Skip to content

Commit

Permalink
Enable CGO (#68)
Browse files Browse the repository at this point in the history
* enable cgo

Signed-off-by: zhujian <jiazhu@redhat.com>

* change golang base image to bullseye

Signed-off-by: zhujian <jiazhu@redhat.com>

---------

Signed-off-by: zhujian <jiazhu@redhat.com>
  • Loading branch information
zhujian7 committed Jul 11, 2023
1 parent 8f502e9 commit 0bf2b87
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
12 changes: 5 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
FROM golang:1.19 AS builder
FROM golang:1.19-bullseye AS builder
WORKDIR /go/src/github.com/open-cluster-management.io/managed-serviceaccount
COPY . .
ENV GO_PACKAGE github.com/open-cluster-management.io/managed-serviceaccount
ENV GOFLAGS ""
RUN go env
RUN go build -a -o manager cmd/manager/main.go
RUN go build -a -o agent cmd/agent/main.go
RUN make build-manager
RUN make build-agent

FROM registry.access.redhat.com/ubi8/ubi-minimal:latest
COPY --from=builder /go/src/github.com/open-cluster-management.io/managed-serviceaccount/manager /
COPY --from=builder /go/src/github.com/open-cluster-management.io/managed-serviceaccount/agent /
COPY --from=builder /go/src/github.com/open-cluster-management.io/managed-serviceaccount/bin/manager /
COPY --from=builder /go/src/github.com/open-cluster-management.io/managed-serviceaccount/bin/agent /
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ else
GOBIN=$(shell go env GOBIN)
endif

export CGO_ENABLED = 1
export GOFLAGS ?=

# Setting SHELL to bash allows bash commands to be executed by recipes.
# This is a requirement for 'setup-envtest.sh' in the test target.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
Expand Down Expand Up @@ -60,9 +63,13 @@ test: manifests generate fmt vet ## Run tests.

##@ Build

build: generate fmt vet ## Build manager binary.
go build -o bin/manager cmd/manager/main.go
go build -o bin/agent cmd/agent/main.go
build: generate fmt vet build-manager build-agent

build-manager:
go build -a -o bin/manager cmd/manager/main.go

build-agent:
go build -a -o bin/agent cmd/agent/main.go

build-e2e:
go test -c -o bin/e2e ./e2e/
Expand Down

0 comments on commit 0bf2b87

Please sign in to comment.