2024-11-02 23:19:00 +00:00
|
|
|
# Build stage
|
2025-02-14 02:12:50 +00:00
|
|
|
FROM node:22.14.0-bullseye-slim AS builder
|
2018-06-10 15:06:52 -04:00
|
|
|
|
2025-03-05 07:07:47 +01:00
|
|
|
WORKDIR /usr/src/app/build
|
2018-06-10 15:06:52 -04:00
|
|
|
|
2024-11-02 23:19:00 +00:00
|
|
|
# Copy only necessary files for build
|
2022-12-02 18:15:03 +01:00
|
|
|
COPY . .
|
2018-06-10 15:06:52 -04:00
|
|
|
|
2024-11-02 23:19:00 +00:00
|
|
|
# Build and cleanup in a single layer
|
2025-03-05 07:07:47 +01:00
|
|
|
RUN npm ci && \
|
|
|
|
npm run build:prepare-dist && \
|
2024-11-02 23:19:00 +00:00
|
|
|
npm cache clean --force && \
|
2025-03-09 08:29:03 +01:00
|
|
|
rm -rf build/node_modules && \
|
|
|
|
mv build/* \
|
2025-03-05 07:07:47 +01:00
|
|
|
start-docker.sh \
|
|
|
|
/usr/src/app/ && \
|
2025-03-05 09:09:54 +01:00
|
|
|
rm -rf \
|
|
|
|
/usr/src/app/build \
|
|
|
|
/tmp/node-compile-cache
|
2025-03-05 07:07:47 +01:00
|
|
|
|
2025-03-25 09:02:03 +01:00
|
|
|
#TODO: run cleanupNodeModules script
|
2025-03-05 08:54:42 +01:00
|
|
|
#TODO: improve node_modules handling in copy-dist/Dockerfile -> remove duplicated work
|
|
|
|
# currently copy-dist will copy certain node_module folders, but in the Dockerfile we delete them again (to keep image size down),
|
|
|
|
# as we install necessary dependencies in runtime buildstage anyways
|
2024-11-02 23:19:00 +00:00
|
|
|
|
|
|
|
# Runtime stage
|
2025-02-14 02:12:50 +00:00
|
|
|
FROM node:22.14.0-bullseye-slim
|
2018-06-10 15:06:52 -04:00
|
|
|
|
2025-03-05 07:07:47 +01:00
|
|
|
WORKDIR /usr/src/app
|
|
|
|
|
2024-11-02 23:19:00 +00:00
|
|
|
# Install only runtime dependencies
|
2025-03-05 07:07:47 +01:00
|
|
|
RUN apt-get update && \
|
|
|
|
apt-get install -y --no-install-recommends \
|
|
|
|
gosu && \
|
2025-03-05 09:09:54 +01:00
|
|
|
rm -rf \
|
|
|
|
/var/lib/apt/lists/* \
|
|
|
|
/var/cache/apt/*
|
2024-11-02 23:19:00 +00:00
|
|
|
|
2025-03-05 07:07:47 +01:00
|
|
|
COPY --from=builder /usr/src/app ./
|
2020-11-15 20:51:47 +01:00
|
|
|
|
2025-03-05 07:07:47 +01:00
|
|
|
RUN sed -i "/electron/d" package.json && \
|
|
|
|
npm ci --omit=dev && \
|
2025-03-05 09:09:54 +01:00
|
|
|
npm cache clean --force && \
|
|
|
|
rm -rf /tmp/node-compile-cache
|
2024-11-02 23:19:00 +00:00
|
|
|
|
|
|
|
# Configure container
|
2018-06-10 15:06:52 -04:00
|
|
|
EXPOSE 8080
|
2022-05-21 13:25:59 +08:00
|
|
|
CMD [ "./start-docker.sh" ]
|
2024-08-08 14:38:39 -07:00
|
|
|
HEALTHCHECK --start-period=10s CMD exec gosu node node docker_healthcheck.js
|