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

Add support for building in docker #759

Merged
merged 13 commits into from
Feb 10, 2022
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# If the first argument is "in_docker"...
ifeq (in_docker,$(firstword $(MAKECMDGOALS)))
# use the rest as arguments for "in_docker"
MAKE_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
# Ignore the next args
$(eval $(MAKE_ARGS):;@:)

.ONESHELL:
in_docker:
docker build -f ./docker/Dockerfile.make -t woodpecker/make:local .
docker run -it \
-e VERSION="$(VERSION)" \
6543 marked this conversation as resolved.
Show resolved Hide resolved
6543 marked this conversation as resolved.
Show resolved Hide resolved
-e CI_COMMIT_SHA="$(CI_COMMIT_SHA)" \
-e GO_PACKAGES="$(GO_PACKAGES)" \
-e TARGETOS="$(TARGETOS)" \
-e TARGETARCH="$(TARGETARCH)" \
-v $(PWD):/build --rm woodpecker/make:local make $(MAKE_ARGS)
else

# Proceed with normal make

GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./.git/*")
GO_PACKAGES ?= $(shell go list ./... | grep -v /vendor/)

Expand Down Expand Up @@ -155,3 +176,5 @@ bundle: bundle-agent bundle-server bundle-cli
.PHONY: version
version:
@echo ${BUILD_VERSION}

endif
13 changes: 13 additions & 0 deletions docker/Dockerfile.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# docker build --rm -f docker/Dockerfile.server -t woodpeckerci/woodpecker-server .
FROM golang:1.16-alpine as golang_image
FROM node:16-alpine

RUN apk add make gcc musl-dev

# Build packages.
COPY --from=golang_image /usr/local/go /usr/local/go
ENV PATH=$PATH:/usr/local/go/bin

WORKDIR /build

CMD [ "sh" ]