Skip to content

Commit db71923

Browse files
committed
PEER-254: Update env vars
1 parent 1f3e60a commit db71923

File tree

6 files changed

+13
-17
lines changed

6 files changed

+13
-17
lines changed

docker-compose.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,18 @@ services:
105105
build:
106106
context: ./frontend
107107
dockerfile: ./frontend.Dockerfile
108+
target: production
108109
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}
112111
ports:
113112
- '3000:${FRONTEND_PORT}'
114113
env_file:
115114
- ./frontend/.env.compose
116115
environment:
117116
- VITE_USER_SERVICE=http://${USER_SERVICE_NAME}:${USER_EXPRESS_PORT}
117+
##to remove localhost once integrating question
118118
- VITE_QUESTION_SERVICE=http://localhost:${QUESTION_EXPRESS_PORT}
119-
- port=${FRONTEND_PORT}
119+
- FRONTEND_PORT=${FRONTEND_PORT}
120120
depends_on:
121121
user-service:
122122
condition: service_healthy

frontend/.env.docker

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
FRONTEND_ENV=local
22

33
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

frontend/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
docker build \
88
--build-arg VITE_USER_SERVICE=http://host.docker.internal:9001 \
99
--build-arg VITE_QUESTION_SERVICE=http://host.docker.internal:9002 \
10+
--build-arg FRONTEND_PORT=3000 \
1011
-t frontend-app -f frontend.Dockerfile .
1112
```
1213
2. Run this command, from the root folder:
@@ -19,7 +20,7 @@
1920

2021
4. Run this command to expose the container:
2122
```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
2324
```
2425

2526
## Running with Docker-Compose (Main config)

frontend/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/sh
22

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
44

55
nginx -g 'daemon off;'

frontend/frontend.Dockerfile

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,17 @@ COPY ./package*.json ./
55
RUN npm install
66
COPY ./ ./
77

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-
148
RUN npm run build
159

16-
FROM nginx:stable-alpine
10+
FROM nginx:stable-alpine AS production
1711

1812
COPY --from=build /app/build /usr/share/nginx/html
1913

2014
COPY ./nginx.conf.template /etc/nginx/nginx.conf.template
2115
COPY entrypoint.sh /usr/local/bin/
2216
RUN chmod +x /usr/local/bin/entrypoint.sh
2317

24-
ARG port
25-
EXPOSE ${port}
18+
ARG FRONTEND_PORT
19+
EXPOSE ${FRONTEND_PORT}
2620

2721
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

frontend/nginx.conf.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
server {
2-
listen ${port};
2+
listen ${FRONTEND_PORT};
33
location / {
44
root /usr/share/nginx/html;
55
index index.html;

0 commit comments

Comments
 (0)