Skip to content

Commit

Permalink
Add working CI setup (#4)
Browse files Browse the repository at this point in the history
* Add working CI setup

* rename the project to gangplank

* fix dockerfile build and tests

* use golang image for goreleaser

* fix goreleaser docker build

* push docker image

* reset docker image push to auto
  • Loading branch information
alessiodionisi authored Mar 11, 2024
1 parent 9454972 commit cf0edcb
Show file tree
Hide file tree
Showing 39 changed files with 802 additions and 518 deletions.
103 changes: 103 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# 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.

kind: pipeline
type: docker
name: main

steps:
- name: prepare
image: quay.io/sighup/golang:1.22.1
commands:
- mkdir -p .go/cache .go/modcache .go/tmp
- go mod download
environment:
GOCACHE: /drone/src/.go/cache
GOMODCACHE: /drone/src/.go/modcache
GOTMPDIR: /drone/src/.go/tmp
depends_on:
- clone

- name: check-license
image: quay.io/sighup/golang:1.22.1
pull: always
commands:
- make license-check
environment:
GOCACHE: /drone/src/.go/cache
GOMODCACHE: /drone/src/.go/modcache
GOTMPDIR: /drone/src/.go/tmp
depends_on:
- prepare

- name: build
image: quay.io/sighup/golang:1.22.1
commands:
- make build
environment:
GOCACHE: /drone/src/.go/cache
GOMODCACHE: /drone/src/.go/modcache
GOTMPDIR: /drone/src/.go/tmp
GITHUB_TOKEN:
from_secret: GITHUB_TOKEN
volumes:
- name: dockersock
path: /var/run/docker.sock
depends_on:
- check-license

- 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
- git fetch --tags
- make release
environment:
GOCACHE: /drone/src/.go/cache
GOMODCACHE: /drone/src/.go/modcache
GOTMPDIR: /drone/src/.go/tmp
GITHUB_TOKEN:
from_secret: GITHUB_TOKEN
DOCKER_CONFIG_JSON:
from_secret: DOCKERCONFIGJSON_UCS
COSIGN_KEY:
from_secret: COSIGN_KEY
COSIGN_PWD:
from_secret: COSIGN_PASSWORD
volumes:
- name: dockersock
path: /var/run/docker.sock
depends_on:
- check-license
when:
ref:
include:
- refs/tags/v**

volumes:
- name: dockersock
host:
path: /var/run/docker.sock

trigger:
event:
exclude:
- pull_request
- promote
ref:
exclude:
- refs/tags/helm-chart-v**
9 changes: 1 addition & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
*.swp
*.swo
config.yml
/gangway
vendor/
cmd/gangway/bindata.go
.idea/
gangway.kubeconfig
dist/
63 changes: 63 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# 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.

project_name: gangplank

before:
hooks:
- go mod tidy

builds:
- env:
- CGO_ENABLED=0
goarch:
- amd64
- arm64
goos:
- linux
main: ./cmd/gangplank

archives:
- name_template: "{{ tolower .ProjectName }}-{{ tolower .Os }}-{{ tolower .Arch }}"

checksum:
name_template: checksums.txt

snapshot:
name_template: "{{ incpatch .Version }}-develop"

changelog:
filters:
exclude:
- "^docs:"
- "^test:"
sort: asc

release:
github:
owner: sighupio
name: gangplank
name_template: "{{ .Tag }}"
prerelease: auto

dockers:
- dockerfile: ./Dockerfile
extra_files:
- ./
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 }}"
skip_push: auto
4 changes: 3 additions & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
golang 1.22.0
golang 1.22.1
make 4.4.1
goreleaser 1.24.0
12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

37 changes: 0 additions & 37 deletions CODE_OF_CONDUCT.md

This file was deleted.

58 changes: 0 additions & 58 deletions CONTRIBUTING.md

This file was deleted.

42 changes: 31 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
FROM golang:1.14.2-stretch
WORKDIR /go/src/github.com/heptiolabs/gangway
# 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 as dev

ENV CGO_ENABLED=0

WORKDIR /src

RUN go get -u github.com/mjibson/esc/...
COPY . .
RUN esc -o cmd/gangway/bindata.go templates/

ENV GO111MODULE on
RUN go mod verify
RUN CGO_ENABLED=0 GOOS=linux go install -ldflags="-w -s" -v github.com/heptiolabs/gangway/...
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

FROM debian:9.12-slim
RUN apt-get update && apt-get install -y ca-certificates
USER 1001:1001
COPY --from=0 /go/bin/gangway /bin/gangway
ENTRYPOINT ["gangplank"]
Loading

0 comments on commit cf0edcb

Please sign in to comment.