2023-01-30 23:02:59 +00:00
|
|
|
# Base image to share ENV vars that activate VENV.
|
2023-10-19 18:22:52 +00:00
|
|
|
FROM node:20.8.1-bookworm-slim AS base
|
2022-11-09 03:36:39 +00:00
|
|
|
|
2022-10-12 14:21:49 +00:00
|
|
|
RUN mkdir /app
|
2023-10-19 18:22:52 +00:00
|
|
|
|
2022-10-12 14:21:49 +00:00
|
|
|
WORKDIR /app
|
|
|
|
|
2023-11-16 15:18:11 +00:00
|
|
|
# curl for debugging
|
|
|
|
# procps for debugging
|
|
|
|
# vim ftw
|
|
|
|
RUN apt-get update \
|
2024-04-15 18:22:34 +00:00
|
|
|
&& apt-get clean -y \
|
|
|
|
&& apt-get install -y -q \
|
|
|
|
curl \
|
|
|
|
procps \
|
|
|
|
vim-tiny \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
2023-11-16 15:18:11 +00:00
|
|
|
|
2022-11-04 23:03:53 +00:00
|
|
|
# this matches total memory on spiffworkflow-demo
|
|
|
|
ENV NODE_OPTIONS=--max_old_space_size=2048
|
|
|
|
|
2023-11-16 15:18:11 +00:00
|
|
|
|
|
|
|
######################## - SETUP
|
|
|
|
|
2023-01-30 23:02:59 +00:00
|
|
|
# Setup image for installing JS dependencies.
|
|
|
|
FROM base AS setup
|
|
|
|
|
|
|
|
COPY . /app/
|
2022-11-09 03:36:39 +00:00
|
|
|
|
2023-01-31 03:35:24 +00:00
|
|
|
RUN cp /app/package.json /app/package.json.bak
|
2023-01-31 14:27:02 +00:00
|
|
|
ADD justservewebserver.package.json /app/package.json
|
2023-01-31 03:35:24 +00:00
|
|
|
RUN npm ci --ignore-scripts
|
|
|
|
RUN cp -r /app/node_modules /app/node_modules.justserve
|
|
|
|
RUN cp /app/package.json.bak /app/package.json
|
|
|
|
|
2022-10-12 14:21:49 +00:00
|
|
|
# npm ci because it respects the lock file.
|
|
|
|
# --ignore-scripts because authors can do bad things in postinstall scripts.
|
|
|
|
# https://cheatsheetseries.owasp.org/cheatsheets/NPM_Security_Cheat_Sheet.html
|
|
|
|
# npx can-i-ignore-scripts can check that it's safe to ignore scripts.
|
2022-11-04 23:04:59 +00:00
|
|
|
RUN npm ci --ignore-scripts
|
2022-11-09 03:36:39 +00:00
|
|
|
|
2023-04-11 19:48:34 +00:00
|
|
|
RUN ./bin/build
|
2023-01-30 15:46:04 +00:00
|
|
|
|
2023-11-16 15:18:11 +00:00
|
|
|
|
|
|
|
######################## - FINAL
|
|
|
|
|
2024-04-15 18:22:34 +00:00
|
|
|
# Use nginx as the base image
|
|
|
|
FROM nginx:1.25.4-bookworm
|
2023-01-30 23:02:59 +00:00
|
|
|
|
2024-04-15 18:22:34 +00:00
|
|
|
# Remove default nginx configuration
|
|
|
|
RUN rm -rf /etc/nginx/conf.d/*
|
2023-01-30 23:02:59 +00:00
|
|
|
|
2024-04-15 18:22:34 +00:00
|
|
|
# Copy the nginx configuration file
|
|
|
|
COPY docker_build/nginx.conf.template /var/tmp
|
2023-01-30 23:02:59 +00:00
|
|
|
|
2024-04-15 18:22:34 +00:00
|
|
|
# Copy the built static files into the nginx directory
|
|
|
|
COPY --from=setup /app/dist /usr/share/nginx/html
|
2023-01-30 23:02:59 +00:00
|
|
|
COPY --from=setup /app/bin /app/bin
|
|
|
|
|
2023-10-19 18:22:52 +00:00
|
|
|
CMD ["/app/bin/boot_server_in_docker"]
|