dashy/Dockerfile

54 lines
1.4 KiB
Docker
Raw Permalink Normal View History

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