2022-04-04 12:20:34 +02:00
|
|
|
# Build-time variables
|
|
|
|
ARG NODE_VERSION=16
|
|
|
|
ARG ALPINE_VERSION=3.15
|
|
|
|
|
|
|
|
|
2020-09-22 14:30:37 +02:00
|
|
|
# Build image
|
2022-04-04 12:20:34 +02:00
|
|
|
FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS build
|
2021-05-08 13:48:51 +02:00
|
|
|
ARG BASE_PATH
|
2020-08-22 14:39:01 +02:00
|
|
|
ARG DATABASE_TYPE
|
2022-02-19 05:00:21 +01:00
|
|
|
|
2021-05-08 13:48:51 +02:00
|
|
|
ENV BASE_PATH=$BASE_PATH
|
2022-02-19 05:00:21 +01:00
|
|
|
ENV DATABASE_URL "postgresql://umami:umami@db:5432/umami"
|
|
|
|
ENV DATABASE_TYPE=$DATABASE_TYPE
|
2022-02-21 08:27:50 +01:00
|
|
|
|
2020-09-22 14:30:37 +02:00
|
|
|
WORKDIR /build
|
2020-08-22 12:00:35 +02:00
|
|
|
|
2020-09-24 11:23:59 +02:00
|
|
|
RUN yarn config set --home enableTelemetry 0
|
2020-09-22 14:30:37 +02:00
|
|
|
COPY package.json yarn.lock /build/
|
2020-08-19 06:23:04 +02:00
|
|
|
|
2020-09-22 14:30:37 +02:00
|
|
|
# Install only the production dependencies
|
2020-09-24 05:12:38 +02:00
|
|
|
RUN yarn install --production --frozen-lockfile
|
2020-08-19 06:23:04 +02:00
|
|
|
|
2020-09-22 14:30:37 +02:00
|
|
|
# Cache these modules for production
|
|
|
|
RUN cp -R node_modules/ prod_node_modules/
|
|
|
|
|
|
|
|
# Install development dependencies
|
2020-09-23 13:06:50 +02:00
|
|
|
RUN yarn install --frozen-lockfile
|
2020-09-22 14:30:37 +02:00
|
|
|
|
|
|
|
COPY . /build
|
2020-09-24 11:23:59 +02:00
|
|
|
RUN yarn next telemetry disable
|
2020-09-20 01:06:40 +02:00
|
|
|
RUN yarn build
|
2020-08-19 06:23:04 +02:00
|
|
|
|
2022-04-04 12:20:34 +02:00
|
|
|
|
2020-09-22 14:30:37 +02:00
|
|
|
# Production image
|
2022-04-04 12:20:34 +02:00
|
|
|
FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS production
|
2020-09-22 14:30:37 +02:00
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
# Copy cached dependencies
|
|
|
|
COPY --from=build /build/prod_node_modules ./node_modules
|
|
|
|
|
|
|
|
# Copy generated Prisma client
|
2020-09-23 13:06:50 +02:00
|
|
|
COPY --from=build /build/node_modules/.prisma/ ./node_modules/.prisma/
|
2020-09-22 14:30:37 +02:00
|
|
|
|
|
|
|
COPY --from=build /build/yarn.lock /build/package.json ./
|
|
|
|
COPY --from=build /build/.next ./.next
|
|
|
|
COPY --from=build /build/public ./public
|
2022-04-04 23:36:42 +02:00
|
|
|
COPY --from=build /build/scripts ./scripts
|
2020-09-22 14:30:37 +02:00
|
|
|
|
|
|
|
USER node
|
|
|
|
|
|
|
|
EXPOSE 3000
|
2020-09-20 01:06:40 +02:00
|
|
|
CMD ["yarn", "start"]
|