From 4ae39e45d8d88afdb144e1e3c7633e7cbb990445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Biegun?= Date: Thu, 28 Apr 2022 18:42:45 +0200 Subject: [PATCH 1/4] use docker multi stage build --- Dockerfile | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index a1e9dc5..1b973a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,11 @@ -FROM golang:1.18 +FROM golang:1.18 as builder -RUN mkdir /app WORKDIR /app - -COPY go.mod ./ -COPY go.sum ./ -RUN go mod download - COPY . . +RUN go mod download +RUN CGO_ENABLED=0 go build -o geralt -RUN go build -o /geralt - +FROM alpine:3.15 +COPY --from=builder /app/geralt / EXPOSE 8080 - -CMD [ "/geralt" ] +CMD ["/geralt"] From 7387374dbcac0401e038b8cc51b825b62ae3ab72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Biegun?= Date: Thu, 28 Apr 2022 18:47:12 +0200 Subject: [PATCH 2/4] make the workflow run on all pull requests --- .github/workflows/ci.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 17e72e3..89985e2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,10 +1,6 @@ name: Testing CI -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] +on: [pull_request] jobs: build: From a3344a34feef384a3ac4d267c68c8e711aff9e0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Biegun?= <69080338+Anakin100100@users.noreply.github.com> Date: Fri, 29 Apr 2022 09:53:13 +0200 Subject: [PATCH 3/4] make docker cache dependencies --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1b973a0..8b9b82f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,10 @@ FROM golang:1.18 as builder WORKDIR /app -COPY . . +COPY go.mod ./ +COPY go.sum ./ RUN go mod download +COPY . . RUN CGO_ENABLED=0 go build -o geralt FROM alpine:3.15 From 3c35fd305880fa30f4473dce941c068818f4fee0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Biegun?= <69080338+Anakin100100@users.noreply.github.com> Date: Fri, 29 Apr 2022 09:57:29 +0200 Subject: [PATCH 4/4] run on push to main branch and on pull requests --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 89985e2..17e72e3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,10 @@ name: Testing CI -on: [pull_request] +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] jobs: build: