forked from bufbuild/buf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
118 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,17 @@ | ||
FROM golang:1.13.3-alpine3.10 | ||
ARG DOCKER_WORKSPACE_IMAGE | ||
|
||
ENV \ | ||
CACHE_BASE=/cache/buf \ | ||
GO111MODULE=on \ | ||
GOPRIVATE=github.com/bufbuild/buf \ | ||
GOPATH=/cache/buf/Linux/x86_64/go \ | ||
GOBIN=/cache/buf/Linux/x86_64/bin \ | ||
PATH=/cache/buf/Linux/x86_64/bin:${PATH} | ||
FROM $DOCKER_WORKSPACE_IMAGE as builder | ||
|
||
WORKDIR /workspace | ||
COPY cmd ./cmd | ||
COPY internal ./internal | ||
RUN go build -o /go/bin/buf ./cmd/buf | ||
|
||
FROM alpine:3.10 | ||
|
||
RUN apk add --update --no-cache \ | ||
bash \ | ||
build-base \ | ||
ca-certificates \ | ||
curl \ | ||
git \ | ||
unzip \ | ||
wget && \ | ||
ca-certificates && \ | ||
rm -rf /var/cache/apk/* | ||
|
||
RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \ | ||
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.30-r0/glibc-2.30-r0.apk && \ | ||
apk add --no-cache glibc-2.30-r0.apk && \ | ||
rm -rf /var/cache/apk/* | ||
COPY --from=builder /go/bin/buf /usr/local/bin/buf | ||
|
||
COPY go.mod go.sum /workspace/ | ||
RUN go mod download | ||
COPY make /workspace/make | ||
Copy Makefile /workspace/ | ||
RUN make deps | ||
ENTRYPOINT ["/usr/local/bin/buf"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
ARG PROJECT | ||
ARG GO_MODULE | ||
|
||
FROM golang:1.13.3-alpine3.10 | ||
|
||
ENV \ | ||
CACHE_BASE=/cache/$PROJECT \ | ||
GO111MODULE=on \ | ||
GOPRIVATE=$GO_MODULE \ | ||
GOPATH=/cache/$PROJECT/Linux/x86_64/go \ | ||
GOBIN=/cache/$PROJECT/Linux/x86_64/bin \ | ||
PATH=/cache/$PROJECT/Linux/x86_64/bin:${PATH} | ||
|
||
WORKDIR /workspace | ||
|
||
RUN apk add --update --no-cache \ | ||
bash \ | ||
build-base \ | ||
ca-certificates \ | ||
curl \ | ||
git \ | ||
unzip \ | ||
wget && \ | ||
rm -rf /var/cache/apk/* | ||
|
||
RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \ | ||
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.30-r0/glibc-2.30-r0.apk && \ | ||
apk add --no-cache glibc-2.30-r0.apk && \ | ||
rm -rf /var/cache/apk/* | ||
|
||
COPY go.mod go.sum /workspace/ | ||
RUN go mod download | ||
COPY make /workspace/make | ||
Copy Makefile /workspace/ | ||
RUN make deps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,48 @@ | ||
ifndef DOCKER_IMAGE | ||
$(error DOCKER_IMAGE is not set) | ||
ifndef DOCKER_ORG | ||
$(error DOCKER_ORG is not set) | ||
endif | ||
ifndef DOCKER_FILE | ||
$(error DOCKER_FILE is not set) | ||
ifndef DOCKER_PROJECT | ||
$(error DOCKER_PROJECT is not set) | ||
endif | ||
ifndef DOCKER_DIR | ||
$(error DOCKER_DIR is not set) | ||
ifndef PROJECT | ||
$(error PROJECT is not set) | ||
endif | ||
ifndef GO_MODULE | ||
$(error GO_MODULE is not set) | ||
endif | ||
|
||
DOCKER_WORKSPACE_IMAGE := $(DOCKER_ORG)/$(DOCKER_PROJECT)-workspace | ||
DOCKER_WORKSPACE_FILE := Dockerfile.workspace | ||
DOCKER_WORKSPACE_DIR := /workspace | ||
|
||
DOCKER_BINS ?= | ||
|
||
.PHONY: dockerbuildworkspace | ||
dockerbuildworkspace: | ||
docker build \ | ||
--build-arg PROJECT=$(PROJECT) \ | ||
--build-arg GO_MODULE=$(GO_MODULE) \ | ||
-t $(DOCKER_WORKSPACE_IMAGE) \ | ||
-f $(DOCKER_WORKSPACE_FILE) \ | ||
. | ||
|
||
.PHONY: dockermakeworkspace | ||
dockermakeworkspace: dockerbuildworkspace | ||
docker run -v "$(CURDIR):$(DOCKER_WORKSPACE_DIR)" $(DOCKER_WORKSPACE_IMAGE) make -j 8 | ||
|
||
.PHONY: dockerbuild | ||
dockerbuild: | ||
docker build -t $(DOCKER_IMAGE) -f $(DOCKER_FILE) . | ||
dockerbuild:: | ||
|
||
define dockerbinfunc | ||
.PHONY: dockerbuild$(1) | ||
dockerbuild$(1): dockerbuildworkspace | ||
docker build \ | ||
--build-arg DOCKER_WORKSPACE_IMAGE=$(DOCKER_WORKSPACE_IMAGE) \ | ||
-t $(DOCKER_ORG)/$(1) \ | ||
-f Dockerfile.$(1) \ | ||
. | ||
|
||
dockerbuild:: dockerbuild$(1) | ||
endef | ||
|
||
.PHONY: dockermake | ||
dockermake: dockerbuild | ||
docker run -v "$(CURDIR):$(DOCKER_DIR)" $(DOCKER_IMAGE) make -j 8 | ||
$(foreach dockerbin,$(DOCKER_BINS),$(eval $(call dockerbinfunc,$(dockerbin)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters