-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
51 lines (32 loc) · 938 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# FROM node:18-alpine as builder
# WORKDIR /code
# ADD package.json package-lock.json /code/
# RUN npm install
# ADD . /code
# RUN npm run build
# FROM nginx:alpine
# ADD nginx.conf /etc/nginx/conf.d/default.conf
# COPY --from=builder code/dist /usr/share/nginx/html
# https://github.com/docker/awesome-compose/blob/master/react-nginx/Dockerfile
# syntax=docker/dockerfile:1.4
# 1. For build React app
FROM node:lts AS development
# Set working directory
WORKDIR /app
#
COPY package.json /app/package.json
COPY package-lock.json /app/package-lock.json
# Same as npm install
RUN npm ci
COPY . /app
FROM development AS build
RUN npm run build
# 2. For Nginx setup
FROM nginx:alpine
# Copy config nginx
COPY --from=build /app/nginx.conf /etc/nginx/conf.d/default.conf
WORKDIR /usr/share/nginx/html
# Remove default nginx static assets
RUN rm -rf ./*
# Copy static assets from builder stage
COPY --from=build /app/dist .