Skip to content

Commit

Permalink
simplify docker image build locally
Browse files Browse the repository at this point in the history
  • Loading branch information
harshavardhana committed May 14, 2020
1 parent a732704 commit 9cc7f57
Show file tree
Hide file tree
Showing 4 changed files with 3,399 additions and 28 deletions.
4 changes: 3 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ project_name: minio-operator

before:
hooks:
# you may remove this if you don't use vgo
- go mod tidy
builds:
-
Expand All @@ -14,6 +13,8 @@ builds:
- amd64
env:
- CGO_ENABLED=0
ldflags:
- -s -w -X main.Version={{.Tag}}
flags:
- -trimpath
dockers:
Expand All @@ -29,3 +30,4 @@ dockers:
extra_files:
- LICENSE
- README.md
- ca-certificates.crt
26 changes: 2 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,8 @@
FROM golang:1.14

ADD go.mod /go/src/github.com/minio/minio-operator/go.mod
ADD go.sum /go/src/github.com/minio/minio-operator/go.sum
WORKDIR /go/src/github.com/minio/minio-operator/

# Get Certificates
RUN apt-get update -y && apt-get install -y ca-certificates

# Get dependencies - will also be cached if we won't change mod/sum
RUN go mod download

ADD . /go/src/github.com/minio/minio-operator/
WORKDIR /go/src/github.com/minio/minio-operator/

ENV CGO_ENABLED=0

ARG ldflags
ENV env_ldflags=$ldflags

RUN go build -ldflags "$env_ldflags" -a -o minio-operator .

FROM scratch

LABEL maintainer="MinIO Inc <[email protected]>"

COPY --from=0 /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=0 /go/src/github.com/minio/minio-operator/minio-operator .
COPY ca-certificates.crt /etc/ssl/certs/
COPY minio-operator /minio-operator

CMD ["/minio-operator"]
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ all: build

verify: govet gotest

build:
@docker build -t $(TAG) --build-arg ldflags=$(LDFLAGS) .
build: verify
@CGO_ENABLED=0 go build -trimpath --ldflags $(LDFLAGS)
@docker build -t $(TAG) .

install: all
@docker push $(TAG)

govet:
@CGO_ENABLED=0 go vet ./...
@go vet ./...

gotest:
@go test -race ./...
Loading

0 comments on commit 9cc7f57

Please sign in to comment.