Improve docker builds #110
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - master | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| env: | |
| NEXT_TELEMETRY_DISABLED: 1 | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| environment: production | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| - name: Log in to Docker Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up docker buildx | |
| id: buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Cache | |
| uses: actions/cache@v4 | |
| id: cache | |
| with: | |
| path: cache-mount | |
| key: cache-mount-${{ hashFiles('Dockerfile') }} | |
| - name: Inject docker mount cache | |
| uses: reproducible-containers/buildkit-cache-dance@v3 | |
| with: | |
| builder: ${{ steps.buildx.outputs.name }} | |
| cache-dir: cache-mount | |
| skip-extraction: ${{ steps.cache.outputs.cache-hit }} | |
| - name: Build and push app image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| platforms: linux/arm64 | |
| file: ./Dockerfile | |
| push: true | |
| tags: | | |
| ${{ secrets.DOCKER_REPOSITORY }}:docs-${{ github.sha }} | |
| ${{ secrets.DOCKER_REPOSITORY }}:docs-latest | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Configure SSH | |
| run: | | |
| mkdir -p ~/.ssh | |
| chmod 700 ~/.ssh | |
| echo "${{ secrets.HETZNER_HOST_SSH_KEY }}" > ~/.ssh/id_rsa | |
| chmod 600 ~/.ssh/id_rsa | |
| ssh-keyscan -H ${{ secrets.HETZNER_HOST }} >> ~/.ssh/known_hosts | |
| chmod 644 ~/.ssh/known_hosts | |
| - name: Deploy | |
| run: | | |
| echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin | |
| docker compose up --build -d --remove-orphans | |
| env: | |
| DOCKER_REPOSITORY: ${{ secrets.DOCKER_REPOSITORY }} | |
| DOCKER_HOST: ssh://${{ secrets.REMOTE_DOCKER_HOST }} | |
| IMAGE_TAG: ${{ github.sha }} |