Skip to content

Commit

Permalink
feat: add docker buildx, update github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
andrejpetras committed Feb 2, 2024
1 parent cc09bd8 commit 8f65c7b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v4
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.19
go-version: 1.21
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
- uses: docker/login-action@v2
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v4
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.19
go-version: 1.21
- uses: golangci/golangci-lint-action@v3
- uses: docker/login-action@v2
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand All @@ -25,7 +25,7 @@ jobs:
go build .
go test
go clean
- uses: goreleaser/goreleaser-action@v4
- uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --clean --snapshot
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ jobs:
name: Release on GitHub
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v4
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.19
go-version: 1.21
- uses: golangci/golangci-lint-action@v3
- uses: docker/login-action@v2
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: goreleaser/goreleaser-action@v4
- uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --clean
Expand Down
5 changes: 5 additions & 0 deletions cmd/docker_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type dockerBuildFlags struct {
Profile string `mapstructure:"docker-profile"`
Context string `mapstructure:"docker-context"`
Platform string `mapstructure:"docker-platform"`
BuildX bool `mapstructure:"docker-buildx"`
SkipDevBuild bool `mapstructure:"docker-skip-dev"`
SkipPull bool `mapstructure:"docker-skip-pull"`
BuildPush bool `mapstructure:"docker-build-push"`
Expand Down Expand Up @@ -39,6 +40,7 @@ func createDockerBuildCmd() *cobra.Command {
addStringFlag(cmd, "docker-platform", "", "", "the docker build platform")
addBoolFlag(cmd, "docker-skip-pull", "", false, "skip docker pull new images for the build")
addBoolFlag(cmd, "docker-build-push", "", false, "push docker image after build")
addBoolFlag(cmd, "docker-buildx", "", false, "extended build capabilities with BuildKit")
addBoolFlag(cmd, "docker-skip-dev", "", false, "skip build image {{ .Name }}:latest")
addBoolFlag(cmd, "docker-remove-intermediate-img-skip", "", false, "skip remove build intermediate containers")

Expand Down Expand Up @@ -70,6 +72,9 @@ func dockerBuild(project *Project, flags dockerBuildFlags) {
log.Info("Build docker image", log.Fields{"image": dockerImage, "tags": tags})

var command []string
if flags.BuildX {
command = append(command, "buildx")
}
command = append(command, "build")
if !flags.SkipPull {
command = append(command, "--pull")
Expand Down

0 comments on commit 8f65c7b

Please sign in to comment.