-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDockerfile
45 lines (35 loc) · 1.22 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
38
39
40
41
42
43
44
45
# syntax=docker/dockerfile:1
ARG NODE_VERSION=18
FROM node:${NODE_VERSION}-alpine as builder
ENV NODE_ENV=production
WORKDIR /app
COPY ["package.json", "yarn.lock*", "./"]
RUN yarn install --production=false
COPY . .
ARG REACT_APP_DESCOPE_BASE_URL=""
ARG REACT_APP_CONTENT_BASE_URL=""
ARG REACT_APP_USE_ORIGIN_BASE_URL="true"
RUN yarn build
FROM nginx:alpine
RUN apk add openssl && \
openssl req -x509 -nodes -days 365 -subj "/C=CA/ST=QC/O=Company, Inc./CN=mydomain.com" -addext "subjectAltName=DNS:mydomain.com" -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt;
RUN cat > /etc/nginx/conf.d/default.conf <<EOF
server {
listen 80;
listen 443 ssl http2 default_server;
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
server_name localhost;
rewrite ^/login/(.*)$ /$1 last;
location / {
root /usr/share/nginx/html;
index index.html;
try_files \$uri \$uri/ /index.html; # this ensures react routing works
}
}
EOF
EXPOSE 80 443
WORKDIR /usr/share/nginx/html
RUN rm -rf ./*
COPY --from=builder /app/build ./
ENTRYPOINT ["nginx", "-g", "daemon off;"]