From 18cbbcf77b2f1ca776328b8f24ab9970253b59e0 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 13 Apr 2021 09:33:58 -0500 Subject: [PATCH] build docker properly --- .dockerignore | 1 + Dockerfile | 5 ++--- Makefile | 11 ++++++++++- go.mod | 1 + go.sum | 2 ++ 5 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..cf70988 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +**/node_modules diff --git a/Dockerfile b/Dockerfile index ae5d865..80968fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,6 @@ ARG GO_VERSION=1.16 FROM golang:${GO_VERSION}-alpine AS builder # Git is required for fetching the dependencies. -RUN go env -w GOPROXY=direct RUN apk add --no-cache git RUN apk add ca-certificates @@ -15,13 +14,13 @@ WORKDIR /src # Fetch dependencies first; they are less susceptible to change on every build # and will therefore be cached for speeding up the next build COPY ./go.mod ./go.sum ./ -RUN go mod download +RUN GO111MODULE=on go mod download # Import the code from the context. COPY ./ ./ # Build the executable to `/app`. Mark the build as statically linked. -RUN CGO_ENABLED=0 go build \ +RUN GO111MODULE=on CGO_ENABLED=0 go build \ -installsuffix 'static' \ -o /app . diff --git a/Makefile b/Makefile index b6877a2..4d52fda 100644 --- a/Makefile +++ b/Makefile @@ -5,4 +5,13 @@ protos: proto/faucet/faucet.proto protoc -Iproto --go_out=proto --go_opt=paths=source_relative \ --go-grpc_out=proto --go-grpc_opt=paths=source_relative \ - proto/faucet/faucet.proto \ No newline at end of file + proto/faucet/faucet.proto +release: + env GOOS=darwin GOARCH=amd64 go build -o ./dist/faucet-v1.0.1-darwin-amd64 . + env GOOS=windows GOARCH=amd64 go build -o ./dist/faucet-v1.0.1-windows-amd64 . + env GOOS=linux GOARCH=amd64 go build -o ./dist/faucet-v1.0.1-linux-amd64 . + env GOOS=linux GOARCH=arm64 go build -o ./dist/faucet-v1.0.1-linux-amd64 . + shasum ./dist/faucet-v1.0.1-windows-amd64 > ./dist/faucet-v1.0.1-darwin-amd64.sha256 + shasum ./dist/faucet-v1.0.1-darwin-amd64 > ./dist/faucet-v1.0.1-darwin-amd64.sha256 + shasum ./dist/faucet-v1.0.1-linux-amd64 > ./dist/faucet-v1.0.1-darwin-amd64.sha256 + shasum ./dist/faucet-v1.0.1-darwin-arm64 > ./dist/faucet-v1.0.1-darwin-arm64.sha256 diff --git a/go.mod b/go.mod index f92d677..f2de35f 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,7 @@ require ( github.com/prestonvanloon/go-recaptcha v0.0.0-20190217191114-0834cef6e8bd github.com/rauljordan/minimal-grpc-gateway v0.0.0-20201017192135-199fa853d2e0 github.com/sirupsen/logrus v1.7.0 + github.com/spf13/afero v1.1.2 // indirect github.com/spf13/cobra v1.1.3 github.com/spf13/viper v1.7.1 google.golang.org/genproto v0.0.0-20201015140912-32ed001d685c diff --git a/go.sum b/go.sum index 34d8d14..e964db8 100644 --- a/go.sum +++ b/go.sum @@ -615,6 +615,7 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202 h1:VvcQYSHwXgi7W+TpUR6A9g6Up98WAHf3f/ulnJ62IyA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20210220033124-5f55cee0dc0d h1:1aflnvSoWWLI2k/dMUAl5lvU1YO4Mb4hz0gh+1rjcxU= golang.org/x/net v0.0.0-20210220033124-5f55cee0dc0d/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -683,6 +684,7 @@ golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3 golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=