dashy/Dockerfile

54 lines
1.4 KiB
Docker
Raw Normal View History

2021-08-14 23:22:30 +00:00
FROM node:14.17.5-alpine AS BUILD_IMAGE
2021-08-14 23:03:06 +00:00
ARG TARGETPLATFORM
ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}
2021-08-14 23:03:06 +00:00
# Install additional tools needed on arm64 and armv7
RUN \
case "${TARGETPLATFORM}" in \
'linux/arm64') apk add --no-cache python make g++ ;; \
'linux/arm/v7') apk add --no-cache python make g++ ;; \
esac
# Create and set the working directory
2021-08-14 23:22:30 +00:00
WORKDIR /app
2021-08-14 23:03:06 +00:00
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile --network-timeout 1000000
# Copy over all project files and folders to the working directory
2021-08-14 23:03:06 +00:00
COPY . ./
# Build initial app for production
RUN yarn build
2021-08-14 23:22:30 +00:00
# # remove development dependencies
# RUN yarn install --production --ignore-scripts --prefer-offline
2021-08-14 23:03:06 +00:00
# Build the final image
2021-08-14 23:22:30 +00:00
FROM node:14.17.5-alpine
2021-08-14 23:03:06 +00:00
# Define some ENV Vars
ENV PORT=80 \
DIRECTORY=/app \
IS_DOCKER=true
# Create and set the working directory
WORKDIR ${DIRECTORY}
# Install tini and tzdata
RUN apk add --no-cache tzdata tini
# copy from build image
COPY --from=BUILD_IMAGE /app ./
# Finally, run start command to serve up the built application
2021-08-14 23:03:06 +00:00
ENTRYPOINT [ "/sbin/tini", "--" ]
2021-08-14 23:22:30 +00:00
CMD [ "yarn", "build-and-start" ]
2021-08-14 23:03:06 +00:00
# Expose given port
EXPOSE ${PORT}
2021-08-14 23:23:29 +00: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