Skip to content

Commit

Permalink
Merge pull request #23 from m-strzelec/compose
Browse files Browse the repository at this point in the history
Remove hardcoded values from `docker-compose.yaml`
  • Loading branch information
m-strzelec authored Jun 23, 2024
2 parents 4d327d6 + e7c0dcf commit f7a3dcc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ jobs:
- name: Deploy to Azure Container Apps
run: |
az containerapp create --name tabiapp --resource-group zzpjtabi --environment tabienv --image ${{ secrets.ACR_NAME }}.azurecr.io/tabi-backend:latest --ingress 'external' --target-port 8080 --env-vars POSTGRES_DB=${{ secrets.POSTGRES_SERVER }} POSTGRES_USER=${{ secrets.POSTGRES_USER }} POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }} DB_HOSTNAME=${{ secrets.DB_HOSTNAME }} DB_NAME=${{ secrets.POSTGRES_DATABASE }} APP_PROFILE=prod STRIPE_PUBLIC_KEY=${{ secrets.STRIPE_PUBLIC_KEY }} STRIPE_PRIVATE_KEY=${{ secrets.STRIPE_PRIVATE_KEY }} || az containerapp update --name tabiapp --resource-group zzpjtabi --set-env-vars POSTGRES_DB=${{ secrets.POSTGRES_SERVER }} POSTGRES_USER=${{ secrets.POSTGRES_USER }} POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }} DB_HOSTNAME=${{ secrets.DB_HOSTNAME }} DB_NAME=${{ secrets.POSTGRES_DATABASE }} APP_PROFILE=prod STRIPE_PUBLIC_KEY=${{ secrets.STRIPE_PUBLIC_KEY }} STRIPE_PRIVATE_KEY=${{ secrets.STRIPE_PRIVATE_KEY }}
az containerapp create --name tabiapp --resource-group zzpjtabi --environment tabienv --image ${{ secrets.ACR_NAME }}.azurecr.io/tabi-backend:latest --ingress 'external' --target-port 8080 --env-vars POSTGRES_DB=${{ secrets.POSTGRES_SERVER }} POSTGRES_USER=${{ secrets.POSTGRES_USER }} POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }} DB_HOSTNAME=${{ secrets.DB_HOSTNAME }} DB_PORT=${{ secrets.DB_PORT }} DB_NAME=${{ secrets.POSTGRES_DATABASE }} APP_PROFILE=prod STRIPE_PUBLIC_KEY=${{ secrets.STRIPE_PUBLIC_KEY }} STRIPE_PRIVATE_KEY=${{ secrets.STRIPE_PRIVATE_KEY }} || az containerapp update --name tabiapp --resource-group zzpjtabi --set-env-vars POSTGRES_DB=${{ secrets.POSTGRES_SERVER }} POSTGRES_USER=${{ secrets.POSTGRES_USER }} POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }} DB_HOSTNAME=${{ secrets.DB_HOSTNAME }} DB_PORT=${{ secrets.DB_PORT }} DB_NAME=${{ secrets.POSTGRES_DATABASE }} APP_PROFILE=prod STRIPE_PUBLIC_KEY=${{ secrets.STRIPE_PUBLIC_KEY }} STRIPE_PRIVATE_KEY=${{ secrets.STRIPE_PRIVATE_KEY }}
10 changes: 5 additions & 5 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
services:
database:
image: 'postgres:latest'
container_name: tabi-db
container_name: ${POSTGRES_DB}
ports:
- 5432:5432
- ${DB_PORT}:${DB_PORT}
expose:
- 5432
- ${DB_PORT}
networks:
- 'spring-postgres'
env_file:
- .env
healthcheck:
test: pg_isready -U tabi -d tabi-db
test: pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}
interval: 5s
timeout: 5s
retries: 3
Expand All @@ -30,7 +30,7 @@ services:
database:
condition: service_healthy
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://database:5432/tabi-db
- SPRING_DATASOURCE_URL=jdbc:postgresql://database:${DB_PORT}/${POSTGRES_DB}

networks:
spring-postgres:
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application-local.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
spring.datasource.url=jdbc:postgresql://${DB_HOSTNAME}/${DB_NAME}
spring.datasource.url=jdbc:postgresql://${DB_HOSTNAME}:${DB_PORT}/${DB_NAME}
spring.datasource.username=${POSTGRES_USER}
spring.datasource.password=${POSTGRES_PASSWORD}
2 changes: 1 addition & 1 deletion src/main/resources/application-prod.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
spring.datasource.url=jdbc:postgresql://${DB_HOSTNAME}/${DB_NAME}?user=${POSTGRES_USER}&password=${POSTGRES_PASSWORD}&sslmode=require
spring.datasource.url=jdbc:postgresql://${DB_HOSTNAME}:${DB_PORT}/${DB_NAME}?user=${POSTGRES_USER}&password=${POSTGRES_PASSWORD}&sslmode=require

0 comments on commit f7a3dcc

Please sign in to comment.