From 18d5508c85d642a9699a21bdf19990f3a7d63a20 Mon Sep 17 00:00:00 2001 From: rachfop Date: Mon, 5 Dec 2022 23:27:13 -0800 Subject: [PATCH 1/2] Adds a dockerfile Signed-off-by: rachfop --- Dockerfile | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..519463d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +# Use the official Golang image to create a build artifact. +# This is based on Debian and sets the GOPATH to /go. +# https://hub.docker.com/_/golang +FROM golang:1.19 as builder + +# Set the current working directory inside the container. +WORKDIR /go/src/github.com/score-spec/score-compose + +# Copy the entire project and build it. +COPY . . +RUN go build -o /usr/local/bin/score-compose ./cmd/score-compose + +# Use the official Alpine image for a lean production container. +# https://hub.docker.com/_/alpine +# https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds +FROM alpine:3 + +# Set the current working directory inside the container. +WORKDIR /score-compose + +# Copy the binary from the builder image. +COPY --from=builder /usr/local/bin/score-compose /usr/local/bin/score-compose + +# Run the binary. +ENTRYPOINT ["/usr/local/bin/score-compose"] From b6ce1997c2336db574a5a1f3c3d1ebb7011b6491 Mon Sep 17 00:00:00 2001 From: Nils Balkow-Tychsen Date: Wed, 14 Dec 2022 14:25:15 +0100 Subject: [PATCH 2/2] go dependencies in alpine (#23) --- Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 519463d..3f1001b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,12 +3,15 @@ # https://hub.docker.com/_/golang FROM golang:1.19 as builder +# https://stackoverflow.com/questions/36279253/go-compiled-binary-wont-run-in-an-alpine-docker-container-on-ubuntu-host +ENV CGO_ENABLED=0 + # Set the current working directory inside the container. WORKDIR /go/src/github.com/score-spec/score-compose # Copy the entire project and build it. COPY . . -RUN go build -o /usr/local/bin/score-compose ./cmd/score-compose +RUN GOOS=linux GOARCH=amd64 go build -o /usr/local/bin/score-compose ./cmd/score-compose # Use the official Alpine image for a lean production container. # https://hub.docker.com/_/alpine