Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build & push demo binaries on main #14

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: docker
on:
push:
- main
pull_request:
permissions:
contents: read
env:
REGISTRY_HOST: ${{ secrets.RELEASE_REGISTRY_HOST }}
REGISTRY_URL: ${{ secrets.RELEASE_REGISTRY_URL }}
concurrency:
group: docker-${{ github.ref }}
cancel-in-progress: false
jobs:
docker-build-push:
runs-on: ubuntu-latest
permissions:
contents: read
# Needed for Github GCP WIF
id-token: write
strategy:
matrix:
dockerfile:
- Dockerfile.produce
- Dockerfile.consume
steps:
- name: Checkout Code
uses: actions/checkout@v4
- id: ar-auth
name: Authenticate to GCP Release Artifact Registry through WIF
uses: google-github-actions/auth@v2
with:
token_format: 'access_token'
workload_identity_provider: ${{ secrets.RELEASE_REGISTRY_WIF_PROVIDER }}
service_account: ${{ secrets.RELEASE_REGISTRY_SERVICE_ACCOUNT }}
export_environment_variables: false
create_credentials_file: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
network=host
- name: login-ar
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY_HOST }}
username: oauth2accesstoken
password: ${{ steps.ar-auth.outputs.access_token }}
- name: Build and push docker image
uses: docker/build-push-action@v6
with:
context: .
file: ${{ matrix.dockerfile }}
platforms: linux/amd64,linux/arm64
# Don't publish images on PR runs
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ env.REGISTRY_URL }}/bufstream-demo:git.${{ github.sha }}
${{ env.REGISTRY_URL }}/bufstream-demo:latest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're building multiple dockerfiles, probably need the tag to at least be partially based on matrix.dockerfile as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image testing - fixed, thanks

# With provenance: true, docker ends up pushing the image separately into
# multiple files and manifests, which not all clients can read.
provenance: false
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,20 @@ docker-bufstream-run: # Run Bufstream within Docker.
"us-docker.pkg.dev/buf-images-1/bufstream-public/images/bufstream:$(BUFSTREAM_VERSION)" \
--config /bufstream.yaml

.PHONY: docker-produce-run
docker-produce-run: # Run the demo producer within Docker. If you have Go installed, you can call produce-run.
.PHONY: docker-produce-build
docker-produce-build:
docker build -t bufstream/demo-produce -f Dockerfile.produce .

.PHONY: docker-consume-build
docker-consume-build:
docker build -t bufstream/demo-consume -f Dockerfile.consume .

.PHONY: docker-produce-run
docker-produce-run: docker-produce-build # Run the demo producer within Docker. If you have Go installed, you can call produce-run.
docker run --rm --network=host bufstream/demo-produce

.PHONY: docker-consume-run
docker-consume-run: # Run the demo consumer within Docker. If you have Go installed, you can call consume-run.
docker build -t bufstream/demo-consume -f Dockerfile.consume .
docker-consume-run: docker-consume-build # Run the demo consumer within Docker. If you have Go installed, you can call consume-run.
docker run --rm --network=host bufstream/demo-consume

.PHONY: produce-run
Expand Down