feat: dockerfile updates

This commit is contained in:
ᗪєνιη ᗷυнʟ 2021-08-14 19:03:06 -04:00
parent 35c2516233
commit 1ac4e8014f
1 changed files with 41 additions and 17 deletions

View File

@ -1,4 +1,37 @@
FROM node:lts-alpine3.14 FROM node:14.17-alpine AS BUILD_IMAGE
ARG TARGETPLATFORM
ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}
# Define some ENV Vars
ENV PORT=80 \
DIRECTORY=/app \
IS_DOCKER=true
# 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
WORKDIR ${DIRECTORY}
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
# remove development dependencies
RUN yarn install --production --ignore-scripts --prefer-offline
# Build the final image
FROM node:14.17-alpine
# Define some ENV Vars # Define some ENV Vars
ENV PORT=80 \ ENV PORT=80 \
@ -8,24 +41,15 @@ ENV PORT=80 \
# Create and set the working directory # Create and set the working directory
WORKDIR ${DIRECTORY} WORKDIR ${DIRECTORY}
# Copy over both 'package.json' and 'package-lock.json' (if available) # Install tini and tzdata
COPY package*.json ./ RUN apk add --no-cache tzdata tini
COPY yarn.lock ./
# Install project dependencies # copy from build image
RUN yarn COPY --from=BUILD_IMAGE /app ./
# Copy over all project files and folders to the working directory # Finally, run start command to serve up the built application
COPY . . ENTRYPOINT [ "/sbin/tini", "--" ]
CMD [ "yarn", "start" ]
# Build initial app for production
RUN yarn build
# Expose given port # Expose given port
EXPOSE ${PORT} EXPOSE ${PORT}
# Finally, run start command to serve up the built application
CMD [ "yarn", "build-and-start"]
# 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