disseminate/Dockerfile

62 lines
1.6 KiB
Docker
Raw Normal View History

# node image
FROM node:21-alpine3.18 as compiled
2024-03-29 06:29:56 +01:00
WORKDIR /tmp
USER root
# Copy the source code into the temp folder.
2024-03-29 06:29:56 +01:00
COPY . /tmp
# Installing the dependencies required for compiling.
RUN yarn install && yarn global add typescript
# Compile the project FROM typescript INTO javascript
2024-03-29 06:29:56 +01:00
RUN tsc
# Putting some stuff into the final build
RUN cp -r /tmp/*.json /tmp/build/ && \
cp -r /tmp/data.template /tmp/build/ && \
cp -r /tmp/src/views /tmp/build/src/ && \
cp -r /tmp/data.template /tmp/build && \
cp -r /tmp/scripts/docker_bootstrapper.sh /tmp/build/bootstrapper.sh && \
cp -r /tmp/scripts/docker_run.sh /tmp/build/runner.sh
# The final version of disseminate is now in /tmp/build
FROM node:21-alpine3.18 as main_image
# Create a volume for our data folder
VOLUME ["/app/data"]
# Create a directory for our new app.
RUN mkdir -p /app
# Switch to the directory.
2024-03-29 06:29:56 +01:00
WORKDIR /app
# Delete default node user for the next step.
RUN deluser node
# We want to run disseminate as a non-root user.
2024-03-31 11:49:37 +02:00
ARG UID=1000
ARG GID=1000
2024-03-31 11:44:09 +02:00
RUN addgroup -g $GID disseminate && \
adduser --home /app --uid $UID -G disseminate --disabled-password disseminate
# Give our non-root user access to /app
RUN chown -R disseminate:disseminate /app
# Installing bash, mostly for debugging.
RUN apk add bash
# Switching to non-root user.
USER disseminate
# Copying the compiled project into our main image, ownership of the build is set to our aforementioned (non-root) user.
COPY --chown=$UID:$GID --from=compiled /tmp/build/ /app
# Installing the dependencies.
RUN yarn install --production
# Startup command
CMD ["npm", "run", "docker:prod:bootstrapper"]