Created
September 29, 2021 00:20
-
-
Save zingbretsen/4ad4a2437a55ba8cc5a76024e2a11d0f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build image | |
FROM node:12.18-alpine AS build | |
ARG BASE_PATH | |
ARG DATABASE_TYPE | |
ENV BASE_PATH=$BASE_PATH | |
ENV DATABASE_URL "postgresql://umami:umami@db:5432/umami" \ | |
DATABASE_TYPE=$DATABASE_TYPE | |
WORKDIR /build | |
RUN yarn config set --home enableTelemetry 0 | |
# Moved this up so the RUN commands can be chained together | |
COPY . /build | |
# This should no longer be necessary given the line above | |
# COPY package.json yarn.lock /build/ | |
# This will only leave you with the prod node modules | |
RUN yarn install --production --frozen-lockfile && \ | |
cp -R node_modules/ prod_node_modules/ && \ | |
yarn install --frozen-lockfile && \ | |
yarn next telemetry disable && \ | |
yarn build && \ | |
cp -r node_modules/.prisma prod_node_modules/ && \ | |
rm -rf node_modules | |
# Production image | |
FROM node:12.18-alpine AS production | |
WORKDIR /app | |
# Copy cached dependencies | |
COPY --from=build /build/prod_node_modules ./node_modules | |
COPY --from=build /build/yarn.lock /build/package.json ./ | |
COPY --from=build /build/.next ./.next | |
COPY --from=build /build/public ./public | |
USER node | |
EXPOSE 3000 | |
CMD ["yarn", "start"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment