mirror of
https://github.com/badges/shields.git
synced 2025-04-18 19:44:04 +03:00
* docker: cleanup some building Somehow `npm prune --omit=dev` does not properly remove unneeded dependencies, this is workarounded by deleting the `node_modules` folder and the running install again. It also removes some unneeded large files in the docker container. * docker building: improve caching, don't download node_modules twice
41 lines
958 B
Docker
41 lines
958 B
Docker
FROM node:20-alpine AS builder
|
|
|
|
RUN npm install -g "npm@^10"
|
|
|
|
RUN mkdir -p /usr/src/app
|
|
RUN mkdir /usr/src/app/private
|
|
WORKDIR /usr/src/app
|
|
|
|
COPY package.json package-lock.json /usr/src/app/
|
|
# Without the badge-maker package.json and CLI script in place, `npm ci` will fail.
|
|
COPY badge-maker /usr/src/app/badge-maker/
|
|
|
|
# We need dev deps to build the front end. We don't need Cypress, though.
|
|
RUN NODE_ENV=development CYPRESS_INSTALL_BINARY=0 npm ci
|
|
|
|
COPY . /usr/src/app
|
|
|
|
RUN npm run build \
|
|
&& npm prune --omit=dev --force \
|
|
&& rm -rf node_modules/.cache \
|
|
&& rm -rf frontend package-lock.json
|
|
|
|
|
|
# Use multi-stage build to reduce size
|
|
FROM node:20-alpine
|
|
|
|
ARG version=dev
|
|
ENV DOCKER_SHIELDS_VERSION=$version
|
|
LABEL version=$version
|
|
LABEL fly.version=$version
|
|
|
|
# Run the server using production configs.
|
|
ENV NODE_ENV=production
|
|
|
|
WORKDIR /usr/src/app
|
|
COPY --from=builder --chown=0:0 /usr/src/app /usr/src/app
|
|
|
|
CMD ["node", "server"]
|
|
|
|
EXPOSE 80 443
|