1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-08 23:25:51 +01:00

apm: update docker

This commit is contained in:
Marc Bernard 2024-07-19 13:02:49 -04:00
parent 71fcd2de91
commit 5bcfd7e2e2
3 changed files with 81 additions and 43 deletions

@ -8,26 +8,22 @@
.* .*
# you can add exceptions like in .gitignore to maintain a whitelist: # you can add exceptions like in .gitignore to maintain a whitelist:
# e.g. # e.g.
!.babelrc !babel.config.js
!.eslintrc !eslintrc.js
!.prettierrc.json !.prettierrc
!.prettierignore
!.eslintignore !.eslintignore
!.stylelintrc !.stylelintrc
!.jest.config.js
!.jestEnvironment.js
!.yarnrc.yml
!.yarn/releases/yarn-*.cjs
!.yarn/plugins/*
!.pnp.js
# do not copy over node_modules we will run `pnpm install` anyway # just in case, yarn 2 pnp is enabled
node_modules node_modules
website .husky/
jest .git/
docs
contrib
docker-examples
website
systemd
e2e
assets
types
scripts
# output from test runs and similar things # output from test runs and similar things
*.log *.log
@ -37,7 +33,21 @@ coverage/
# IDE config files # IDE config files
jsconfig.json jsconfig.json
*.iml *.iml
# let's not get too recursive ;) # let's not get too recursive ;)
Dockerfile* Dockerfile*
docker-compose*.yaml docker-compose*.yaml
.github/
.husky/
*.log
coverage/
.vscode/
*.md
contrib/
docs/
docker-examples/
systemd/
assets/
jest*.js
test/
wiki/
debug/

@ -4,13 +4,17 @@ on:
workflow_dispatch: workflow_dispatch:
push: push:
paths: paths:
- '.github/workflows/docker-apm.yml' - .github/workflows/docker-publish.yml
- 'packages/**' - 'src/**'
- 'conf/**'
- 'types/**'
- 'docker-bin/**' - 'docker-bin/**'
- 'bin/**'
- 'package.json' - 'package.json'
- 'pnpm-*.yaml' - 'yarn.lock'
- 'Dockerfile' - '.yarn/**'
- '.dockerignore' - '.yarnrc.yaml'
- '.pnp.js'
branches: branches:
- 'apm' - 'apm'

@ -1,9 +1,13 @@
FROM --platform=${BUILDPLATFORM:-linux/amd64} node:21-alpine AS builder FROM --platform=${BUILDPLATFORM:-linux/amd64} node:20.15.1-alpine AS builder
ENV NODE_ENV=development \ ENV NODE_ENV=production \
VERDACCIO_BUILD_REGISTRY=https://registry.npmjs.org VERDACCIO_BUILD_REGISTRY=https://registry.npmjs.org \
HUSKY_SKIP_INSTALL=1 \
CI=true \
HUSKY_DEBUG=1
RUN apk --no-cache add openssl ca-certificates wget && \ RUN apk add --force-overwrite && \
apk --no-cache add openssl ca-certificates wget && \
apk --no-cache add g++ gcc libgcc libstdc++ linux-headers make python3 && \ apk --no-cache add g++ gcc libgcc libstdc++ linux-headers make python3 && \
wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \ wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
wget -q https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.35-r0/glibc-2.35-r0.apk && \ wget -q https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.35-r0/glibc-2.35-r0.apk && \
@ -11,17 +15,24 @@ RUN apk --no-cache add openssl ca-certificates wget && \
WORKDIR /opt/verdaccio-build WORKDIR /opt/verdaccio-build
COPY . . COPY . .
RUN npm -g i pnpm@8.14.0 && \
pnpm config set registry $VERDACCIO_BUILD_REGISTRY && \
pnpm install --frozen-lockfile --ignore-scripts && \
rm -Rf test && \
pnpm run build
# FIXME: need to remove devDependencies from the build
# NODE_ENV=production pnpm install --frozen-lockfile --ignore-scripts
# RUN pnpm install --prod --ignore-scripts
FROM node:21-alpine ## build the project and create a tarball of the project for later
LABEL maintainer="https://github.com/verdaccio/verdaccio" ## global installation
RUN yarn config set npmRegistryServer $VERDACCIO_BUILD_REGISTRY && \
yarn config set enableProgressBars true && \
yarn config set enableScripts false && \
yarn install --immutable && \
yarn build
## pack the project
RUN yarn pack --dry-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:20.15.1-alpine
LABEL maintainer="https://github.com/abapPM/abapPM"
ENV VERDACCIO_APPDIR=/opt/verdaccio \ ENV VERDACCIO_APPDIR=/opt/verdaccio \
VERDACCIO_USER_NAME=verdaccio \ VERDACCIO_USER_NAME=verdaccio \
@ -33,18 +44,33 @@ ENV PATH=$VERDACCIO_APPDIR/docker-bin:$PATH \
WORKDIR $VERDACCIO_APPDIR WORKDIR $VERDACCIO_APPDIR
# https://github.com/Yelp/dumb-init
RUN apk --no-cache add openssl dumb-init RUN apk --no-cache add openssl dumb-init
RUN mkdir -p /verdaccio/storage /verdaccio/plugins /verdaccio/conf RUN mkdir -p /verdaccio/storage /verdaccio/plugins /verdaccio/conf
COPY --from=builder /opt/verdaccio-build . COPY --from=builder /opt/tarball .
RUN ls packages/config/src/conf USER root
ADD config.yaml /verdaccio/conf/config.yaml # 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
# 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
# apm assets and config
ADD abappm /verdaccio/abappm ADD abappm /verdaccio/abappm
ADD config.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 && \ 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/packages/verdaccio/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 && \ chown -R $VERDACCIO_USER_UID:root /verdaccio/storage && \
chmod -R g=u /verdaccio/storage /etc/passwd chmod -R g=u /verdaccio/storage /etc/passwd
@ -56,6 +82,4 @@ VOLUME /verdaccio/storage
ENTRYPOINT ["uid_entrypoint"] ENTRYPOINT ["uid_entrypoint"]
CMD $VERDACCIO_APPDIR/packages/verdaccio/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
HEALTHCHECK --interval=5s --timeout=1s CMD /verdaccio/abappm/healthcheck.sh