diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4a896de --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +vendor/ +dist/ +docker-compose.override.yml diff --git a/Makefile b/Makefile index c93de4a..c93fdad 100644 --- a/Makefile +++ b/Makefile @@ -31,3 +31,6 @@ build: -w /go/src/github.com/pottava/aws-s3-proxy \ supinf/go-gox:1.11 --osarch "linux/amd64 darwin/amd64 windows/amd64" \ -ldflags "-s -w" -output "dist/{{.OS}}_{{.Arch}}" + +build-local: + @docker-compose -f docker-compose.local.yml build diff --git a/docker-compose.local.yml b/docker-compose.local.yml new file mode 100644 index 0000000..005cb4b --- /dev/null +++ b/docker-compose.local.yml @@ -0,0 +1,8 @@ +version: "3" + +services: + app: + build: + dockerfile: docker/local/Dockerfile + context: . + image: pottava/s3-proxy:local diff --git a/docker/local/Dockerfile b/docker/local/Dockerfile new file mode 100644 index 0000000..be7d134 --- /dev/null +++ b/docker/local/Dockerfile @@ -0,0 +1,20 @@ +FROM golang:1.13.7-alpine3.11 AS builder +RUN apk --no-cache add gcc musl-dev git +WORKDIR /go/src/github.com/pottava/aws-s3-proxy +COPY . . +ARG APP_VERSION=local +RUN go mod download +RUN go mod verify +RUN githash=$(git rev-parse --short HEAD 2>/dev/null) \ + && today=$(date +%Y-%m-%d --utc) \ + && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \ + -ldflags "-s -w -X main.ver=${APP_VERSION} -X main.commit=${githash} -X main.date=${today}" \ + -o /app + +FROM alpine:3.11 AS libs +RUN apk --no-cache add ca-certificates + +FROM scratch +COPY --from=libs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ +COPY --from=builder /app /aws-s3-proxy +ENTRYPOINT ["/aws-s3-proxy"]