-
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.
- Loading branch information
Showing
2 changed files
with
65 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: ci | ||
on: [push] | ||
|
||
jobs: | ||
hadolint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: hadolint/[email protected] | ||
with: | ||
ignore: DL3018 | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.18 | ||
- name: Lint & Test | ||
run: make setup-ci ci | ||
docker: | ||
needs: [hadolint, test] | ||
runs-on: ubuntu-latest | ||
env: | ||
IMGTAG: ghcr.io/avakarev/lidl-connect-exporter | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- id: git | ||
run: | | ||
echo "::set-output name=sha::$(git rev-parse --short HEAD)" | ||
echo "::set-output name=ref::${GITHUB_REF##*/}" | ||
- uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- uses: docker/build-push-action@v3 | ||
with: | ||
tags: | | ||
${{ env.IMGTAG }}:${{ steps.git.outputs.sha }} | ||
${{ env.IMGTAG }}:${{ steps.git.outputs.ref }} | ||
build-args: | | ||
GITHUB_SHA=${{ steps.git.outputs.sha }} | ||
GITHUB_REF=${{ steps.git.outputs.ref }} | ||
push: true |
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,20 @@ | ||
ARG GO_VERSION=1.18 | ||
|
||
FROM golang:${GO_VERSION}-alpine AS builder | ||
ARG GITHUB_SHA | ||
ARG GITHUB_REF | ||
RUN apk add --no-cache ca-certificates tzdata make | ||
WORKDIR /src | ||
COPY go.mod go.sum Makefile ./ | ||
RUN go mod download | ||
COPY cmd ./cmd | ||
COPY internal ./internal | ||
RUN make build | ||
|
||
FROM scratch | ||
USER 1000 | ||
WORKDIR /app | ||
COPY --from=builder /src/bin/server /app/server | ||
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo | ||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt | ||
CMD ["/app/server"] |