Files
shields/Dockerfile
rroesch1 174b1915c5 fix: Set uid/gid in docker image to 0 (#8908)
* UIDs/GIDs in the docker image are messed up due to strange UIDs/GIDs in tarballs from the npm registry
* This change overrides the UID/GID of all files in `/usr/src/app`

fixes: badges/shields#8906

Co-authored-by: chris48s <chris48s@users.noreply.github.com>
2023-02-20 19:22:14 +00:00

38 lines
915 B
Docker

FROM node:16-alpine AS Builder
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/
RUN apk add python3 make g++
RUN npm install -g "npm@>=8"
# 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
RUN npm prune --production
RUN npm cache clean --force
# Use multi-stage build to reduce size
FROM node:16-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