Skip to content

Commit

Permalink
fixing env
Browse files Browse the repository at this point in the history
  • Loading branch information
pdelebarre committed Oct 28, 2024
1 parent 580bafc commit d2deeca
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 15 deletions.
7 changes: 4 additions & 3 deletions docker-compose.nas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ services:
build:
context: ./frontend
image: pdelebarre/guitar-tutorial-app-frontend
# :${BUILD_ENV:-dev}
environment:
- GUITARTUTORIALAPP_API_BASE_URL=http://backend
- GUITARTUTORIALAPP_API_PORT=8080
ports:
- "3000:80"
environment:
# Set VITE_API_URL to the internal backend service name inside Docker
- VITE_API_URL=http://backend:8080
depends_on:
- backend
networks:
Expand Down
37 changes: 37 additions & 0 deletions docker-compose.prod.yml.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
version: '3.8'

services:
backend:
depends_on:
- postgres # Only in prod mode

postgres:
image: postgres:15-alpine
container_name: postgres
environment:
POSTGRES_USER: myuser # Creates the "myuser" role
POSTGRES_PASSWORD: mypassword # Password for "myuser"
POSTGRES_DB: guitardb # Creates the "guitardb" database
# Set the profile to prod and connect to Postgres
SPRING_PROFILES_ACTIVE: prod
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/guitardb
SPRING_DATASOURCE_USERNAME: myuser
SPRING_DATASOURCE_PASSWORD: mypassword
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- guitartuto-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U myuser -d guitardb"]
interval: 10s
retries: 5
start_period: 5s

networks:
guitartuto-network:
driver: bridge

volumes:
postgres_data:
5 changes: 1 addition & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ services:
build:
context: ./frontend
image: pdelebarre/guitar-tutorial-app-frontend
# :${BUILD_ENV:-dev}
environment:
- GUITARTUTORIALAPP_API_BASE_URL=$GUITARTUTORIALAPP_API_BASE_URL
- GUITARTUTORIALAPP_API_PORT=$GUITARTUTORIALAPP_API_PORT

ports:
- "3000:80"
depends_on:
Expand Down
3 changes: 3 additions & 0 deletions frontend/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
VITE_API_BASE_URL=http://backend
VITE_API_PORT=8080
# VITE_ENVIRONMENT=DEVELOPMENT
3 changes: 0 additions & 3 deletions frontend/.env.development

This file was deleted.

3 changes: 0 additions & 3 deletions frontend/.env.production

This file was deleted.

5 changes: 3 additions & 2 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ COPY --from=builder /app/dist /usr/share/nginx/html

#shell to be able to catch variables at docker run time
#https://dev.to/sanjayttg/dynamic-environment-variables-for-dockerized-react-apps-5bc5
COPY env.sh /docker-entrypoint.d/env.sh
RUN chmod +x /docker-entrypoint.d/env.sh
# COPY env.sh /docker-entrypoint.d/env.sh
# RUN chmod +x /docker-entrypoint.d/env.sh
COPY .env .env

# Expose the port NGINX is running on
EXPOSE 80
Expand Down

0 comments on commit d2deeca

Please sign in to comment.