2024-03-04 14:00:17 +01:00
|
|
|
FROM node:18.19.1-alpine AS BUILD_IMAGE
|
2022-01-29 01:31:41 +01:00
|
|
|
|
2022-02-14 00:30:34 +01:00
|
|
|
# Set the platform to build image for
|
2022-01-29 01:31:41 +01:00
|
|
|
ARG TARGETPLATFORM
|
|
|
|
ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}
|
|
|
|
|
2022-02-14 00:30:34 +01:00
|
|
|
# Install additional tools needed if on arm64 / armv7
|
2022-01-29 01:31:41 +01:00
|
|
|
RUN \
|
|
|
|
case "${TARGETPLATFORM}" in \
|
2022-02-05 06:39:14 +01:00
|
|
|
'linux/arm64') apk add --no-cache python3 make g++ ;; \
|
|
|
|
'linux/arm/v7') apk add --no-cache python3 make g++ ;; \
|
2022-01-29 01:31:41 +01:00
|
|
|
esac
|
|
|
|
|
|
|
|
# Create and set the working directory
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
# Install app dependencies
|
2024-03-03 20:03:17 +01:00
|
|
|
COPY package.json yarn.lock ./
|
2024-03-03 22:07:56 +01:00
|
|
|
RUN yarn install --ignore-engines --immutable --no-cache --network-timeout 300000 --network-concurrency 1
|
2022-01-29 01:31:41 +01:00
|
|
|
|
|
|
|
# Copy over all project files and folders to the working directory
|
|
|
|
COPY . ./
|
|
|
|
|
|
|
|
# Build initial app for production
|
2024-03-04 14:47:15 +01:00
|
|
|
RUN yarn build --mode production
|
2022-01-29 01:31:41 +01:00
|
|
|
|
2022-02-14 00:30:34 +01:00
|
|
|
# Production stage
|
2024-03-04 14:00:17 +01:00
|
|
|
FROM node:20.11.1-alpine3.19
|
2021-08-15 01:03:06 +02:00
|
|
|
|
|
|
|
# Define some ENV Vars
|
2024-04-13 13:32:17 +02:00
|
|
|
ENV PORT=8080 \
|
2021-08-15 12:24:04 +02:00
|
|
|
DIRECTORY=/app \
|
2022-02-20 12:56:26 +01:00
|
|
|
IS_DOCKER=true
|
2022-02-17 15:52:07 +01:00
|
|
|
|
2021-08-15 01:03:06 +02:00
|
|
|
# Create and set the working directory
|
|
|
|
WORKDIR ${DIRECTORY}
|
|
|
|
|
2022-09-07 17:25:11 +02:00
|
|
|
# Update tzdata for setting timezone
|
|
|
|
RUN apk add --no-cache tzdata
|
2022-02-20 12:56:26 +01:00
|
|
|
|
2022-01-29 01:31:41 +01:00
|
|
|
# Copy built application from build phase
|
2022-03-14 00:35:19 +01:00
|
|
|
COPY --from=BUILD_IMAGE /app ./
|
2021-06-04 20:57:43 +02:00
|
|
|
|
2022-01-29 01:31:41 +01:00
|
|
|
# Finally, run start command to serve up the built application
|
2024-04-22 13:40:46 +02:00
|
|
|
CMD [ "yarn", "start" ]
|
2021-06-10 20:46:46 +02:00
|
|
|
|
2022-02-14 00:30:34 +01:00
|
|
|
# Expose the port
|
2021-08-15 01:03:06 +02:00
|
|
|
EXPOSE ${PORT}
|
2021-08-15 01:23:29 +02:00
|
|
|
|
2022-02-14 00:30:34 +01:00
|
|
|
# Run simple healthchecks every 5 mins, to check that everythings still great
|
2023-01-21 17:33:11 +01:00
|
|
|
HEALTHCHECK --interval=5m --timeout=5s --start-period=30s CMD yarn health-check
|