Skip to content

Commit

Permalink
Add Github Workflow to build and push a docker image to GHCR
Browse files Browse the repository at this point in the history
  • Loading branch information
danielelisi committed Oct 3, 2023
1 parent 27a91c0 commit d4dddfb
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 1 deletion.
58 changes: 58 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
name: Build and Publish Docker image

on:
push:
tags:
- "v*"
branches:
- '*'
pull_request:
branches:
- 'main'

jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
id: 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/ecadlabs/go-tezos-keygen
tags: |
type=ref,event=branch,suffix=-{{sha}}
type=ref,event=pr,suffix=-{{sha}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@
# Go workspace file
go.work

/go-tezos-keygen
/go-tezos-keygen
*.db
networks.yaml
.vscode
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM golang:1.21-bullseye AS builder

WORKDIR /src

# Caching step
COPY go.mod go.sum ./
RUN go mod download

COPY . .

RUN go build -o /go-tezos-keygen

FROM debian:bullseye-slim as runtime

WORKDIR /app

COPY --from=builder /go-tezos-keygen /app/go-tezos-keygen

EXPOSE 3000

ENTRYPOINT ["/app/go-tezos-keygen"]

0 comments on commit d4dddfb

Please sign in to comment.