2025-01-20 20:32:49 +01:00
|
|
|
# Prepare dependencies
|
|
|
|
# In this stage all build and production dependencies are prepared
|
2024-08-19 12:17:21 +02:00
|
|
|
FROM node:20-slim AS dependencies
|
2024-08-21 16:10:47 +02:00
|
|
|
WORKDIR /home/node
|
2024-08-19 12:17:21 +02:00
|
|
|
RUN corepack enable
|
|
|
|
COPY package.json yarn.lock ./
|
|
|
|
RUN yarn install --frozen-lockfile --production && \
|
|
|
|
mv node_modules prod_node_modules && \
|
|
|
|
yarn install --frozen-lockfile
|
|
|
|
|
|
|
|
## tests
|
|
|
|
# FROM dependencies AS test
|
2025-01-20 20:32:49 +01:00
|
|
|
# WORKDIR /home/node
|
2024-08-19 12:17:21 +02:00
|
|
|
# COPY . .
|
|
|
|
# RUN yarn test-sqlite
|
|
|
|
|
2025-01-20 20:32:49 +01:00
|
|
|
## Build
|
|
|
|
## Build and create the package
|
|
|
|
FROM node:20-slim AS build
|
|
|
|
WORKDIR /usr/src/app
|
|
|
|
COPY package.json yarn.lock ./
|
|
|
|
COPY --from=dependencies /home/node/node_modules ./node_modules
|
|
|
|
COPY . .
|
|
|
|
ENV NODE_ENV=production
|
|
|
|
RUN yarn build --production
|
|
|
|
RUN yarn pack --filename /tmp/package.tgz
|
2024-08-19 12:17:21 +02:00
|
|
|
|
2025-01-20 20:32:49 +01:00
|
|
|
## Production
|
|
|
|
## Use the built package
|
2024-08-19 12:17:21 +02:00
|
|
|
FROM node:20-slim
|
2025-01-20 20:32:49 +01:00
|
|
|
RUN --mount=type=bind,from=build,source=/tmp/package.tgz,target=/tmp/package.tgz \
|
|
|
|
tar xf /tmp/package.tgz --owner node --group node -C /home/node --strip-components 1
|
|
|
|
COPY --from=dependencies /home/node/prod_node_modules /home/node/node_modules
|
2024-08-19 12:17:21 +02:00
|
|
|
|
2025-01-20 20:32:49 +01:00
|
|
|
RUN ln -s /home/node/server/cli.js /usr/local/bin/gancio
|
2024-08-19 12:17:21 +02:00
|
|
|
|
|
|
|
EXPOSE 13120
|
2025-01-20 20:32:49 +01:00
|
|
|
ENTRYPOINT ["/home/node/server/cli.js"]
|