mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-22 01:41:02 +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
|
||||
|
||||
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" )
|
||||
ifeq ($(HAS_GO), GO)
|
||||
ifeq ($(HAS_GO),GO)
|
||||
XGO_VERSION ?= go-1.18.x
|
||||
CGO_CFLAGS ?= $(shell $(GO) env CGO_CFLAGS)
|
||||
CGO_CFLAGS ?= $(shell go env CGO_CFLAGS)
|
||||
endif
|
||||
CGO_CFLAGS ?=
|
||||
|
||||
# If the first argument is "in_docker"...
|
||||
ifeq (in_docker,$(firstword $(MAKECMDGOALS)))
|
||||
|
@ -45,6 +46,9 @@ ifeq (in_docker,$(firstword $(MAKECMDGOALS)))
|
|||
-e GO_PACKAGES="$(GO_PACKAGES)" \
|
||||
-e TARGETOS="$(TARGETOS)" \
|
||||
-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)
|
||||
else
|
||||
|
||||
|
@ -154,7 +158,7 @@ build-ui: ## Build UI
|
|||
(cd web/; pnpm install --frozen-lockfile; pnpm build)
|
||||
|
||||
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
|
||||
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
|
||||
# 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 -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 .
|
||||
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.
|
||||
COPY --from=golang_image /usr/local/go /usr/local/go
|
||||
|
|
Loading…
Reference in a new issue