diff --git a/.github/workflows/deploy-development.yml b/.github/workflows/deploy-development.yml index 2b479028..b72a1140 100644 --- a/.github/workflows/deploy-development.yml +++ b/.github/workflows/deploy-development.yml @@ -4,22 +4,91 @@ on: workflow_dispatch: jobs: - docker: - name: Build & Deploy Docker - runs-on: ubuntu-latest + docker-build: + name: Build Docker + runs-on: ${{ matrix.arch.os }} if: github.repository_owner == 'wg-easy' permissions: packages: write - contents: read + strategy: + fail-fast: false + matrix: + arch: + - platform: linux/amd64 + os: ubuntu-latest + - platform: linux/arm64 + os: ubuntu-24.04-arm steps: - uses: actions/checkout@v4 + - name: Prepare + run: | + platform=${{ matrix.arch.platform }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/wg-easy/wg-easy + flavor: | + latest=false + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Build and push by digest + id: build + uses: docker/build-push-action@v6 + with: + context: . + platforms: ${{ matrix.arch.platform }} + labels: ${{ steps.meta.outputs.labels }} + tags: ghcr.io/wg-easy/wg-easy + outputs: type=image,push-by-digest=true,name-canonical=true,push=true + cache-from: type=gha,scope=build-${{ env.PLATFORM_PAIR }} + cache-to: type=gha,mode=min,scope=build-${{ env.PLATFORM_PAIR }} + + - name: Export digest + run: | + mkdir -p ${{ runner.temp }}/digests + digest="${{ steps.build.outputs.digest }}" + touch "${{ runner.temp }}/digests/${digest#sha256:}" + + - name: Upload digest + uses: actions/upload-artifact@v4 + with: + name: digests-${{ env.PLATFORM_PAIR }} + path: ${{ runner.temp }}/digests/* + if-no-files-found: error + retention-days: 1 + + docker-merge: + name: Merge & Deploy Docker + runs-on: ubuntu-latest + if: github.repository_owner == 'wg-easy' + permissions: + packages: write + needs: docker-build + steps: + - name: Download digests + uses: actions/download-artifact@v4 + with: + path: ${{ runner.temp }}/digests + pattern: digests-* + merge-multiple: true + - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: @@ -27,15 +96,29 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build & Publish Docker Image - uses: docker/build-push-action@v6 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 with: - context: . - push: true - platforms: linux/amd64,linux/arm64 - tags: ghcr.io/wg-easy/wg-easy:development - cache-from: type=gha - cache-to: type=gha,mode=min + images: | + ghcr.io/wg-easy/wg-easy + flavor: | + latest=false + tags: | + type=raw,value=development + + - name: Create manifest list and push + working-directory: ${{ runner.temp }}/digests + run: | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf 'ghcr.io/wg-easy/wg-easy@sha256:%s ' *) + + - name: Inspect image + run: | + docker buildx imagetools inspect ghcr.io/wg-easy/wg-easy:${{ steps.meta.outputs.version }} docs: name: Build & Deploy Docs @@ -43,7 +126,7 @@ jobs: if: github.repository_owner == 'wg-easy' permissions: contents: write - needs: docker + needs: docker-merge steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/deploy-edge.yml b/.github/workflows/deploy-edge.yml index de8a842f..0a626557 100644 --- a/.github/workflows/deploy-edge.yml +++ b/.github/workflows/deploy-edge.yml @@ -11,24 +11,93 @@ concurrency: cancel-in-progress: true jobs: - docker: - name: Build & Deploy Docker - runs-on: ubuntu-latest + docker-build: + name: Build Docker + runs-on: ${{ matrix.arch.os }} if: github.repository_owner == 'wg-easy' permissions: packages: write - contents: read + strategy: + fail-fast: false + matrix: + arch: + - platform: linux/amd64 + os: ubuntu-latest + - platform: linux/arm64 + os: ubuntu-24.04-arm steps: - uses: actions/checkout@v4 with: ref: master + - name: Prepare + run: | + platform=${{ matrix.arch.platform }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/wg-easy/wg-easy + flavor: | + latest=false + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Build and push by digest + id: build + uses: docker/build-push-action@v6 + with: + context: . + platforms: ${{ matrix.arch.platform }} + labels: ${{ steps.meta.outputs.labels }} + tags: ghcr.io/wg-easy/wg-easy + outputs: type=image,push-by-digest=true,name-canonical=true,push=true + cache-from: type=gha,scope=build-${{ env.PLATFORM_PAIR }} + cache-to: type=gha,mode=min,scope=build-${{ env.PLATFORM_PAIR }} + + - name: Export digest + run: | + mkdir -p ${{ runner.temp }}/digests + digest="${{ steps.build.outputs.digest }}" + touch "${{ runner.temp }}/digests/${digest#sha256:}" + + - name: Upload digest + uses: actions/upload-artifact@v4 + with: + name: digests-${{ env.PLATFORM_PAIR }} + path: ${{ runner.temp }}/digests/* + if-no-files-found: error + retention-days: 1 + + docker-merge: + name: Merge & Deploy Docker + runs-on: ubuntu-latest + if: github.repository_owner == 'wg-easy' + permissions: + packages: write + needs: docker-build + steps: + - name: Download digests + uses: actions/download-artifact@v4 + with: + path: ${{ runner.temp }}/digests + pattern: digests-* + merge-multiple: true + - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: @@ -36,15 +105,29 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build & Publish Docker Image - uses: docker/build-push-action@v6 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 with: - context: . - push: true - platforms: linux/amd64,linux/arm64 - tags: ghcr.io/wg-easy/wg-easy:edge - cache-from: type=gha - cache-to: type=gha,mode=min + images: | + ghcr.io/wg-easy/wg-easy + flavor: | + latest=false + tags: | + type=raw,value=edge + + - name: Create manifest list and push + working-directory: ${{ runner.temp }}/digests + run: | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf 'ghcr.io/wg-easy/wg-easy@sha256:%s ' *) + + - name: Inspect image + run: | + docker buildx imagetools inspect ghcr.io/wg-easy/wg-easy:${{ steps.meta.outputs.version }} docs: name: Build & Deploy Docs @@ -52,7 +135,7 @@ jobs: if: github.repository_owner == 'wg-easy' permissions: contents: write - needs: docker + needs: docker-merge steps: - uses: actions/checkout@v4 with: diff --git a/.github/workflows/deploy-pr.yml b/.github/workflows/deploy-pr.yml index 4a3f38e2..2ea72247 100644 --- a/.github/workflows/deploy-pr.yml +++ b/.github/workflows/deploy-pr.yml @@ -11,14 +11,24 @@ concurrency: jobs: docker: name: Build Docker - runs-on: ubuntu-latest + runs-on: ${{ matrix.arch.os }} if: github.repository_owner == 'wg-easy' - permissions: - packages: write - contents: read + strategy: + fail-fast: false + matrix: + arch: + - platform: linux/amd64 + os: ubuntu-latest + - platform: linux/arm64 + os: ubuntu-24.04-arm steps: - uses: actions/checkout@v4 + - name: Prepare + run: | + platform=${{ matrix.arch.platform }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -37,7 +47,7 @@ jobs: with: context: . push: false - platforms: linux/amd64,linux/arm64 + platforms: ${{ matrix.arch.platform }} tags: ghcr.io/wg-easy/wg-easy:pr cache-from: type=gha - cache-to: type=gha,mode=min + cache-to: type=gha,mode=min,scope=build-${{ env.PLATFORM_PAIR }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 9afe6ac5..043b2b19 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -10,23 +10,29 @@ on: # as this will break the latest and major tags jobs: - docker: - name: Build & Deploy Docker - runs-on: ubuntu-latest + docker-build: + name: Build Docker + runs-on: ${{ matrix.arch.os }} if: | github.repository_owner == 'wg-easy' && startsWith(github.ref, 'refs/tags/v') permissions: packages: write - contents: read + strategy: + fail-fast: false + matrix: + arch: + - platform: linux/amd64 + os: ubuntu-latest + - platform: linux/arm64 + os: ubuntu-24.04-arm steps: - uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + - name: Prepare + run: | + platform=${{ matrix.arch.platform }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV - name: Docker meta id: meta @@ -36,10 +42,6 @@ jobs: ghcr.io/wg-easy/wg-easy flavor: | latest=false - tags: | - type=semver,pattern={{version}} - type=semver,pattern={{major}} - type=semver,pattern={{major}}.{{minor}} - name: Login to GitHub Container Registry uses: docker/login-action@v3 @@ -48,16 +50,87 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build & Publish Docker Image + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push by digest + id: build uses: docker/build-push-action@v6 with: context: . - push: true - platforms: linux/amd64,linux/arm64 - tags: ${{ steps.meta.outputs.tags }} + platforms: ${{ matrix.arch.platform }} labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=min + tags: ghcr.io/wg-easy/wg-easy + outputs: type=image,push-by-digest=true,name-canonical=true,push=true + cache-from: type=gha,scope=build-${{ env.PLATFORM_PAIR }} + cache-to: type=gha,mode=min,scope=build-${{ env.PLATFORM_PAIR }} + + - name: Export digest + run: | + mkdir -p ${{ runner.temp }}/digests + digest="${{ steps.build.outputs.digest }}" + touch "${{ runner.temp }}/digests/${digest#sha256:}" + + - name: Upload digest + uses: actions/upload-artifact@v4 + with: + name: digests-${{ env.PLATFORM_PAIR }} + path: ${{ runner.temp }}/digests/* + if-no-files-found: error + retention-days: 1 + + docker-merge: + name: Merge & Deploy Docker + runs-on: ubuntu-latest + if: | + github.repository_owner == 'wg-easy' && + startsWith(github.ref, 'refs/tags/v') + permissions: + packages: write + needs: docker-build + steps: + - name: Download digests + uses: actions/download-artifact@v4 + with: + path: ${{ runner.temp }}/digests + pattern: digests-* + merge-multiple: true + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/wg-easy/wg-easy + flavor: | + latest=false + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}} + type=semver,pattern={{major}}.{{minor}} + + - name: Create manifest list and push + working-directory: ${{ runner.temp }}/digests + run: | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf 'ghcr.io/wg-easy/wg-easy@sha256:%s ' *) + + - name: Inspect image + run: | + docker buildx imagetools inspect ghcr.io/wg-easy/wg-easy:${{ steps.meta.outputs.version }} docs: name: Build & Deploy Docs @@ -67,7 +140,7 @@ jobs: startsWith(github.ref, 'refs/tags/v') permissions: contents: write - needs: docker + needs: docker-merge steps: - uses: actions/checkout@v4 @@ -93,8 +166,8 @@ jobs: git fetch origin gh-pages --depth=1 || true # Extract version numbers - DOCS_VERSION=${GITHUB_REF#refs/tags/} # e.g. v1.2.3 or v1.2.3-beta - MINOR_VERSION=$(echo $DOCS_VERSION | cut -d. -f1,2) # e.g. v1.2 + DOCS_VERSION=${GITHUB_REF#refs/tags/} # e.g. v1.2.3 or v1.2.3-beta + MINOR_VERSION=$(echo $DOCS_VERSION | cut -d. -f1,2) # e.g. v1.2 # Check if it's a stable release (only numbers, no '-') if [[ "$DOCS_VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then diff --git a/Dockerfile b/Dockerfile index 0aae23f1..f160d7c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,7 +28,7 @@ COPY --from=build /app/server/database/migrations /app/server/database/migration # libsql RUN cd /app/server && npm install --no-save libsql # cli -COPY --from=build /app/cli/cli.sh /usr/local/bin/cli +COPY --from=build /app/cli/cli.sh /usr/local/bin/cli RUN chmod +x /usr/local/bin/cli # Install Linux packages