dashy/Dockerfile

52 lines
1.3 KiB
Docker
Raw Normal View History

2022-02-05 06:39:14 +01:00
FROM node:16.13.2-alpine AS BUILD_IMAGE
ARG TARGETPLATFORM
ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}
# Install additional tools needed on arm64 and armv7
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++ ;; \
esac
# Create and set the working directory
WORKDIR /app
# Install app dependencies
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile --network-timeout 1000000
# Copy over all project files and folders to the working directory
COPY . ./
# Build initial app for production
RUN yarn build
# Build the final image
FROM node:16.13.2-alpine
2021-08-15 01:03:06 +02:00
# Define some ENV Vars
ENV PORT=80 \
DIRECTORY=/app \
IS_DOCKER=true
2021-08-15 01:03:06 +02:00
# Create and set the working directory
WORKDIR ${DIRECTORY}
# Install tini for initialization and tzdata for setting timezone
RUN apk add --no-cache tzdata tini
2021-08-15 01:03:06 +02:00
# Copy built application from build phase
COPY --from=BUILD_IMAGE /app ./
# Finally, run start command to serve up the built application
ENTRYPOINT [ "/sbin/tini", "--" ]
CMD [ "yarn", "build-and-start" ]
2021-08-15 01:03:06 +02:00
# Expose given port
EXPOSE ${PORT}
2021-08-15 01:23:29 +02:00
# Run simple healthchecks every 5 mins, to check the Dashy's everythings great
HEALTHCHECK --interval=5m --timeout=2s --start-period=30s CMD yarn health-check