Skip to content

Commit

Permalink
feat: docker image refactor a new internal binary run (#3475)
Browse files Browse the repository at this point in the history
  • Loading branch information
juanpicado committed Nov 8, 2022
1 parent 644938c commit ebaaf3f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 51 deletions.
42 changes: 0 additions & 42 deletions .npmignore

This file was deleted.

35 changes: 26 additions & 9 deletions Dockerfile
Expand Up @@ -15,15 +15,19 @@ RUN apk --no-cache add openssl ca-certificates wget && \
WORKDIR /opt/verdaccio-build
COPY . .

## build the project and create a tarball of the project for later
## global installation
RUN yarn config set npmRegistryServer $VERDACCIO_BUILD_REGISTRY && \
yarn config set enableProgressBars true && \
yarn config set enableTelemetry false && \
yarn config set enableGlobalCache false && \
yarn config set enableScripts false && \
yarn install --immutable && \
yarn code:docker-build && \
yarn cache clean && \
yarn workspaces focus --production
yarn install && \
yarn code:docker-build
## pack the project
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

FROM node:18.12.0-alpine
LABEL maintainer="https://github.com/verdaccio/verdaccio"
Expand All @@ -38,16 +42,29 @@ ENV PATH=$VERDACCIO_APPDIR/docker-bin:$PATH \

WORKDIR $VERDACCIO_APPDIR

# https://github.com/Yelp/dumb-init
RUN apk --no-cache add openssl dumb-init

RUN mkdir -p /verdaccio/storage /verdaccio/plugins /verdaccio/conf

COPY --from=builder /opt/verdaccio-build .
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
RUN npm install -g $VERDACCIO_APPDIR/verdaccio.tgz \
## clean up cache
&& npm cache clean --force \
&& rm -Rf .npm/ \
&& rm $VERDACCIO_APPDIR/verdaccio.tgz \
# yarn is not need it after this step
&& rm -Rf /opt/yarn-v1.22.19/

ADD conf/docker.yaml /verdaccio/conf/config.yaml
ADD docker-bin $VERDACCIO_APPDIR/docker-bin

RUN adduser -u $VERDACCIO_USER_UID -S -D -h $VERDACCIO_APPDIR -g "$VERDACCIO_USER_NAME user" -s /sbin/nologin $VERDACCIO_USER_NAME && \
chmod -R +x $VERDACCIO_APPDIR/bin $VERDACCIO_APPDIR/docker-bin && \
chmod -R +x /usr/local/lib/node_modules/verdaccio/bin/verdaccio $VERDACCIO_APPDIR/docker-bin && \
chown -R $VERDACCIO_USER_UID:root /verdaccio/storage && \
chmod -R g=u /verdaccio/storage /etc/passwd

Expand All @@ -59,4 +76,4 @@ VOLUME /verdaccio/storage

ENTRYPOINT ["uid_entrypoint"]

CMD node -r ./.pnp.js $VERDACCIO_APPDIR/bin/verdaccio --config /verdaccio/conf/config.yaml --listen $VERDACCIO_PROTOCOL://0.0.0.0:$VERDACCIO_PORT
CMD verdaccio --config /verdaccio/conf/config.yaml --listen $VERDACCIO_PROTOCOL://0.0.0.0:$VERDACCIO_PORT
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -17,6 +17,7 @@
"type": "opencollective",
"url": "https://opencollective.com/verdaccio"
},
"files": ["./build", "./index.js", "./conf/"],
"dependencies": {
"@verdaccio/commons-api": "10.2.0",
"@verdaccio/local-storage": "10.3.1",
Expand Down

0 comments on commit ebaaf3f

Please sign in to comment.