mirror of
https://github.com/Lissy93/dashy.git
synced 2024-11-24 14:08:30 +03:00
57 lines
1.5 KiB
Docker
57 lines
1.5 KiB
Docker
FROM node:16.13.2-alpine AS BUILD_IMAGE
|
|
|
|
# Set the platform to build image for
|
|
ARG TARGETPLATFORM
|
|
ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}
|
|
|
|
# Install additional tools needed if on arm64 / armv7
|
|
RUN \
|
|
case "${TARGETPLATFORM}" in \
|
|
'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
|
|
|
|
# Production stage
|
|
FROM node:16.13.2-alpine
|
|
|
|
# Define some ENV Vars
|
|
ENV PORT=80 \
|
|
DIRECTORY=/app \
|
|
IS_DOCKER=true
|
|
|
|
# Create and set the working directory
|
|
WORKDIR ${DIRECTORY}
|
|
|
|
# Install tini for initialization and tzdata for setting timezone
|
|
RUN apk add --no-cache tzdata tini
|
|
|
|
# Copy built application from build phase
|
|
COPY --from=BUILD_IMAGE /app/dist/ public/
|
|
COPY --from=BUILD_IMAGE /app/node_modules/ node_modules/
|
|
COPY services/ services/
|
|
COPY src/utils/ src/utils/
|
|
COPY package.json yarn.lock server.js ./
|
|
|
|
# Finally, run start command to serve up the built application
|
|
ENTRYPOINT [ "/sbin/tini", "--" ]
|
|
CMD [ "yarn", "start" ]
|
|
|
|
# Expose the port
|
|
EXPOSE ${PORT}
|
|
|
|
# Run simple healthchecks every 5 mins, to check that everythings still great
|
|
HEALTHCHECK --interval=5m --timeout=2s --start-period=30s CMD yarn health-check
|