diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 010e0edb..02eada5d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -28,7 +28,7 @@ jobs: with: host: ${{ secrets.HOST }} username: ${{ secrets.USERNAME }} - key: ${{ secrets.DO_SSH_PRIVATE_KEY }} + key: ${{ secrets.PRIVATE_KEY }} script: | mkdir -p "/opt/${{ env.REPO_NAME }}" mkdir -p "/opt/${{ env.REPO_NAME }}/config" @@ -50,7 +50,7 @@ jobs: with: host: ${{ secrets.HOST }} username: ${{ secrets.USERNAME }} - key: ${{ secrets.DO_SSH_PRIVATE_KEY }} + key: ${{ secrets.PRIVATE_KEY }} source: "./docker-compose-prod.yml" target: "/opt/${{ env.REPO_NAME }}/" @@ -59,7 +59,7 @@ jobs: with: host: ${{ secrets.HOST }} username: ${{ secrets.USERNAME }} - key: ${{ secrets.DO_SSH_PRIVATE_KEY }} + key: ${{ secrets.PRIVATE_KEY }} source: "./nginx/nginx.conf" target: "/opt/${{ env.REPO_NAME }}/" @@ -68,7 +68,7 @@ jobs: with: host: ${{ secrets.HOST }} username: ${{ secrets.USERNAME }} - key: ${{ secrets.DO_SSH_PRIVATE_KEY }} + key: ${{ secrets.PRIVATE_KEY }} script: | sed -i "s/server_name localhost/server_name ${{ secrets.DOMAIN }}/g" /opt/${{ env.REPO_NAME }}/nginx/nginx.conf @@ -77,7 +77,7 @@ jobs: with: host: ${{ secrets.HOST }} username: ${{ secrets.USERNAME }} - key: ${{ secrets.DO_SSH_PRIVATE_KEY }} + key: ${{ secrets.PRIVATE_KEY }} script: | sudo apt update -y sudo apt upgrade -y @@ -119,7 +119,7 @@ jobs: with: host: ${{ secrets.HOST }} username: ${{ secrets.USERNAME }} - key: ${{ secrets.DO_SSH_PRIVATE_KEY }} + key: ${{ secrets.PRIVATE_KEY }} script: | echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin echo ${REGISTRY}/${OWNER_LC}/${{ env.IMAGE_NAME }}:latest diff --git a/docker-compose-dev.yml b/docker-compose.dev.yml similarity index 100% rename from docker-compose-dev.yml rename to docker-compose.dev.yml diff --git a/docker-compose-prod.yml b/docker-compose.prod.yml similarity index 100% rename from docker-compose-prod.yml rename to docker-compose.prod.yml diff --git a/docs/README.md b/docs/README.md index b9661113..384cc435 100644 --- a/docs/README.md +++ b/docs/README.md @@ -125,7 +125,7 @@ the actions read from the secrets of github, they contain the following informat other info used by the droplet and the container registry: -1. **DO_SSH_PRIVATE_KEY**-> private key from server +1. **PRIVATE_KEY**-> private key from server 1. **GHCR_TOKEN** -> [token of github](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) 1. **HOST** -> droplet IP address 1. **USERNAME** -> root diff --git a/manager.sh b/manager.sh index 015bad75..a31dba17 100755 --- a/manager.sh +++ b/manager.sh @@ -3,22 +3,22 @@ # Questa funzione elimina le immagini precedenti e avvia i container build_and_start_containers() { # Elimina i container e i volumi esistenti (opzionale) - sudo docker-compose -f docker-compose-dev.yml down -v --remove-orphans + sudo docker-compose -f docker-compose.dev.yml down -v --remove-orphans # Avvia i container Docker in background e ricrea le immagini se necessario - sudo docker-compose -f docker-compose-dev.yml up -d --build + sudo docker-compose -f docker-compose.dev.yml up -d --build echo "Immagini create" # Applica le migrazioni del database all'interno del container "web" - sudo docker-compose -f docker-compose-dev.yml exec web python manage.py migrate --noinput + sudo docker-compose -f docker-compose.dev.yml exec web python manage.py migrate --noinput echo "Migrazioni eseguite" # Raccoglie i file statici all'interno del container "web", cancellando quelli esistenti - sudo docker-compose -f docker-compose-dev.yml exec web python manage.py collectstatic --noinput --clear + sudo docker-compose -f docker-compose.dev.yml exec web python manage.py collectstatic --noinput --clear echo "File statici raccolti" # Crea un superuser con le credenziali dalle variabili d'ambiente - sudo docker-compose -f docker-compose-dev.yml exec web python manage.py createsuperuser + sudo docker-compose -f docker-compose.dev.yml exec web python manage.py createsuperuser echo "Superuser creato" echo "Server in esecuzione" @@ -27,15 +27,15 @@ build_and_start_containers() { # Questa funzione avvia solo i container Docker start_containers() { # Avvia i container Docker in background - sudo docker-compose -f docker-compose-dev.yml up -d + sudo docker-compose -f docker-compose.dev.yml up -d echo "Immagini create" # Applica le migrazioni del database all'interno del container "web" - sudo docker-compose -f docker-compose-dev.yml exec web python manage.py migrate --noinput + sudo docker-compose -f docker-compose.dev.yml exec web python manage.py migrate --noinput echo "Migrazioni eseguite" # Raccoglie i file statici all'interno del container "web", cancellando quelli esistenti - sudo docker-compose -f docker-compose-dev.yml exec web python manage.py collectstatic --noinput --clear + sudo docker-compose -f docker-compose.dev.yml exec web python manage.py collectstatic --noinput --clear echo "File statici raccolti" echo "Server in esecuzione" @@ -44,7 +44,7 @@ start_containers() { # Questa funzione ferma i container Docker stop_containers() { # Ferma tutti i container precedenti - sudo docker-compose -f docker-compose-dev.yml down + sudo docker-compose -f docker-compose.dev.yml down echo "Server fermato" } @@ -52,7 +52,7 @@ stop_containers() { # Questa funzione elimina tutti i container e i volumi destroy_containers() { # Elimina tutti i container e i volumi associati - sudo docker-compose -f docker-compose-dev.yml down -v --remove-orphans + sudo docker-compose -f docker-compose.dev.yml down -v --remove-orphans echo "Container e volumi eliminati" }