-
Notifications
You must be signed in to change notification settings - Fork 56
refactor(dockerfile): builder multistage pattern & random uid user support #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
47 changes: 20 additions & 27 deletions
Dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,41 +1,34 @@ | ||
| FROM node:10-alpine | ||
| LABEL maintainer="https://github.com/bufferoverflow/verdaccio-gitlab" | ||
|
|
||
| RUN apk --no-cache add wget openssl dumb-init && \ | ||
| apk del openssl | ||
|
|
||
| ENV APPDIR /usr/local/app | ||
| FROM node:10-alpine as builder | ||
|
|
||
| WORKDIR $APPDIR | ||
| WORKDIR /opt/verdaccio-gitlab-build | ||
| COPY . . | ||
|
|
||
| ADD . $APPDIR | ||
| ENV NODE_ENV=production \ | ||
| VERDACCIO_BUILD_REGISTRY=https://registry.npmjs.org/ | ||
|
|
||
| ENV NODE_ENV=production | ||
|
|
||
| RUN npm config set registry https://registry.npmjs.org/ && \ | ||
| RUN yarn config set registry $VERDACCIO_BUILD_REGISTRY && \ | ||
| yarn install --production=false && \ | ||
| yarn build && \ | ||
| yarn cache clean && \ | ||
| yarn install --production=true --pure-lockfile && \ | ||
| yarn add file:. | ||
|
|
||
| RUN mkdir -p /verdaccio/storage /verdaccio/conf | ||
| yarn install --production=true --pure-lockfile | ||
|
|
||
| ADD docker-verdaccio-gitlab.config.yaml /verdaccio/conf/config.yaml | ||
|
|
||
| RUN addgroup -S verdaccio && adduser -S -G verdaccio verdaccio && \ | ||
| chown -R verdaccio:verdaccio "$APPDIR" && \ | ||
| chown -R verdaccio:verdaccio /verdaccio | ||
|
|
||
| USER verdaccio | ||
| FROM verdaccio/verdaccio:4.x-next | ||
| LABEL maintainer="https://github.com/bufferoverflow/verdaccio-gitlab" | ||
|
|
||
| ENV PORT 4873 | ||
| ENV PROTOCOL http | ||
| # Go back to root to be able to install the plugin | ||
| USER root | ||
|
|
||
| EXPOSE $PORT | ||
| COPY --from=builder /opt/verdaccio-gitlab-build/lib /opt/verdaccio-gitlab/lib | ||
| COPY --from=builder /opt/verdaccio-gitlab-build/package.json /opt/verdaccio-gitlab/package.json | ||
| COPY --from=builder /opt/verdaccio-gitlab-build/node_modules /opt/verdaccio-gitlab/node_modules | ||
|
|
||
| VOLUME ["/verdaccio"] | ||
| ADD conf/docker.yaml /verdaccio/conf/config.yaml | ||
|
|
||
| ENTRYPOINT ["/usr/bin/dumb-init", "--"] | ||
| # Inherited from parent image | ||
| WORKDIR $VERDACCIO_APPDIR | ||
| RUN ln -s /opt/verdaccio-gitlab/lib /verdaccio/plugins/verdaccio-gitlab | ||
|
|
||
| CMD $APPDIR/node_modules/.bin/verdaccio --config /verdaccio/conf/config.yaml --listen $PROTOCOL://0.0.0.0:${PORT} | ||
| # Inherited from parent image | ||
| USER $VERDACCIO_USER_UID |
4 changes: 3 additions & 1 deletion
docker-verdaccio-gitlab.config.yaml → conf/docker.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| storage: /verdaccio/storage | ||
| storage: /verdaccio/storage/data | ||
|
|
||
| plugins: /verdaccio/plugins | ||
|
|
||
| listen: | ||
| - 0.0.0.0:4873 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.