-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Markus Blaschke <[email protected]>
- Loading branch information
Showing
5 changed files
with
169 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: "Scheduled: docker" | ||
|
||
on: | ||
schedule: | ||
- cron: '0 6 * * 1' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Run Gosec Security Scanner | ||
uses: securego/gosec@master | ||
with: | ||
args: ./... | ||
|
||
- name: Run Golangci lint | ||
uses: golangci/golangci-lint-action@v2 | ||
with: | ||
version: latest | ||
args: -E exportloopref,gofmt --timeout=30m | ||
|
||
- name: Docker meta | ||
id: docker_meta | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: ${{ github.repository }},quay.io/${{ github.repository }} | ||
labels: | | ||
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/${{ github.repository }}/${{ github.event.repository.default_branch }}/README.md | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Login to Quay | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: quay.io | ||
username: ${{ secrets.QUAY_USERNAME }} | ||
password: ${{ secrets.QUAY_TOKEN }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
platforms: linux/amd64,linux/arm,linux/arm64 | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.docker_meta.outputs.tags }} | ||
labels: ${{ steps.docker_meta.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,38 @@ | ||
FROM golang:1.15 as build | ||
############################################# | ||
# Build | ||
############################################# | ||
FROM --platform=$BUILDPLATFORM golang:1.18-alpine as build | ||
|
||
RUN apk upgrade --no-cache --force | ||
RUN apk add --update build-base make git | ||
|
||
WORKDIR /go/src/github.com/webdevops/apprelease-exporter | ||
|
||
# Get deps (cached) | ||
COPY ./go.mod /go/src/github.com/webdevops/apprelease-exporter | ||
COPY ./go.sum /go/src/github.com/webdevops/apprelease-exporter | ||
# Dependencies | ||
COPY go.mod go.sum . | ||
RUN go mod download | ||
|
||
# Compile | ||
COPY ./ /go/src/github.com/webdevops/apprelease-exporter | ||
COPY . . | ||
RUN make test | ||
RUN make lint | ||
RUN make build | ||
RUN ./apprelease-exporter --help | ||
ARG TARGETOS TARGETARCH | ||
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build | ||
|
||
############################################# | ||
# Test | ||
############################################# | ||
FROM gcr.io/distroless/static as test | ||
USER 0:0 | ||
WORKDIR /app | ||
COPY --from=build /go/src/github.com/webdevops/apprelease-exporter/apprelease-exporter . | ||
RUN ["./apprelease-exporter", "--help"] | ||
|
||
############################################# | ||
# FINAL IMAGE | ||
# Final | ||
############################################# | ||
FROM gcr.io/distroless/static | ||
ENV LOG_JSON=1 | ||
COPY --from=build /go/src/github.com/webdevops/apprelease-exporter/apprelease-exporter / | ||
USER 1000 | ||
WORKDIR / | ||
COPY --from=test /app . | ||
USER 1000:1000 | ||
ENTRYPOINT ["/apprelease-exporter"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters