build: Dockerfile defaults are env vars instead of CMD args

This commit is contained in:
Thomas Dupont 2022-07-05 14:49:51 +02:00 committed by Joachim Van Herwegen
parent a461586921
commit c6c42e40cc

View File

@ -1,13 +1,13 @@
# Build stage # Build stage
FROM node:lts-alpine AS build FROM node:lts-alpine AS build
## Set current working directory # Set current working directory
WORKDIR /community-server WORKDIR /community-server
## Copy the dockerfile's context's community server files # Copy the dockerfile's context's community server files
COPY . . COPY . .
## Install and build the Solid community server (prepare script cannot run in wd) # Install and build the Solid community server (prepare script cannot run in wd)
RUN npm ci --unsafe-perm && npm run build RUN npm ci --unsafe-perm && npm run build
@ -15,17 +15,17 @@ RUN npm ci --unsafe-perm && npm run build
# Runtime stage # Runtime stage
FROM node:lts-alpine FROM node:lts-alpine
## Add contact informations for questions about the container # Add contact informations for questions about the container
LABEL maintainer="Solid Community Server Docker Image Maintainer <thomas.dupont@ugent.be>" LABEL maintainer="Solid Community Server Docker Image Maintainer <thomas.dupont@ugent.be>"
## Container config & data dir for volume sharing # Container config & data dir for volume sharing
## Defaults to filestorage with /data directory (passed through CMD below) # Defaults to filestorage with /data directory (passed through CMD below)
RUN mkdir /config /data RUN mkdir /config /data
## Set current directory # Set current directory
WORKDIR /community-server WORKDIR /community-server
## Copy runtime files from build stage # Copy runtime files from build stage
COPY --from=build /community-server/package.json . COPY --from=build /community-server/package.json .
COPY --from=build /community-server/bin ./bin COPY --from=build /community-server/bin ./bin
COPY --from=build /community-server/config ./config COPY --from=build /community-server/config ./config
@ -33,11 +33,12 @@ COPY --from=build /community-server/dist ./dist
COPY --from=build /community-server/node_modules ./node_modules COPY --from=build /community-server/node_modules ./node_modules
COPY --from=build /community-server/templates ./templates COPY --from=build /community-server/templates ./templates
## Informs Docker that the container listens on the specified network port at runtime # Informs Docker that the container listens on the specified network port at runtime
EXPOSE 3000 EXPOSE 3000
## Set command run by the container # Set command run by the container
ENTRYPOINT [ "node", "bin/server.js" ] ENTRYPOINT [ "node", "bin/server.js" ]
## By default run in filemode (overriden if passing alternative arguments) # By default run in filemode (overriden if passing alternative arguments or env vars)
CMD [ "-c", "config/file.json", "-f", "/data" ] ENV CSS_CONFIG=config/file.json
ENV CSS_ROOT_FILE_PATH=/data