forked from datacamp/rdocumentation-2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
36 lines (25 loc) · 948 Bytes
/
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
ARG NODE_VERSION=12.14-alpine3.9
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 ./
RUN yarn install
# 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"]