From 7b404d8815420a80f800c932029657bf39e2fef5 Mon Sep 17 00:00:00 2001 From: Mahyar Mirrashed Date: Thu, 19 Dec 2024 21:42:46 -0600 Subject: [PATCH] build: add ability to run program in a docker container --- Dockerfile | 16 ++++++++++++++++ go.mod | 1 + go.sum | 2 ++ main.go | 5 ++++- 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cf600ca --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM golang:1.23-alpine3.21 AS builder + +WORKDIR /app + +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . + +RUN CGO_ENABLED=0 go build -o app + +FROM scratch + +COPY --from=builder /app/app /usr/local/bin/ + +ENTRYPOINT ["app"] diff --git a/go.mod b/go.mod index 5bae787..82076f9 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( github.com/rs/zerolog v1.33.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/vektah/gqlparser/v2 v2.5.11 // indirect + golang.org/x/crypto/x509roots/fallback v0.0.0-20241211175049-b4f1988a35de // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/sys v0.17.0 // indirect golang.org/x/tools v0.18.0 // indirect diff --git a/go.sum b/go.sum index 3cb9ce1..123a9d5 100644 --- a/go.sum +++ b/go.sum @@ -32,6 +32,8 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/vektah/gqlparser/v2 v2.5.11 h1:JJxLtXIoN7+3x6MBdtIP59TP1RANnY7pXOaDnADQSf8= github.com/vektah/gqlparser/v2 v2.5.11/go.mod h1:1rCcfwB2ekJofmluGWXMSEnPMZgbxzwj6FaZ/4OT8Cc= +golang.org/x/crypto/x509roots/fallback v0.0.0-20241211175049-b4f1988a35de h1:mWbGEbMwt3/D0JWUOEXf8GQAlCZP9midqxAnmQTH4To= +golang.org/x/crypto/x509roots/fallback v0.0.0-20241211175049-b4f1988a35de/go.mod h1:kNa9WdvYnzFwC79zRpLRMJbdEFlhyM5RPFBBZp/wWH8= golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/main.go b/main.go index 8c681be..f7b8f15 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,9 @@ package main -import "github.com/mahyarmirrashed/github-readme-stats/cmd" +import ( + "github.com/mahyarmirrashed/github-readme-stats/cmd" + _ "golang.org/x/crypto/x509roots/fallback" // CA bundle for FROM Scratch +) func main() { cmd.Execute()