Skip to content

Commit

Permalink
delete docker
Browse files Browse the repository at this point in the history
  • Loading branch information
waelABDALLAH1 committed Nov 11, 2024
1 parent 9b915b4 commit 87e23b5
Showing 1 changed file with 27 additions and 26 deletions.
53 changes: 27 additions & 26 deletions .github/workflows/catalog-service-ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,50 +22,51 @@ jobs:
distribution: 'temurin'
java-version: '17'

- name: Install SDKMAN!
- name: Install SDKMAN! and Quarkus
run: |
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install quarkus
- name: Build with Quarkus
run: |
cd catalog/catalog-service/
quarkus build
source "$HOME/.sdkman/bin/sdkman-init.sh"
cd catalog/catalog-service/
quarkus build --uber-jar # Génère un fichier JAR exécutable
- name: Run Tests
run: |
cd catalog/catalog-service/
quarkus test
- name: Set Docker Image Tag
id: docker_tag
run: echo "tag=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV

- name: Build Docker image
run: |
cd catalog/catalog-service/
docker-compose up --build -d
source "$HOME/.sdkman/bin/sdkman-init.sh"
cd catalog/catalog-service/
quarkus test
- name: Push Docker image
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker push <dockerhub_username>/<image_name>:${{ env.tag }}
- name: Archive JAR Artifact
uses: actions/upload-artifact@v3
with:
name: service-catalog.jar
path: catalog/catalog-service/target/*-runner.jar # Chemin vers le JAR généré

deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to VM
- name: Download JAR Artifact
uses: actions/download-artifact@v3
with:
name: service-catalog.jar
path: ./

- name: Deploy JAR to VM
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.VM_HOST }}
username: ${{ secrets.VM_USERNAME }}
key: ${{ secrets.VM_SSH_KEY }}
script: |
docker pull <dockerhub_username>/<image_name>:${{ needs.build.outputs.tag }}
docker-compose down
docker-compose up -d
# Crée un répertoire pour l'application s'il n'existe pas
mkdir -p ~/service-catalog
# Copie le fichier JAR sur la VM
scp service-catalog.jar ${{ secrets.VM_USERNAME }}@${{ secrets.VM_HOST }}:~/service-catalog/service-catalog.jar
# Redémarre l'application avec le nouveau JAR sur le port 8082
pkill -f 'java.*service-catalog.jar' || true # Arrête l'ancienne instance
nohup java -jar ~/service-catalog/service-catalog.jar --server.port=8082 > ~/service-catalog/app.log 2>&1 &

0 comments on commit 87e23b5

Please sign in to comment.