Skip to content

Commit bc636c2

Browse files
committed
add test nginx config and update admin page for logout
1 parent 1a8da29 commit bc636c2

File tree

5 files changed

+46
-17
lines changed

5 files changed

+46
-17
lines changed

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Name of the Docker container
22
DOCKER_IMAGE=node:22-slim
3+
VIS_DOCKER_IMAGE_NAME_PREFIX=ghcr.io/local-connectivity-lab
4+
VIS_DOCKER_IMAGE_NAME=ccn-coverage-vis
35
include .env
46

57
# The current directory (mapped to the container)
@@ -14,8 +16,9 @@ clean:
1416

1517
.PHONY: build
1618
build:
17-
@echo "Create docker container"
18-
docker build -t ccn-coverage-vis .
19+
@echo "Create docker container for $(VIS_DOCKER_IMAGE_NAME)"
20+
21+
docker build -t $(VIS_DOCKER_IMAGE_NAME_PREFIX)/$(VIS_DOCKER_IMAGE_NAME) -f vis.dockerfile .
1922

2023
# The target for development
2124
.PHONY: dev

configs/nginx.conf

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,50 @@ server {
3434
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml application/javascript;
3535
gzip_disable "MSIE [1-6]\.";
3636

37-
# Caching settings for static assets
38-
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
39-
root /usr/share/nginx/html;
37+
# Root directory for the site
38+
root /usr/share/nginx/html;
39+
40+
# API and secure endpoints
41+
location ~ ^/(api|secure)/ {
42+
proxy_pass http://api:3000;
43+
proxy_http_version 1.1;
44+
proxy_set_header Upgrade $http_upgrade;
45+
proxy_set_header Connection 'upgrade';
46+
proxy_set_header Host $host;
47+
proxy_set_header X-Real-IP $remote_addr;
48+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
49+
proxy_set_header X-Forwarded-Proto $scheme;
50+
proxy_cache_bypass $http_upgrade;
51+
52+
# Timeout settings
53+
proxy_connect_timeout 60s;
54+
proxy_send_timeout 60s;
55+
proxy_read_timeout 60s;
56+
}
57+
58+
# Handle requests to /admin/assets/ - KEY FIX HERE
59+
location ^~ /admin/assets/ {
60+
# Rewrite requests from /admin/assets/ to /assets/
61+
rewrite ^/admin/assets/(.*) /assets/$1 last;
62+
}
63+
64+
# Static assets caching
65+
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
4066
expires 1y;
4167
add_header Cache-Control "public, max-age=31536000, immutable";
4268
try_files $uri =404;
4369
}
4470

71+
# Handle all routes for the SPA
4572
location / {
46-
root /usr/share/nginx/html;
73+
index index.html;
4774
try_files $uri $uri/ /index.html;
4875
}
4976

5077
# Error pages
5178
error_page 404 /index.html;
5279
error_page 500 502 503 504 /50x.html;
5380
location = /50x.html {
54-
root /usr/share/nginx/html;
81+
try_files $uri =404;
5582
}
5683
}

docker-compose.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ services:
1515
ports:
1616
- 443:443
1717
depends_on:
18-
- cert-generator
18+
cert-generator:
19+
condition: service_completed_successfully
1920

2021
volumes:
2122
certs:

src/admin/AdminPortal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ const logout = () => {
8383
console.log(`Unable to logout: ${error}`);
8484
return;
8585
}
86-
window.open('/', '_self');
86+
window.location.href = '/login';
8787
})
8888
.catch(err => {
8989
console.log(`Error occurred while logging out: ${err}`);

vis.dockerfile

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,16 @@ COPY package*.json ./
66
COPY tsconfig.json ./
77
COPY scripts/setup.sh ./scripts/
88

9-
RUN chmod +x ./scripts/setup.sh
10-
RUN ./scripts/setup.sh
11-
12-
RUN npm ci
9+
RUN chmod +x ./scripts/setup.sh && \
10+
./scripts/setup.sh && \
11+
npm ci && \
12+
npm cache clean --force
1313

1414
COPY . .
1515

16-
RUN npm run build
17-
18-
RUN npm prune --production
16+
RUN npm run build && npm prune --production
1917

20-
FROM nginx:stable
18+
FROM nginx:stable-alpine
2119

2220
COPY --from=build /usr/src/app/build /usr/share/nginx/html
2321
COPY configs/nginx.conf /etc/nginx/conf.d/default.conf

0 commit comments

Comments
 (0)