Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify local docker build #45

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
vendor/
dist/
docker-compose.override.yml
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions docker-compose.local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: "3"

services:
app:
build:
dockerfile: docker/local/Dockerfile
context: .
image: pottava/s3-proxy:local
20 changes: 20 additions & 0 deletions docker/local/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]