Xiao commited on
Commit
283f898
·
1 Parent(s): a94a366
Files changed (3) hide show
  1. .nginx/nginx.conf +20 -3
  2. Dockerfile +20 -6
  3. docker-compose.yaml +2 -0
.nginx/nginx.conf CHANGED
@@ -1,15 +1,32 @@
1
  server {
2
 
3
- listen 3000;
4
 
5
  location / {
6
- root /usr/share/nginx/html;
7
- index index.html index.htm;
 
 
8
  try_files $uri /index.html =404;
9
  }
10
 
11
  error_page 500 502 503 504 /50x.html;
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  location = /50x.html {
14
  root /usr/share/nginx/html;
15
  }
 
1
  server {
2
 
3
+ listen 5000;
4
 
5
  location / {
6
+ # root /usr/share/nginx/html;
7
+ proxy_pass http://localhost:3000;
8
+ # root /app/public;
9
+ # index index.html index.htm;
10
  try_files $uri /index.html =404;
11
  }
12
 
13
  error_page 500 502 503 504 /50x.html;
14
 
15
+ location /static/ {
16
+ # Serve backend from port
17
+ rewrite /static/(.*) /$1 break;
18
+ proxy_pass http://localhost:3000;
19
+ proxy_http_version 1.1;
20
+ proxy_set_header Upgrade $http_upgrade;
21
+ proxy_set_header Connection 'upgrade';
22
+ proxy_set_header Host $host;
23
+ proxy_set_header X-Real-IP $remote_addr;
24
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
25
+ proxy_cache_bypass $http_upgrade;
26
+ proxy_read_timeout 86400;
27
+ proxy_redirect off;
28
+ }
29
+
30
  location = /50x.html {
31
  root /usr/share/nginx/html;
32
  }
Dockerfile CHANGED
@@ -14,6 +14,8 @@ RUN mkdir -p /var/cache/nginx \
14
  /var/lib/nginx
15
  RUN touch /var/run/nginx.pid
16
 
 
 
17
  # Set up a new user named "luminlab" with user ID 1000
18
  RUN useradd -m -u 1000 luminlab &&\
19
  groupadd luminlab &&\
@@ -33,6 +35,10 @@ RUN chown -R luminlab:luminlab /var/cache/nginx \
33
  /var/run/nginx.pid
34
 
35
  # syntax=docker/dockerfile:1.4
 
 
 
 
36
 
37
  # 1. For build React app
38
  FROM node:lts AS build
@@ -47,7 +53,7 @@ COPY --chown=luminlab:luminlab package-lock.json /app/package-lock.json
47
  # Same as npm install
48
  RUN npm ci
49
 
50
- COPY --chown=luminlab:luminlab . /app
51
 
52
  ENV CI=true
53
  ENV PORT=3000
@@ -79,15 +85,23 @@ ENV PORT=3000
79
  FROM nginx:alpine AS prod
80
 
81
  # Copy config nginx
82
- COPY --from=build /app/.nginx/nginx.conf /etc/nginx/conf.d/default.conf
83
-
84
- WORKDIR /usr/share/nginx/html
85
 
86
  # Remove default nginx static assets
87
- RUN rm -rf ./*
 
 
 
 
 
 
 
88
 
89
  # Copy static assets from builder stage
90
- COPY --from=build /app .
 
 
 
91
  USER luminlab:luminlab
92
 
93
  # Switch to the "user" user
 
14
  /var/lib/nginx
15
  RUN touch /var/run/nginx.pid
16
 
17
+
18
+
19
  # Set up a new user named "luminlab" with user ID 1000
20
  RUN useradd -m -u 1000 luminlab &&\
21
  groupadd luminlab &&\
 
35
  /var/run/nginx.pid
36
 
37
  # syntax=docker/dockerfile:1.4
38
+ ENV HOME=/home/luminlab \
39
+ PATH=/home/luminlab/.local/bin:$PATH
40
+
41
+ RUN mkdir $HOME/app
42
 
43
  # 1. For build React app
44
  FROM node:lts AS build
 
53
  # Same as npm install
54
  RUN npm ci
55
 
56
+ COPY --chown=luminlab:luminlab . .
57
 
58
  ENV CI=true
59
  ENV PORT=3000
 
85
  FROM nginx:alpine AS prod
86
 
87
  # Copy config nginx
88
+ COPY --chown=luminlab:luminlab --from=build /app/.nginx/nginx.conf /etc/nginx/conf.d/default.conf
 
 
89
 
90
  # Remove default nginx static assets
91
+ # RUN rm -rf ./*
92
+
93
+ # WORKDIR /usr/share/nginx/html
94
+
95
+
96
+ WORKDIR $HOME
97
+
98
+
99
 
100
  # Copy static assets from builder stage
101
+ COPY --chown=luminlab:luminlab --from=build /app ./app
102
+
103
+
104
+
105
  USER luminlab:luminlab
106
 
107
  # Switch to the "user" user
docker-compose.yaml CHANGED
@@ -5,7 +5,9 @@ services:
5
  container_name: luminlab-nginx-frontend
6
  user: root
7
  ports:
 
8
  - "3000:3000"
9
  volumes:
10
  - ./run_hf.sh:/app/run_hf.sh
11
 
 
 
5
  container_name: luminlab-nginx-frontend
6
  user: root
7
  ports:
8
+ - "80:3000"
9
  - "3000:3000"
10
  volumes:
11
  - ./run_hf.sh:/app/run_hf.sh
12
 
13
+