Skip to content

Commit 36fd947

Browse files
committed
fix: updated docker files for VM based deployments
1 parent 45a4695 commit 36fd947

File tree

3 files changed

+74
-15
lines changed

3 files changed

+74
-15
lines changed

Dockerfile.prod

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
# build environment
2-
FROM node:22-alpine3.18 as build
2+
FROM node:22-alpine3.18 AS build
33

4-
# ARG RELEASE_VERSION
4+
# Define ARG before using it
5+
ARG RELEASE_VERSION=latest
56
ENV RELEASE_VERSION=${RELEASE_VERSION}
67

78
WORKDIR /app
8-
ENV PATH /app/node_modules/.bin:$PATH
9+
ENV PATH=/app/node_modules/.bin:$PATH
910
COPY package.json ./
1011
RUN export NODE_OPTIONS=--max-old-space-size=8192
1112
RUN npm i --silent
1213
RUN npm i react-scripts@latest -g --silent
1314
COPY . ./
1415
RUN echo "export default { version: '$RELEASE_VERSION' };" > src/versionInfo.ts
1516
RUN npm run build -- --outDir=build
16-
RUN npm run build -- --outDir=build/releases/${RELEASE_VERSION}
17+
COPY ./releases ./build/
18+
RUN mkdir -p ./build/${RELEASE_VERSION}
19+
RUN npm run build -- --outDir=build/${RELEASE_VERSION}
1720

1821
# production environment
1922
FROM nginx:stable-alpine

nginx/nginx.conf

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,40 @@
11
server {
2-
32
listen 80;
43

5-
location / {
6-
root /usr/share/nginx/html;
7-
index index.html index.htm;
8-
try_files $uri $uri/ /index.html;
4+
# Root directory for all files
5+
root /usr/share/nginx/html;
6+
index index.html;
7+
8+
# Enable directory listing for debugging
9+
autoindex on;
10+
11+
# Default route for root
12+
location = / {
13+
try_files /index.html =404;
14+
}
15+
16+
# Handle version-specific routes
17+
location ~ ^/v[0-9]+\.[0-9]+\.[0-9]+(/.*)?$ {
18+
# Remove trailing slash for consistency
19+
if ($request_uri ~ ^(.+?)/+$) {
20+
return 301 $1;
21+
}
22+
try_files $uri $uri/index.html $uri/ =404;
923
}
1024

11-
error_page 500 502 503 504 /50x.html;
25+
# Handle all other routes
26+
location / {
27+
try_files $uri $uri/ /index.html =404;
28+
}
1229

30+
error_page 404 /404.html;
31+
error_page 500 502 503 504 /50x.html;
32+
33+
location = /404.html {
34+
internal;
35+
}
36+
1337
location = /50x.html {
14-
root /usr/share/nginx/html;
38+
internal;
1539
}
16-
1740
}

nginx/proxy.conf

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,42 @@
11
server {
22
listen 80;
3-
3+
4+
# Default route for root
5+
location = / {
6+
proxy_pass http://nmrium-prod:80/;
7+
proxy_http_version 1.1;
8+
proxy_set_header Upgrade $http_upgrade;
9+
proxy_set_header Connection 'upgrade';
10+
proxy_set_header Host $host;
11+
proxy_set_header X-Real-IP $remote_addr;
12+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
13+
proxy_set_header X-Forwarded-Proto $scheme;
14+
proxy_cache_bypass $http_upgrade;
15+
}
16+
17+
# Handle version-specific routes
18+
location ~ ^/v[0-9]+\.[0-9]+\.[0-9]+(/.*)?$ {
19+
proxy_pass http://nmrium-prod:80;
20+
proxy_http_version 1.1;
21+
proxy_set_header Upgrade $http_upgrade;
22+
proxy_set_header Connection 'upgrade';
23+
proxy_set_header Host $host;
24+
proxy_set_header X-Real-IP $remote_addr;
25+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
26+
proxy_set_header X-Forwarded-Proto $scheme;
27+
proxy_cache_bypass $http_upgrade;
28+
}
29+
30+
# Handle all other routes
431
location / {
5-
proxy_pass http://nmrium-dev:80;
32+
proxy_pass http://nmrium-prod:80;
633
proxy_http_version 1.1;
734
proxy_set_header Upgrade $http_upgrade;
835
proxy_set_header Connection 'upgrade';
936
proxy_set_header Host $host;
37+
proxy_set_header X-Real-IP $remote_addr;
38+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
39+
proxy_set_header X-Forwarded-Proto $scheme;
1040
proxy_cache_bypass $http_upgrade;
1141
}
1242
}
@@ -15,11 +45,14 @@ server {
1545
listen 81;
1646

1747
location / {
18-
proxy_pass http://nmrium-prod:80;
48+
proxy_pass http://nmrium-dev:80;
1949
proxy_http_version 1.1;
2050
proxy_set_header Upgrade $http_upgrade;
2151
proxy_set_header Connection 'upgrade';
2252
proxy_set_header Host $host;
53+
proxy_set_header X-Real-IP $remote_addr;
54+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
55+
proxy_set_header X-Forwarded-Proto $scheme;
2356
proxy_cache_bypass $http_upgrade;
2457
}
2558
}

0 commit comments

Comments
 (0)