File tree Expand file tree Collapse file tree 6 files changed +29
-13
lines changed Expand file tree Collapse file tree 6 files changed +29
-13
lines changed Original file line number Diff line number Diff line change @@ -10,12 +10,15 @@ COLLAB_EXPRESS_DB_PORT=5434
10
10
MATCHING_PGDATA = " /data/collab-db"
11
11
MATCHING_EXPRESS_DB_PORT = 5434
12
12
13
+ USER_SERVICE_NAME = user-express
13
14
USER_EXPRESS_ENV = compose
14
15
USER_EXPRESS_PORT = 9001
15
16
17
+ QUESTION_SERVICE_NAME = question-service
16
18
QUESTION_EXPRESS_ENV = compose
17
19
QUESTION_EXPRESS_PORT = 9002
18
20
21
+ COLLAB_SERVICE_NAME = collab-service
19
22
COLLAB_EXPRESS_ENV = compose
20
23
COLLAB_EXPRESS_PORT = 9003
21
24
Original file line number Diff line number Diff line change @@ -78,19 +78,22 @@ services:
78
78
# Frontend
79
79
80
80
frontend :
81
- image : ' frontend'
82
81
container_name : ' frontend'
83
82
build :
84
83
context : ./frontend
85
84
dockerfile : ./frontend.Dockerfile
86
85
args :
87
- - VITE_USER_SERVICE
88
- - VITE_QUESTION_SERVICE
86
+ - VITE_USER_SERVICE=http://${USER_SERVICE_NAME}:${USER_EXPRESS_PORT}
87
+ - VITE_QUESTION_SERVICE=http://${QUESTION_SERVICE_NAME}:${QUESTION_EXPRESS_PORT}
89
88
- port=${FRONTEND_PORT}
90
89
ports :
91
90
- ' 3000:${FRONTEND_PORT}'
92
91
env_file :
93
92
- ./frontend/.env.compose
93
+ environment :
94
+ - VITE_USER_SERVICE=http://${USER_SERVICE_NAME}:${USER_EXPRESS_PORT}
95
+ - VITE_QUESTION_SERVICE=http://localhost:${QUESTION_EXPRESS_PORT}
96
+ - port=${FRONTEND_PORT}
94
97
# depends_on:
95
98
# - user-service
96
99
networks :
Original file line number Diff line number Diff line change 1
1
FRONTEND_ENV=compose
2
2
3
- VITE_USER_SERVICE=http://user-service:9001
4
- VITE_QUESTION_SERVICE=http://question-service:9002
3
+ # VITE_USER_SERVICE=http://user-service:9001
4
+ # VITE_QUESTION_SERVICE=http://question-service:9002
5
5
6
- FRONTEND_PORT=3000
6
+ # FRONTEND_PORT=3000
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ envsubst ' ${port} ${VITE_USER_SERVICE} ${VITE_QUESTION_SERVICE}' < /etc/nginx/nginx.conf.template > /etc/nginx/conf.d/default.conf
4
+
5
+ nginx -g ' daemon off;'
Original file line number Diff line number Diff line change @@ -14,8 +14,14 @@ ENV VITE_QUESTION_SERVICE=${VITE_QUESTION_SERVICE}
14
14
RUN npm run build
15
15
16
16
FROM nginx:stable-alpine
17
+
17
18
COPY --from=build /app/build /usr/share/nginx/html
18
- COPY ./nginx.conf /etc/nginx/conf.d/default.conf
19
19
20
- EXPOSE 3000
21
- CMD ["nginx" , "-g" , "daemon off;" ]
20
+ COPY ./nginx.conf.template /etc/nginx/nginx.conf.template
21
+ COPY entrypoint.sh /usr/local/bin/
22
+ RUN chmod +x /usr/local/bin/entrypoint.sh
23
+
24
+ ARG port
25
+ EXPOSE ${port}
26
+
27
+ ENTRYPOINT ["/usr/local/bin/entrypoint.sh" ]
Original file line number Diff line number Diff line change 1
1
server {
2
- listen 3000 ;
2
+ listen ${port} ;
3
3
location / {
4
4
root /usr/share/nginx/html;
5
5
index index.html;
6
6
try_files $uri $uri/ /index.html;
7
7
}
8
8
9
9
location /user-service/ {
10
- proxy_pass http ://host.docker. internal : 9001 / ;
10
+ proxy_pass ${VITE_USER_SERVICE} ;
11
11
proxy_set_header Host $host;
12
12
proxy_set_header X-Real-IP $remote_addr;
13
13
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
14
14
proxy_set_header X-Forwarded-Proto $scheme;
15
15
}
16
16
17
17
location /question-service/ {
18
- proxy_pass http ://host.docker. internal : 9002 / ;
18
+ proxy_pass ${VITE_QUESTION_SERVICE} ;
19
19
proxy_set_header Host $host;
20
20
proxy_set_header X-Real-IP $remote_addr;
21
21
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
22
22
proxy_set_header X-Forwarded-Proto $scheme;
23
23
}
24
24
25
- # Optionally log details of proxied requests
26
25
access_log /var/log/nginx/access.log;
27
26
error_log /var/log/nginx/error.log;
28
27
}
You can’t perform that action at this time.
0 commit comments