From 144d0f44604beb1a10c9f79e34e9aaf7df31df76 Mon Sep 17 00:00:00 2001 From: kahootali Date: Thu, 2 Nov 2023 03:34:16 +0500 Subject: [PATCH] update dockerfile and pipeline to use go mod --- .github/workflows/cd.yml | 2 +- .github/workflows/ci.yml | 2 +- Dockerfile | 11 ++++++----- go.mod | 8 ++++++++ go.sum | 5 +++++ 5 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 go.mod create mode 100644 go.sum diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index ded315d..f321756 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -27,7 +27,7 @@ jobs: - name: Build Code run: | - go get github.com/thedevsaddam/renderer/... + go mod download go build -v . - name: Generate Version diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 53eea0c..6f594e1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: - name: Build Code run: | - go get github.com/thedevsaddam/renderer/... + go mod download go build -v . - name: Initialize Pipeline diff --git a/Dockerfile b/Dockerfile index ff47e77..3b61d70 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,11 @@ FROM golang:1.20 as build WORKDIR /app -RUN go env -w GO111MODULE=auto -RUN go get github.com/thedevsaddam/renderer/... +COPY go.mod go.sum . +RUN go mod download COPY main.go . -RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build main.go +COPY tpl ./tpl/ +RUN CGO_ENABLED=0 go build main.go FROM alpine @@ -14,6 +15,6 @@ LABEL name="Golang Application" \ summary="A Golang Sample application" WORKDIR /app EXPOSE 8080 -COPY --from=build ./app/main ./ -COPY ./tpl ./tpl +COPY --from=build /app/main ./ +COPY --from=build /app/tpl ./tpl CMD ["./main"] \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..2b55990 --- /dev/null +++ b/go.mod @@ -0,0 +1,8 @@ +module github.com/kahootali/golang-sample-app + +go 1.20 + +require ( + github.com/thedevsaddam/renderer v1.2.0 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..3930f34 --- /dev/null +++ b/go.sum @@ -0,0 +1,5 @@ +github.com/thedevsaddam/renderer v1.2.0 h1:+N0J8t/s2uU2RxX2sZqq5NbaQhjwBjfovMU28ifX2F4= +github.com/thedevsaddam/renderer v1.2.0/go.mod h1:k/TdZXGcpCpHE/KNj//P2COcmYEfL8OV+IXDX0dvG+U= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=