mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-25 19:31:05 +00:00
Makefile tweaks (#1410)
make CGO optional and fix a bug Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
parent
cbe74dee34
commit
e7c8ed00e6
2 changed files with 12 additions and 7 deletions
14
Makefile
14
Makefile
|
@ -19,13 +19,14 @@ ifeq ($(BUILD_VERSION),next)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
LDFLAGS := -s -w -extldflags "-static" -X github.com/woodpecker-ci/woodpecker/version.Version=${BUILD_VERSION}
|
LDFLAGS := -s -w -extldflags "-static" -X github.com/woodpecker-ci/woodpecker/version.Version=${BUILD_VERSION}
|
||||||
CGO_CFLAGS ?=
|
CGO_ENABLED ?= 1 # only used to compile server
|
||||||
|
|
||||||
HAS_GO = $(shell hash go > /dev/null 2>&1 && echo "GO" || echo "NOGO" )
|
HAS_GO = $(shell hash go > /dev/null 2>&1 && echo "GO" || echo "NOGO" )
|
||||||
ifeq ($(HAS_GO), GO)
|
ifeq ($(HAS_GO),GO)
|
||||||
XGO_VERSION ?= go-1.18.x
|
XGO_VERSION ?= go-1.18.x
|
||||||
CGO_CFLAGS ?= $(shell $(GO) env CGO_CFLAGS)
|
CGO_CFLAGS ?= $(shell go env CGO_CFLAGS)
|
||||||
endif
|
endif
|
||||||
|
CGO_CFLAGS ?=
|
||||||
|
|
||||||
# If the first argument is "in_docker"...
|
# If the first argument is "in_docker"...
|
||||||
ifeq (in_docker,$(firstword $(MAKECMDGOALS)))
|
ifeq (in_docker,$(firstword $(MAKECMDGOALS)))
|
||||||
|
@ -45,6 +46,9 @@ ifeq (in_docker,$(firstword $(MAKECMDGOALS)))
|
||||||
-e GO_PACKAGES="$(GO_PACKAGES)" \
|
-e GO_PACKAGES="$(GO_PACKAGES)" \
|
||||||
-e TARGETOS="$(TARGETOS)" \
|
-e TARGETOS="$(TARGETOS)" \
|
||||||
-e TARGETARCH="$(TARGETARCH)" \
|
-e TARGETARCH="$(TARGETARCH)" \
|
||||||
|
-e CGO_ENABLED="$(CGO_ENABLED)"
|
||||||
|
-e GOPATH=/tmp/go \
|
||||||
|
-e HOME=/tmp/home \
|
||||||
-v $(PWD):/build --rm woodpecker/make:local make $(MAKE_ARGS)
|
-v $(PWD):/build --rm woodpecker/make:local make $(MAKE_ARGS)
|
||||||
else
|
else
|
||||||
|
|
||||||
|
@ -154,7 +158,7 @@ build-ui: ## Build UI
|
||||||
(cd web/; pnpm install --frozen-lockfile; pnpm build)
|
(cd web/; pnpm install --frozen-lockfile; pnpm build)
|
||||||
|
|
||||||
build-server: build-ui ## Build server
|
build-server: build-ui ## Build server
|
||||||
CGO_ENABLED=1 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags '${LDFLAGS}' -o dist/woodpecker-server github.com/woodpecker-ci/woodpecker/cmd/server
|
CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags '${LDFLAGS}' -o dist/woodpecker-server github.com/woodpecker-ci/woodpecker/cmd/server
|
||||||
|
|
||||||
build-agent: ## Build agent
|
build-agent: ## Build agent
|
||||||
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags '${LDFLAGS}' -o dist/woodpecker-agent github.com/woodpecker-ci/woodpecker/cmd/agent
|
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags '${LDFLAGS}' -o dist/woodpecker-agent github.com/woodpecker-ci/woodpecker/cmd/agent
|
||||||
|
@ -188,7 +192,7 @@ release-server-xgo: check-xgo ## Create server binaries for release using xgo
|
||||||
|
|
||||||
release-server: ## Create server binaries for release
|
release-server: ## Create server binaries for release
|
||||||
# compile
|
# compile
|
||||||
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -ldflags '${LDFLAGS}' -o dist/server/linux_amd64/woodpecker-server github.com/woodpecker-ci/woodpecker/cmd/server
|
GOOS=linux GOARCH=amd64 CGO_ENABLED=${CGO_ENABLED} go build -ldflags '${LDFLAGS}' -o dist/server/linux_amd64/woodpecker-server github.com/woodpecker-ci/woodpecker/cmd/server
|
||||||
# tar binary files
|
# tar binary files
|
||||||
tar -cvzf dist/woodpecker-server_linux_amd64.tar.gz -C dist/server/linux_amd64 woodpecker-server
|
tar -cvzf dist/woodpecker-server_linux_amd64.tar.gz -C dist/server/linux_amd64 woodpecker-server
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
# docker build --rm -f docker/Dockerfile.server -t woodpeckerci/woodpecker-server .
|
# docker build --rm -f docker/Dockerfile.server -t woodpeckerci/woodpecker-server .
|
||||||
FROM golang:1.18-alpine as golang_image
|
FROM golang:1.18-alpine as golang_image
|
||||||
FROM node:16-alpine
|
FROM node:18-alpine
|
||||||
|
|
||||||
RUN apk add make gcc musl-dev
|
RUN apk add --no-cache --update make gcc binutils-gold musl-dev && \
|
||||||
|
corepack enable
|
||||||
|
|
||||||
# Build packages.
|
# Build packages.
|
||||||
COPY --from=golang_image /usr/local/go /usr/local/go
|
COPY --from=golang_image /usr/local/go /usr/local/go
|
||||||
|
|
Loading…
Reference in a new issue