Skip to content

Commit

Permalink
Add cosign consign and multi arch images
Browse files Browse the repository at this point in the history
  • Loading branch information
alessiodionisi committed Mar 12, 2024
1 parent cf0edcb commit 0c04880
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 26 deletions.
7 changes: 5 additions & 2 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,14 @@ steps:
path: /var/run/docker.sock
depends_on:
- check-license
when:
ref:
exclude:
- refs/tags/v**

- name: release
image: quay.io/sighup/golang:1.22.1
commands:
- ./scripts/drone/install-cosign.sh
- mkdir -p /root/.docker
- printf "%s" "$DOCKER_CONFIG_JSON" > /root/.docker/config.json
- git reset --hard
Expand All @@ -73,7 +76,7 @@ steps:
GITHUB_TOKEN:
from_secret: GITHUB_TOKEN
DOCKER_CONFIG_JSON:
from_secret: DOCKERCONFIGJSON_UCS
from_secret: DOCKERCONFIGJSON_FURY
COSIGN_KEY:
from_secret: COSIGN_KEY
COSIGN_PWD:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.go/
dist/
55 changes: 48 additions & 7 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ changelog:
- "^docs:"
- "^test:"
sort: asc
use: github-native

release:
github:
Expand All @@ -52,12 +53,52 @@ release:
prerelease: auto

dockers:
- dockerfile: ./Dockerfile
extra_files:
- ./
- build_flag_templates:
- --platform=linux/amd64
image_templates:
- "registry.sighup.io/fury/gangplank:latest"
- "registry.sighup.io/fury/gangplank:v{{ .Major }}"
- "registry.sighup.io/fury/gangplank:v{{ .Major }}.{{ .Minor }}"
- "registry.sighup.io/fury/gangplank:{{ .Tag }}"
- registry.sighup.io/fury/gangplank-amd64:latest
- registry.sighup.io/fury/gangplank-amd64:{{ .Major }}
- registry.sighup.io/fury/gangplank-amd64:{{ .Major }}.{{ .Minor }}
- registry.sighup.io/fury/gangplank-amd64:{{ .Major }}.{{ .Minor }}.{{ .Patch }}
skip_push: auto

- build_flag_templates:
- --platform=linux/arm64
goarch: arm64
image_templates:
- registry.sighup.io/fury/gangplank-arm64:latest
- registry.sighup.io/fury/gangplank-arm64:{{ .Major }}
- registry.sighup.io/fury/gangplank-arm64:{{ .Major }}.{{ .Minor }}
- registry.sighup.io/fury/gangplank-arm64:{{ .Major }}.{{ .Minor }}.{{ .Patch }}
skip_push: auto

docker_manifests:
- name_template: registry.sighup.io/fury/gangplank:latest
image_templates:
- registry.sighup.io/fury/gangplank-amd64:latest
- registry.sighup.io/fury/gangplank-arm64:latest

- name_template: registry.sighup.io/fury/gangplank:{{ .Major }}
image_templates:
- registry.sighup.io/fury/gangplank-amd64:{{ .Major }}
- registry.sighup.io/fury/gangplank-arm64:{{ .Major }}

- name_template: registry.sighup.io/fury/gangplank:{{ .Major }}.{{ .Minor }}
image_templates:
- registry.sighup.io/fury/gangplank-amd64:{{ .Major }}.{{ .Minor }}
- registry.sighup.io/fury/gangplank-arm64:{{ .Major }}.{{ .Minor }}

- name_template: registry.sighup.io/fury/gangplank:{{ .Major }}.{{ .Minor }}.{{ .Patch }}
image_templates:
- registry.sighup.io/fury/gangplank-amd64:{{ .Major }}.{{ .Minor }}.{{ .Patch }}
- registry.sighup.io/fury/gangplank-arm64:{{ .Major }}.{{ .Minor }}.{{ .Patch }}

docker_signs:
- artifacts: all
stdin: "{{ .Env.COSIGN_PWD }}"
args:
- sign
- --key=env://COSIGN_KEY
- --upload=true
- ${artifact}
- --yes
18 changes: 1 addition & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.22.1-alpine as dev

ENV CGO_ENABLED=0

WORKDIR /src

COPY . .

RUN go mod download

ENTRYPOINT [ "go", "run", "./cmd/gangplank" ]

FROM dev as builder

RUN go build ./cmd/gangplank

FROM scratch

COPY --from=builder /src/gangplank /usr/local/bin/gangplank
COPY gangplank /usr/local/bin/gangplank

ENTRYPOINT ["gangplank"]
25 changes: 25 additions & 0 deletions Dockerfile-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2017-present SIGHUP s.r.l
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.22.1-alpine

ENV CGO_ENABLED=0

WORKDIR /src

COPY . .

RUN go mod download

ENTRYPOINT [ "go", "run", "./cmd/gangplank" ]

0 comments on commit 0c04880

Please sign in to comment.