diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..96fbaad --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,102 @@ +name: "Build and Push Docker image" + +on: + pull_request: + branches: + - main + release: + types: + - published + +env: + REGISTRY: ghcr.io + +concurrency: + group: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' && github.ref_type != 'tag' }} + +jobs: + build: + name: Build ${{ matrix.name }} - ${{ matrix.label }} + strategy: + matrix: + include: + - name: GitHub Actions + dockerfile: Dockerfile.gha + label: ${{ github.repository_owner }}/temporal-gha-service + - name: Official + dockerfile: Dockerfile + label: ${{ github.repository_owner }}/temporal-dev-server + permissions: + contents: read + packages: write + id-token: write + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + # Install the cosign tool except on PR + # https://github.com/sigstore/cosign-installer + # - name: Install cosign + # if: github.event_name != 'pull_request' + # uses: sigstore/cosign-installer@v3.5.0 + # with: + # cosign-release: "v2.1.1" + + # Set up BuildKit Docker container builder to be able to build + # multi-platform images and export cache + # https://github.com/docker/setup-buildx-action + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.3.0 + with: + install: true + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v3.1.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata (${{ matrix.name }}) + id: meta + uses: docker/metadata-action@v5.5.1 + with: + images: "${{ env.REGISTRY }}/${{ matrix.label }}" + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image (${{ matrix.name }}) + id: build-and-push + uses: docker/build-push-action@v5.3.0 + with: + context: . + file: ${{ matrix.dockerfile }} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + # Sign the resulting Docker image digest except on PRs. + # This will only write to the public Rekor transparency log when the Docker + # repository is public to avoid leaking data. If you would like to publish + # transparency data even for private images, pass --force to cosign below. + # https://github.com/sigstore/cosign + # - name: Sign the published Docker image + # if: ${{ github.event_name != 'pull_request' }} + # env: + # https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable + # COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }} + # COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }} + # DIGEST: ${{ steps.build-and-push.outputs.digest }} + # TAGS: ${{ steps.meta.outputs.tags }} + # This step uses the identity token to provision an ephemeral certificate + # against the sigstore community Fulcio instance. + # run: echo "${TAGS}" | xargs -I {} cosign sign --yes --key env://COSIGN_PRIVATE_KEY {}@${DIGEST} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..544e0c5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,4 @@ +FROM temporalio/admin-tools:1.23 +EXPOSE 7233 +EXPOSE 8233 +ENTRYPOINT ["/usr/local/bin/temporal", "server", "start-dev", "-p", "7233", "--ip", "0.0.0.0"] diff --git a/Dockerfile.gha b/Dockerfile.gha new file mode 100644 index 0000000..e3e2e4b --- /dev/null +++ b/Dockerfile.gha @@ -0,0 +1,4 @@ +FROM temporalio/admin-tools:1.23 +EXPOSE 7233 +ENTRYPOINT ["/usr/local/bin/temporal", "server", "start-dev", "-p", "7233", "--ip", "0.0.0.0"] +CMD ["--namespace", "test"]