-
Notifications
You must be signed in to change notification settings - Fork 45
/
Dockerfile
37 lines (26 loc) · 1.03 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
ARG NODE_VERSION=20-alpine
FROM node:${NODE_VERSION} AS dependencies
WORKDIR /usr/app
# First copy only package.json & yarn.lock and run yarn install, this will make
# docker cache these steps if those files didn't change
COPY package.json yarn.lock ./
ARG NPM_TOKEN
RUN echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc && yarn install --frozen-lock-file && rm -f .npmrc
# Copy all the other source files we need to build
COPY . .
RUN yarn build
# Main
FROM node:${NODE_VERSION}
RUN apk --no-cache add curl bash
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Only copy the files actually needed to run the app, this will make our docker
# image significant smaller and we don't leak uncompiled source code to production
COPY --from=dependencies /usr/app/package.json ./
COPY --from=dependencies /usr/app/next.config.js ./
COPY --from=dependencies /usr/app/node_modules ./node_modules
COPY --from=dependencies /usr/app/.next ./.next
COPY --from=dependencies /usr/app/public ./public
ENV PORT 3000
EXPOSE 3000
CMD ["yarn", "start"]