2021-08-15 02:22:30 +03:00
|
|
|
FROM node:14.17.5-alpine AS BUILD_IMAGE
|
2021-08-15 02:03:06 +03:00
|
|
|
|
|
|
|
ARG TARGETPLATFORM
|
|
|
|
ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}
|
2021-04-17 20:42:38 +03:00
|
|
|
|
2021-08-15 02:03:06 +03: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
|
|
|
|
|
2021-06-04 21:57:43 +03:00
|
|
|
# Create and set the working directory
|
2021-08-15 02:22:30 +03:00
|
|
|
WORKDIR /app
|
2021-04-17 20:42:38 +03:00
|
|
|
|
2021-08-15 02:03:06 +03:00
|
|
|
COPY package.json yarn.lock ./
|
|
|
|
RUN yarn install --frozen-lockfile --network-timeout 1000000
|
2021-05-24 22:46:58 +03:00
|
|
|
|
2021-06-04 21:57:43 +03:00
|
|
|
# Copy over all project files and folders to the working directory
|
2021-08-15 02:03:06 +03:00
|
|
|
COPY . ./
|
2021-04-17 20:42:38 +03:00
|
|
|
|
2021-06-04 21:57:43 +03:00
|
|
|
# Build initial app for production
|
|
|
|
RUN yarn build
|
2021-04-17 20:42:38 +03:00
|
|
|
|
2021-08-15 02:22:30 +03:00
|
|
|
# # remove development dependencies
|
|
|
|
# RUN yarn install --production --ignore-scripts --prefer-offline
|
2021-08-15 02:03:06 +03:00
|
|
|
|
|
|
|
# Build the final image
|
2021-08-15 02:22:30 +03:00
|
|
|
FROM node:14.17.5-alpine
|
2021-08-15 02:03:06 +03: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 ./
|
2021-06-04 21:57:43 +03:00
|
|
|
|
|
|
|
# Finally, run start command to serve up the built application
|
2021-08-15 02:03:06 +03:00
|
|
|
ENTRYPOINT [ "/sbin/tini", "--" ]
|
2021-08-15 02:22:30 +03:00
|
|
|
CMD [ "yarn", "build-and-start" ]
|
2021-06-10 21:46:46 +03:00
|
|
|
|
2021-08-15 02:03:06 +03:00
|
|
|
# Expose given port
|
|
|
|
EXPOSE ${PORT}
|