diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6709137..e4bf523 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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 }} diff --git a/docker-compose.yaml b/docker-compose.yaml index c83fe68..f1bc316 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -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 @@ -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: diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties index 820f224..bd75f8c 100644 --- a/src/main/resources/application-local.properties +++ b/src/main/resources/application-local.properties @@ -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} \ No newline at end of file diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties index 15b1221..1e3f02d 100644 --- a/src/main/resources/application-prod.properties +++ b/src/main/resources/application-prod.properties @@ -1 +1 @@ -spring.datasource.url=jdbc:postgresql://${DB_HOSTNAME}/${DB_NAME}?user=${POSTGRES_USER}&password=${POSTGRES_PASSWORD}&sslmode=require \ No newline at end of file +spring.datasource.url=jdbc:postgresql://${DB_HOSTNAME}:${DB_PORT}/${DB_NAME}?user=${POSTGRES_USER}&password=${POSTGRES_PASSWORD}&sslmode=require \ No newline at end of file