feat: changed Dockerfile, docker-compose.yml

This commit is contained in:
filippo-ferrari 2024-09-06 20:30:32 +02:00
parent 1b4abd03c0
commit 9a05cbd665
2 changed files with 18 additions and 9 deletions

View file

@ -25,18 +25,22 @@ jobs:
with: with:
ssh-private-key: ${{ secrets.SSH_KEY }} ssh-private-key: ${{ secrets.SSH_KEY }}
- name: Deploy Docker image - name: Copy files to server
run: |
scp -o StrictHostKeyChecking=no docker-compose.yml Dockerfile ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/${{ secrets.SSH_USER }}/munera/
scp -o StrictHostKeyChecking=no target/munera-1.0-SNAPSHOT.jar ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/${{ secrets.SSH_USER }}/munera/
- name: Deploy using Docker Compose
run: | run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} << 'EOF' ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} << 'EOF'
docker pull vaadin-app || true cd /home/${{ secrets.SSH_USER }}/munera
# Stop and remove only the specific application container
docker stop vaadin-app || true docker stop vaadin-app || true
docker rm vaadin-app || true docker rm vaadin-app || true
docker run -d --name vaadin-app -p 8080:8080 \
-e DB_ADDRESS=${DB_ADDRESS} \ # Build and start the containers (including the database container)
-e DB_USER=${DB_USER} \ docker-compose up -d --build
-e DB_PASSWORD=${DB_PASSWORD} \
-e DB_NAME=${DB_NAME} \
vaadin-app
EOF EOF
env: env:
DB_ADDRESS: ${{ secrets.DB_ADDRESS }} DB_ADDRESS: ${{ secrets.DB_ADDRESS }}

View file

@ -21,3 +21,8 @@ services:
POSTGRES_PASSWORD: ${DB_PASSWORD} POSTGRES_PASSWORD: ${DB_PASSWORD}
ports: ports:
- "5432:5432" - "5432:5432"
volumes:
- db_data:/var/lib/postgresql/data
volumes:
db_data: