2020-09-22 14:30:37 +02:00
|
|
|
# Build image
|
|
|
|
FROM node:12.18-alpine AS build
|
2020-08-22 14:39:01 +02:00
|
|
|
ARG DATABASE_TYPE
|
|
|
|
ENV DATABASE_URL "postgresql://umami:umami@db:5432/umami" \
|
|
|
|
DATABASE_TYPE=$DATABASE_TYPE
|
2020-09-22 14:30:37 +02:00
|
|
|
WORKDIR /build
|
2020-08-22 12:00:35 +02:00
|
|
|
|
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
|
|
|
|
RUN yarn install --production
|
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
|
|
|
|
RUN yarn install
|
|
|
|
|
|
|
|
COPY . /build
|
2020-09-20 01:06:40 +02:00
|
|
|
RUN yarn build
|
2020-08-19 06:23:04 +02:00
|
|
|
|
2020-09-22 14:30:37 +02:00
|
|
|
# Production image
|
|
|
|
FROM node:12.18-alpine AS production
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
# Copy cached dependencies
|
|
|
|
COPY --from=build /build/prod_node_modules ./node_modules
|
|
|
|
|
|
|
|
# Copy generated Prisma client
|
|
|
|
COPY --from=build /build/node_modules/\.prisma/ ./node_modules/\.prisma/
|
|
|
|
|
|
|
|
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
|
2020-09-20 01:06:40 +02:00
|
|
|
CMD ["yarn", "start"]
|