From bac001a5c2d2b699f98360619fc0ddbdce29c732 Mon Sep 17 00:00:00 2001 From: Alexandre Date: Thu, 4 Jan 2024 20:36:26 +0100 Subject: [PATCH] Initial commit --- Dockerfile | 24 ++++++++++++++++++++++++ go.mod | 8 ++++++++ go.sum | 4 ++++ main.go | 12 ++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 Dockerfile create mode 100644 go.mod create mode 100644 go.sum create mode 100644 main.go diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..eb0616b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM golang:1.21 AS builder +ENV GO111MODULE=on \ + CGO_ENABLED=0 \ + GOOS=linux \ + GOARCH=amd64 +WORKDIR /src +COPY . . +RUN go build \ + -ldflags "-s -w -extldflags '-static'" \ + -o /bin/app \ + . +RUN echo "nobody:x:65534:65534:Nobody:/:" > /etc_passwd + +FROM alpine:3.19 as compressor +RUN apk add --no-cache upx binutils +COPY --from=builder --chown=65534:0 /bin/app /app +RUN strip /app && upx -q -9 /app + +FROM scratch +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ +COPY --from=builder /etc_passwd /etc/passwd +COPY --from=compressor --chown=65534:0 /app /app +USER nobody +ENTRYPOINT ["/app"] diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..a82e968 --- /dev/null +++ b/go.mod @@ -0,0 +1,8 @@ +module gitea.bruyant.xyz/alexandre/ipfs-node-pin + +go 1.21.5 + +require ( + github.com/sethvargo/go-envconfig v0.9.0 // indirect + github.com/sethvargo/go-githubactions v1.1.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..757224e --- /dev/null +++ b/go.sum @@ -0,0 +1,4 @@ +github.com/sethvargo/go-envconfig v0.9.0 h1:Q6FQ6hVEeTECULvkJZakq3dZMeBQ3JUpcKMfPQbKMDE= +github.com/sethvargo/go-envconfig v0.9.0/go.mod h1:Iz1Gy1Sf3T64TQlJSvee81qDhf7YIlt8GMUX6yyNFs0= +github.com/sethvargo/go-githubactions v1.1.0 h1:mg03w+b+/s5SMS298/2G6tHv8P0w0VhUFaqL1THIqzY= +github.com/sethvargo/go-githubactions v1.1.0/go.mod h1:qIboSF7yq2Qnaw2WXDsqCReM0Lo1gU4QXUWmhBC3pxE= diff --git a/main.go b/main.go new file mode 100644 index 0000000..e3162fb --- /dev/null +++ b/main.go @@ -0,0 +1,12 @@ +package main + +import ( + "github.com/sethvargo/go-githubactions" +) + +func main() { + path := githubactions.GetInput("path_to_add") + if path == "" { + githubactions.Fatalf("Missing: path_to_add") + } +}