-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
30 lines (26 loc) · 850 Bytes
/
Dockerfile
File metadata and controls
30 lines (26 loc) · 850 Bytes
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
# Multi-stage build pipeline
# STAGE 1: Building assets using Node image
# Using nodejs image as starting point
FROM node:14 AS builder
# Setting working directory
WORKDIR /app
# Copying package.json and yarn.lock and installing node modules
# This helps caching the modules
COPY package.json .
COPY yarn.lock .
RUN yarn install
# Copying rest of the file in image's working directory
COPY . .
# Building the assets
RUN yarn build
# STAGE 2: Using nginx to serve the built assets
# Using nginx as a starting point
FROM nginx:alpine
# Setting up working directory to nginx asset directory
WORKDIR /usr/share/nginx/html
# Remove default nginx static assets
RUN rm -rf ./*
# Copy static assets from builder stage
COPY --from=builder /app/build .
# Containers run nginx with global directives and daemon off
ENTRYPOINT ["nginx", "-g", "daemon off;"]