From adddb2dacf6f5b02bff2bf54c4943eab4b54aa10 Mon Sep 17 00:00:00 2001 From: Sebastian Lorenz Date: Fri, 24 Jan 2025 14:07:58 +0100 Subject: [PATCH 1/4] add github workflow for server builds --- .github/workflows/build-server.yml | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/build-server.yml diff --git a/.github/workflows/build-server.yml b/.github/workflows/build-server.yml new file mode 100644 index 00000000..c742b15b --- /dev/null +++ b/.github/workflows/build-server.yml @@ -0,0 +1,39 @@ +on: + pull_request: + branches: [main] + push: + branches: [main] + +jobs: + build-and-push: + name: Build server + runs-on: ubuntu-latest + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/graphprotocol/hypergraph-server + + - name: Login to ghcr.io + uses: docker/login-action@v3 + # if: ${{ github.event_name != 'pull_request' }} + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # TODO: Consider adding caching (`cache-from` and `cache-to`) to speed up builds. + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + # push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From ce53efda77ba910a5c7da1b027360d53b445b03d Mon Sep 17 00:00:00 2001 From: Sebastian Lorenz Date: Fri, 24 Jan 2025 14:10:39 +0100 Subject: [PATCH 2/4] remove context option --- .github/workflows/build-server.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-server.yml b/.github/workflows/build-server.yml index c742b15b..788c2ef6 100644 --- a/.github/workflows/build-server.yml +++ b/.github/workflows/build-server.yml @@ -1,3 +1,5 @@ +name: Build Server + on: pull_request: branches: [main] @@ -6,7 +8,7 @@ on: jobs: build-and-push: - name: Build server + name: Build and Push runs-on: ubuntu-latest steps: - name: Set up QEMU @@ -33,7 +35,6 @@ jobs: - name: Build and push uses: docker/build-push-action@v6 with: - context: . # push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From fa0453bd2f919d038a6767ea3488740b681a949c Mon Sep 17 00:00:00 2001 From: Sebastian Lorenz Date: Fri, 24 Jan 2025 14:18:15 +0100 Subject: [PATCH 3/4] adjust tags --- .github/workflows/build-server.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-server.yml b/.github/workflows/build-server.yml index 788c2ef6..2439d932 100644 --- a/.github/workflows/build-server.yml +++ b/.github/workflows/build-server.yml @@ -5,6 +5,7 @@ on: branches: [main] push: branches: [main] + tags: ['v*'] jobs: build-and-push: @@ -21,11 +22,18 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: ghcr.io/graphprotocol/hypergraph-server + images: ghcr.io/${{ github.repository }} + # TODO: Customize tagging behavior to our needs. + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha - name: Login to ghcr.io uses: docker/login-action@v3 - # if: ${{ github.event_name != 'pull_request' }} + if: ${{ github.event_name != 'pull_request' }} with: registry: ghcr.io username: ${{ github.actor }} @@ -35,6 +43,7 @@ jobs: - name: Build and push uses: docker/build-push-action@v6 with: - # push: ${{ github.event_name != 'pull_request' }} + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From f50c159cdaeacf333d10c2d1dc28a4c86d289061 Mon Sep 17 00:00:00 2001 From: Sebastian Lorenz Date: Fri, 24 Jan 2025 14:26:37 +0100 Subject: [PATCH 4/4] disable prisma codegen postinstall --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index 284a0c90..56369a5f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,9 @@ RUN apk add --update --no-cache openssl python3 make g++ # Install pnpm. ADD package.json . RUN corepack enable && corepack prepare --activate +# Skip prisma code generation during install. +ENV PRISMA_SKIP_POSTINSTALL_GENERATE=true +ENV CI=true # Fetch all node modules purely based on the pnpm lock file. COPY pnpm-lock.yaml . RUN --mount=type=cache,id=workspace,target=/root/.local/share/pnpm/store pnpm fetch