From c339a9c33efc960f6bcd82e78d6b95eadbf49d99 Mon Sep 17 00:00:00 2001 From: n0l3p <4n4kn0l3p@gmail.com> Date: Mon, 4 Dec 2023 16:06:55 +0700 Subject: [PATCH] update go ci attempt --- .github/workflows/ci.yml | 12 ++++++++---- Dockerfile | 40 ++++++++++++++++++++-------------------- go.mod | 4 +--- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c83d8a6..7adf8c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,8 +49,11 @@ jobs: name: runner / check-dependencies runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v4 + with: + go-version: '1.21.4' + check-latest: true - name: WriteGoList run: go list -json -m all > go.list - name: Nancy @@ -62,9 +65,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-go@v2 + - uses: actions/setup-go@v4 with: - go-version: 1.21.x + go-version: '1.21.4' + check-latest: true - name: Unit Tests run: "go test \ diff --git a/Dockerfile b/Dockerfile index 8ac5a05..be92c2f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,21 @@ -# Step 1: Modules caching -FROM golang:alpine as modules -COPY go.mod go.sum /modules/ -WORKDIR /modules -RUN go mod download - -# Step 2: Builder -FROM golang:alpine as builder -COPY --from=modules /go/pkg /go/pkg -COPY . /app -WORKDIR /app -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \ - go build -tags migrate -o /bin/app ./cmd/app - -# Step 3: Final -FROM scratch -COPY --from=builder /app/config /config -COPY --from=builder /app/migrations /migrations -COPY --from=builder /bin/app /app -COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ +# Step 1: Modules caching +FROM golang:alpine as modules +COPY go.mod go.sum /modules/ +WORKDIR /modules +RUN go mod download + +# Step 2: Builder +FROM golang:alpine as builder +COPY --from=modules /go/pkg /go/pkg +COPY . /app +WORKDIR /app +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \ + go build -tags migrate -o /bin/app ./cmd/app + +# Step 3: Final +FROM alpine +COPY --from=builder /app/config /config +COPY --from=builder /app/migrations /migrations +COPY --from=builder /bin/app /app +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ CMD ["/app"] \ No newline at end of file diff --git a/go.mod b/go.mod index d1a8282..d136757 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module go-clean-template -go 1.21 - -toolchain go1.21.4 +go 1.21.4 require ( github.com/Conight/go-googletrans v0.2.4