2023-09-24 09:26:07 +02:00
FROM --platform=${BUILDPLATFORM:-linux/amd64} node:20.7.0-alpine as builder
2016-05-09 19:19:35 +02:00
2018-07-30 12:08:12 +02:00
ENV NODE_ENV = production \
2021-09-07 21:19:44 +02:00
VERDACCIO_BUILD_REGISTRY = https://registry.npmjs.org \
2021-05-13 23:13:57 +02:00
HUSKY_SKIP_INSTALL = 1 \
CI = true \
HUSKY_DEBUG = 1
2018-07-30 12:08:12 +02:00
2022-11-19 22:00:56 +01:00
RUN apk add --force-overwrite && \
apk --no-cache add openssl ca-certificates wget && \
2022-07-12 22:26:18 +02:00
apk --no-cache add g++ gcc libgcc libstdc++ linux-headers make python3 && \
2018-08-13 23:27:31 +02:00
wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
2022-11-19 22:00:56 +01:00
wget -q https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.35-r0/glibc-2.35-r0.apk && \
apk add --force-overwrite glibc-2.35-r0.apk
2017-07-04 18:10:41 +02:00
2018-07-25 18:48:26 +02:00
WORKDIR /opt/verdaccio-build
COPY . .
2017-07-04 18:10:41 +02:00
2023-05-30 14:53:42 +02:00
## build the project and create a tarball of the project for later
2022-11-08 07:29:19 +01:00
## global installation
2020-10-11 19:06:21 +02:00
RUN yarn config set npmRegistryServer $VERDACCIO_BUILD_REGISTRY && \
2021-05-13 23:13:57 +02:00
yarn config set enableProgressBars true && \
2022-11-02 23:09:15 +01:00
yarn config set enableScripts false && \
2023-02-14 22:20:11 +01:00
yarn install --immutable && \
2023-02-09 21:42:24 +01:00
yarn build
2023-05-30 14:53:42 +02:00
## pack the project
2022-11-08 07:29:19 +01:00
RUN yarn pack --out verdaccio.tgz \
&& mkdir -p /opt/tarball \
&& mv /opt/verdaccio-build/verdaccio.tgz /opt/tarball
## clean up and reduce bundle size
RUN rm -Rf /opt/verdaccio-build
2016-05-09 19:19:35 +02:00
2023-09-24 09:26:07 +02:00
FROM node:20.7.0-alpine
2018-07-25 18:48:26 +02:00
LABEL maintainer = "https://github.com/verdaccio/verdaccio"
2018-07-30 12:08:12 +02:00
ENV VERDACCIO_APPDIR = /opt/verdaccio \
VERDACCIO_USER_NAME = verdaccio \
VERDACCIO_USER_UID = 10001 \
VERDACCIO_PORT = 4873 \
VERDACCIO_PROTOCOL = http
ENV PATH = $VERDACCIO_APPDIR /docker-bin:$PATH \
HOME = $VERDACCIO_APPDIR
WORKDIR $VERDACCIO_APPDIR
2022-11-08 07:29:19 +01:00
# https://github.com/Yelp/dumb-init
2018-07-25 18:48:26 +02:00
RUN apk --no-cache add openssl dumb-init
2018-07-18 14:53:08 +02:00
RUN mkdir -p /verdaccio/storage /verdaccio/plugins /verdaccio/conf
2017-07-18 20:53:37 +02:00
2022-11-08 07:29:19 +01:00
COPY --from= builder /opt/tarball .
USER root
# install verdaccio as a global package so is fully handled by npm
# ensure none dependency is being missing and is prod by default
2023-05-30 14:53:42 +02:00
RUN npm install -g $VERDACCIO_APPDIR /verdaccio.tgz \
2022-11-08 07:29:19 +01:00
## clean up cache
&& npm cache clean --force \
&& rm -Rf .npm/ \
&& rm $VERDACCIO_APPDIR /verdaccio.tgz \
# yarn is not need it after this step
2023-05-30 14:53:42 +02:00
# Also remove the symlinks added in the [`node:alpine` Docker image](https://github.com/nodejs/docker-node/blob/02a64a08a98a472c6141cd583d2e9fc47bcd9bfd/18/alpine3.16/Dockerfile#L91-L92).
&& rm -Rf /opt/yarn-v1.22.19/ /usr/local/bin/yarn /usr/local/bin/yarnpkg
2018-07-25 18:48:26 +02:00
2016-05-09 19:19:35 +02:00
ADD conf/docker.yaml /verdaccio/conf/config.yaml
2022-11-08 07:29:19 +01:00
ADD docker-bin $VERDACCIO_APPDIR /docker-bin
2016-05-09 19:19:35 +02:00
2018-07-30 12:08:12 +02:00
RUN adduser -u $VERDACCIO_USER_UID -S -D -h $VERDACCIO_APPDIR -g " $VERDACCIO_USER_NAME user " -s /sbin/nologin $VERDACCIO_USER_NAME && \
2022-11-08 07:29:19 +01:00
chmod -R +x /usr/local/lib/node_modules/verdaccio/bin/verdaccio $VERDACCIO_APPDIR /docker-bin && \
2018-07-30 12:08:12 +02:00
chown -R $VERDACCIO_USER_UID :root /verdaccio/storage && \
2018-07-25 18:48:26 +02:00
chmod -R g = u /verdaccio/storage /etc/passwd
2017-01-14 21:51:18 +01:00
2018-07-25 18:48:26 +02:00
USER $VERDACCIO_USER_UID
2017-01-14 21:51:18 +01:00
2018-07-25 18:48:26 +02:00
EXPOSE $VERDACCIO_PORT
2016-05-09 19:19:35 +02:00
2018-07-25 18:48:26 +02:00
VOLUME /verdaccio/storage
2016-05-09 19:19:35 +02:00
2018-07-25 18:48:26 +02:00
ENTRYPOINT [ "uid_entrypoint" ]
2017-07-04 18:10:41 +02:00
2022-11-08 07:29:19 +01:00
CMD verdaccio --config /verdaccio/conf/config.yaml --listen $VERDACCIO_PROTOCOL ://0.0.0.0:$VERDACCIO_PORT