File tree Expand file tree Collapse file tree 6 files changed +13
-17
lines changed Expand file tree Collapse file tree 6 files changed +13
-17
lines changed Original file line number Diff line number Diff line change @@ -105,18 +105,18 @@ services:
105
105
build :
106
106
context : ./frontend
107
107
dockerfile : ./frontend.Dockerfile
108
+ target : production
108
109
args :
109
- - VITE_USER_SERVICE=http://${USER_SERVICE_NAME}:${USER_EXPRESS_PORT}
110
- - VITE_QUESTION_SERVICE=http://${QUESTION_SERVICE_NAME}:${QUESTION_EXPRESS_PORT}
111
- - port=${FRONTEND_PORT}
110
+ - FRONTEND_PORT=${FRONTEND_PORT}
112
111
ports :
113
112
- ' 3000:${FRONTEND_PORT}'
114
113
env_file :
115
114
- ./frontend/.env.compose
116
115
environment :
117
116
- VITE_USER_SERVICE=http://${USER_SERVICE_NAME}:${USER_EXPRESS_PORT}
117
+ # #to remove localhost once integrating question
118
118
- VITE_QUESTION_SERVICE=http://localhost:${QUESTION_EXPRESS_PORT}
119
- - port =${FRONTEND_PORT}
119
+ - FRONTEND_PORT =${FRONTEND_PORT}
120
120
depends_on :
121
121
user-service :
122
122
condition : service_healthy
Original file line number Diff line number Diff line change 1
1
FRONTEND_ENV=local
2
2
3
3
VITE_USER_SERVICE=http://host.docker.internal:9001
4
- VITE_QUESTION_SERVICE=http://host.docker.internal:9002
4
+ VITE_QUESTION_SERVICE=http://host.docker.internal:9002
5
+ FRONTEND_PORT=3000
Original file line number Diff line number Diff line change 7
7
docker build \
8
8
--build-arg VITE_USER_SERVICE=http://host.docker.internal:9001 \
9
9
--build-arg VITE_QUESTION_SERVICE=http://host.docker.internal:9002 \
10
+ --build-arg FRONTEND_PORT=3000 \
10
11
-t frontend-app -f frontend.Dockerfile .
11
12
```
12
13
2 . Run this command, from the root folder:
19
20
20
21
4 . Run this command to expose the container:
21
22
``` sh
22
- docker run -p 3000:3000 --env-file ./.env.docker frontend-local
23
+ docker run -p 3000:3000 --env-file ./.env.docker frontend-app
23
24
```
24
25
25
26
## Running with Docker-Compose (Main config)
Original file line number Diff line number Diff line change 1
1
#! /bin/sh
2
2
3
- envsubst ' ${port } ${VITE_USER_SERVICE} ${VITE_QUESTION_SERVICE}' < /etc/nginx/nginx.conf.template > /etc/nginx/conf.d/default.conf
3
+ envsubst ' ${FRONTEND_PORT } ${VITE_USER_SERVICE} ${VITE_QUESTION_SERVICE}' < /etc/nginx/nginx.conf.template > /etc/nginx/conf.d/default.conf
4
4
5
5
nginx -g ' daemon off;'
Original file line number Diff line number Diff line change @@ -5,23 +5,17 @@ COPY ./package*.json ./
5
5
RUN npm install
6
6
COPY ./ ./
7
7
8
- # ADD Service ENV
9
- ARG VITE_USER_SERVICE
10
- ARG VITE_QUESTION_SERVICE
11
- ENV VITE_USER_SERVICE=${VITE_USER_SERVICE}
12
- ENV VITE_QUESTION_SERVICE=${VITE_QUESTION_SERVICE}
13
-
14
8
RUN npm run build
15
9
16
- FROM nginx:stable-alpine
10
+ FROM nginx:stable-alpine AS production
17
11
18
12
COPY --from=build /app/build /usr/share/nginx/html
19
13
20
14
COPY ./nginx.conf.template /etc/nginx/nginx.conf.template
21
15
COPY entrypoint.sh /usr/local/bin/
22
16
RUN chmod +x /usr/local/bin/entrypoint.sh
23
17
24
- ARG port
25
- EXPOSE ${port }
18
+ ARG FRONTEND_PORT
19
+ EXPOSE ${FRONTEND_PORT }
26
20
27
21
ENTRYPOINT ["/usr/local/bin/entrypoint.sh" ]
Original file line number Diff line number Diff line change 1
1
server {
2
- listen ${port };
2
+ listen ${FRONTEND_PORT };
3
3
location / {
4
4
root /usr/share/nginx/html;
5
5
index index.html;
You can’t perform that action at this time.
0 commit comments