forked from umami-software/umami
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Only copy production node dependencies into image * Use multi-stage build to make use of node dependency cache * Use non-root user
- Loading branch information
Showing
1 changed file
with
30 additions
and
8 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,39 @@ | ||
FROM node:12.18-alpine | ||
|
||
# Build image | ||
FROM node:12.18-alpine AS build | ||
ARG DATABASE_TYPE | ||
|
||
ENV DATABASE_URL "postgresql://umami:umami@db:5432/umami" \ | ||
DATABASE_TYPE=$DATABASE_TYPE | ||
WORKDIR /build | ||
|
||
WORKDIR /app | ||
EXPOSE 3000 | ||
COPY package.json yarn.lock /build/ | ||
|
||
COPY package.json yarn.lock /app/ | ||
RUN yarn install --frozen-lockfile | ||
# Install only the production dependencies | ||
RUN yarn install --production | ||
|
||
COPY . /app | ||
# Cache these modules for production | ||
RUN cp -R node_modules/ prod_node_modules/ | ||
|
||
# Install development dependencies | ||
RUN yarn install | ||
|
||
COPY . /build | ||
RUN yarn build | ||
|
||
# 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 | ||
CMD ["yarn", "start"] |