-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrontend.Dockerfile
54 lines (41 loc) · 1.47 KB
/
frontend.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
51
52
53
54
FROM node:20.11-alpine as build
COPY package.json package-lock.json tsconfig.json vite.config.ts index.html ./
COPY src ./src
COPY .env.local .
ENV VITE_SERVER_URL=""
RUN npm install
RUN npm run build
FROM nginx:bookworm
EXPOSE 80
COPY --from=build dist /usr/share/nginx/html
# we place this in templates to replace the default.conf file
# we need to adapt the proxy_pass directive to point to the backend service
COPY <<"EOF" /etc/nginx/templates/default.conf.template
server {
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ @proxy;
}
location @proxy {
# app is the name of the backend service in the docker-compose file
proxy_pass ${NGINX_BACKEND_SERVICE};
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
# Proxy SSL
proxy_ssl_server_name on;
# Proxy headers
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Proxy timeouts
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
listen [::]:80;
listen 80;
}
EOF