diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index c3a9b54..0f07f90 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -1,24 +1,58 @@ -name: Deploy +name: Build & Deploy on: push: branches: [main] +env: + IMAGE: ${{ vars.REGISTRY_URL }}/${{ github.repository_owner }}/slaapkampioen + jobs: - deploy: + # ── 1. Bouw de Docker image en push naar Gitea registry ── + build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Checkout + uses: actions/checkout@v4 - - name: Deploy via SSH - uses: appleboy/ssh-action@master + - name: Log in to Gitea registry + uses: docker/login-action@v3 with: - host: ${{ secrets.DEPLOY_HOST }} - username: ${{ secrets.DEPLOY_USER }} - key: ${{ secrets.DEPLOY_KEY }} - script: | - cd /opt/slaapkampioen - git pull - docker compose build --no-cache - docker compose up -d - docker compose logs --tail=20 app + registry: ${{ vars.REGISTRY_URL }} + username: ${{ vars.REGISTRY_USER }} + password: ${{ secrets.REGISTRY_TOKEN }} + + - name: Build & push + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: | + ${{ env.IMAGE }}:latest + ${{ env.IMAGE }}:${{ github.sha }} + + # # ── 2. Deployen op de server via SSH ── + # deploy: + # needs: build + # runs-on: ubuntu-latest + # steps: + # - name: Deploy via SSH + # uses: appleboy/ssh-action@master + # with: + # host: ${{ vars.DEPLOY_HOST }} + # username: ${{ vars.DEPLOY_USER }} + # key: ${{ secrets.DEPLOY_KEY }} + # script: | + # # Inloggen op de Gitea registry (voor docker pull) + # echo "${{ secrets.REGISTRY_TOKEN }}" | \ + # docker login ${{ vars.REGISTRY_URL }} \ + # -u ${{ vars.REGISTRY_USER }} --password-stdin + + # cd ${{ vars.DEPLOY_PATH }} + + # # Nieuwste image pullen en container herstarten + # docker compose pull + # docker compose up -d + + # # Oude images opruimen + # docker image prune -f \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 6fbf349..0ba5b60 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,8 @@ services: app: - build: . + # Image wordt gebuild door Gitea Actions en gepusht naar de registry. + # Vervang dit met jouw Gitea hostname + gebruikersnaam: + image: git.geyskens.eu/sam/slaapkampioenv2:latest container_name: slaapkampioen restart: unless-stopped environment: @@ -40,4 +42,4 @@ volumes: networks: internal: - driver: bridge + driver: bridge \ No newline at end of file