dashy/Dockerfile

51 lines
1.2 KiB
Docker
Raw Normal View History

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-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
# Create and set the working directory
2021-08-15 02:22:30 +03:00
WORKDIR /app
2021-08-15 02:03:06 +03: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-15 02:03:06 +03:00
COPY . ./
# Build initial app for production
RUN yarn build
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 ./
# 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-08-15 02:03:06 +03:00
# Expose given port
EXPOSE ${PORT}