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,21 +25,25 @@ jobs:
with:
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: |
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 rm vaadin-app || true
docker run -d --name vaadin-app -p 8080:8080 \
-e DB_ADDRESS=${DB_ADDRESS} \
-e DB_USER=${DB_USER} \
-e DB_PASSWORD=${DB_PASSWORD} \
-e DB_NAME=${DB_NAME} \
vaadin-app
# Build and start the containers (including the database container)
docker-compose up -d --build
EOF
env:
DB_ADDRESS: ${{ secrets.DB_ADDRESS }}
DB_USER: ${{ secrets.DB_USER }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
DB_NAME: ${{ secrets.DB_NAME }}
DB_NAME: ${{ secrets.DB_NAME }}

View file

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