Skip to content

Commit 8155761

Browse files
authored
🐳 Set up Docker config for new-frontend (#564)
1 parent 2291910 commit 8155761

File tree

7 files changed

+67
-1
lines changed

7 files changed

+67
-1
lines changed

src/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ TRAEFIK_PUBLIC_TAG=traefik-public
1313
DOCKER_IMAGE_BACKEND=backend
1414
DOCKER_IMAGE_CELERYWORKER=celery
1515
DOCKER_IMAGE_FRONTEND=frontend
16+
DOCKER_IMAGE_NEW_FRONTEND=new-frontend
1617

1718
# Backend
1819
BACKEND_CORS_ORIGINS="[\"http://localhost\", \"http://localhost:4200\", \"http://localhost:3000\", \"http://localhost:8080\", \"https://localhost\", \"https://localhost:4200\", \"https://localhost:3000\", \"https://localhost:8080\", \"http://local.dockertoolbox.tiangolo.com\", \"http://localhost.tiangolo.com\"]"

src/docker-compose.override.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,19 @@ services:
8080
labels:
8181
- traefik.enable=true
8282
- traefik.constraint-label-stack=${TRAEFIK_TAG?Variable not set}
83-
- traefik.http.routers.${STACK_NAME?Variable not set}-frontend-http.rule=PathPrefix(`/`)
83+
# - traefik.http.routers.${STACK_NAME?Variable not set}-frontend-http.rule=PathPrefix(`/`)
84+
- traefik.http.routers.${STACK_NAME?Variable not set}-frontend-http.rule=Host(`old-frontend.localhost.tiangolo.com`)
8485
- traefik.http.services.${STACK_NAME?Variable not set}-frontend.loadbalancer.server.port=80
8586

87+
new-frontend:
88+
build:
89+
context: ./new-frontend
90+
labels:
91+
- traefik.enable=true
92+
- traefik.constraint-label-stack=${TRAEFIK_TAG?Variable not set}
93+
- traefik.http.routers.${STACK_NAME?Variable not set}-new-frontend-http.rule=PathPrefix(`/`)
94+
- traefik.http.services.${STACK_NAME?Variable not set}-new-frontend.loadbalancer.server.port=80
95+
8696
networks:
8797
traefik-public:
8898
# For local dev, don't expect an external Traefik network

src/docker-compose.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,18 @@ services:
190190
- traefik.constraint-label-stack=${TRAEFIK_TAG?Variable not set}
191191
- traefik.http.routers.${STACK_NAME?Variable not set}-frontend-http.rule=PathPrefix(`/`)
192192
- traefik.http.services.${STACK_NAME?Variable not set}-frontend.loadbalancer.server.port=80
193+
194+
new-frontend:
195+
image: '${DOCKER_IMAGE_NEW_FRONTEND?Variable not set}:${TAG-latest}'
196+
build:
197+
context: ./new-frontend
198+
deploy:
199+
labels:
200+
- traefik.enable=true
201+
- traefik.constraint-label-stack=${TRAEFIK_TAG?Variable not set}
202+
- traefik.http.routers.${STACK_NAME?Variable not set}-new-frontend-http.rule=PathPrefix(`/`)
203+
- traefik.http.services.${STACK_NAME?Variable not set}-new-frontend.loadbalancer.server.port=80
204+
193205

194206
volumes:
195207
app-db-data:

src/new-frontend/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
dist

src/new-frontend/Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Stage 0, "build-stage", based on Node.js, to build and compile the frontend
2+
FROM node:20 as build-stage
3+
4+
WORKDIR /app
5+
6+
COPY package*.json /app/
7+
8+
RUN npm install
9+
10+
COPY ./ /app/
11+
12+
RUN npm run build
13+
14+
15+
# Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx
16+
FROM nginx:1
17+
18+
COPY --from=build-stage /app/dist/ /usr/share/nginx/html
19+
20+
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
21+
COPY ./nginx-backend-not-found.conf /etc/nginx/extra-conf.d/backend-not-found.conf
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
location /api {
2+
return 404;
3+
}
4+
location /docs {
5+
return 404;
6+
}
7+
location /redoc {
8+
return 404;
9+
}

src/new-frontend/nginx.conf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
server {
2+
listen 80;
3+
4+
location / {
5+
root /usr/share/nginx/html;
6+
index index.html index.htm;
7+
try_files $uri $uri/ /index.html =404;
8+
}
9+
10+
include /etc/nginx/extra-conf.d/*.conf;
11+
}

0 commit comments

Comments
 (0)