From 1ac4e8014f08ed1a3bfdcfcf621a7c14edfa443f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=97=AA=D1=94=CE=BD=CE=B9=CE=B7=20=E1=97=B7=CF=85=D0=BD?= =?UTF-8?q?=CA=9F?= Date: Sat, 14 Aug 2021 19:03:06 -0400 Subject: [PATCH 1/3] feat: dockerfile updates --- Dockerfile | 58 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3539bd9f..161af7bb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 ENV PORT=80 \ @@ -8,24 +41,15 @@ ENV PORT=80 \ # Create and set the working directory WORKDIR ${DIRECTORY} -# Copy over both 'package.json' and 'package-lock.json' (if available) -COPY package*.json ./ -COPY yarn.lock ./ +# Install tini and tzdata +RUN apk add --no-cache tzdata tini -# Install project dependencies -RUN yarn +# copy from build image +COPY --from=BUILD_IMAGE /app ./ -# Copy over all project files and folders to the working directory -COPY . . - -# Build initial app for production -RUN yarn build +# Finally, run start command to serve up the built application +ENTRYPOINT [ "/sbin/tini", "--" ] +CMD [ "yarn", "start" ] # Expose given 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 From 1d526b73e9a6fba5f39431a18f25775de23f2a4d Mon Sep 17 00:00:00 2001 From: Devin Buhl Date: Sat, 14 Aug 2021 19:22:30 -0400 Subject: [PATCH 2/3] fix: update dockerfile --- Dockerfile | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 161af7bb..2a0e4cd1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,8 @@ -FROM node:14.17-alpine AS BUILD_IMAGE +FROM node:14.17.5-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 \ @@ -16,7 +11,7 @@ RUN \ esac # Create and set the working directory -WORKDIR ${DIRECTORY} +WORKDIR /app COPY package.json yarn.lock ./ RUN yarn install --frozen-lockfile --network-timeout 1000000 @@ -27,11 +22,11 @@ COPY . ./ # Build initial app for production RUN yarn build -# remove development dependencies -RUN yarn install --production --ignore-scripts --prefer-offline +# # remove development dependencies +# RUN yarn install --production --ignore-scripts --prefer-offline # Build the final image -FROM node:14.17-alpine +FROM node:14.17.5-alpine # Define some ENV Vars ENV PORT=80 \ @@ -49,7 +44,7 @@ COPY --from=BUILD_IMAGE /app ./ # Finally, run start command to serve up the built application ENTRYPOINT [ "/sbin/tini", "--" ] -CMD [ "yarn", "start" ] +CMD [ "yarn", "build-and-start" ] # Expose given port EXPOSE ${PORT} From 1cbdee31dc1da557538abd45d600aefd56859963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=97=AA=D1=94=CE=BD=CE=B9=CE=B7=20=E1=97=B7=CF=85=D0=BD?= =?UTF-8?q?=CA=9F?= Date: Sat, 14 Aug 2021 19:23:29 -0400 Subject: [PATCH 3/3] add health check back in --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index 2a0e4cd1..cb9a39e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,3 +48,6 @@ CMD [ "yarn", "build-and-start" ] # Expose given port EXPOSE ${PORT} + +# 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