Skip to content

Commit

Permalink
Merge pull request #385 from williepaul/disable-cgo-in-dockerfile
Browse files Browse the repository at this point in the history
fixes dockerfile build issues
  • Loading branch information
Cesar Rodriguez authored Nov 17, 2020
2 parents 25d5b56 + 04be644 commit 62a3549
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null)
BUILD_FLAGS := -v -ldflags "-w -s"
ENV_SETTINGS := CGO_ENABLED=0

BUILD_DIR = ./bin
BINARY_NAME = terrascan
Expand Down Expand Up @@ -30,7 +31,7 @@ help:
build: clean
@mkdir -p $(BUILD_DIR) > /dev/null
@export GO111MODULE=on
go build ${BUILD_FLAGS} -o ${BUILD_DIR}/${BINARY_NAME} cmd/terrascan/main.go
${ENV_SETTINGS} go build ${BUILD_FLAGS} -o ${BUILD_DIR}/${BINARY_NAME} cmd/terrascan/main.go
@echo "binary created at ${BUILD_DIR}/${BINARY_NAME}"


Expand Down
5 changes: 3 additions & 2 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
FROM golang:alpine AS builder

ARG GOOS_VAL=linux
ARG GOARCH=amd64
ARG GOARCH_VAL=amd64
ARG CGO_ENABLED_VAL=0

WORKDIR $GOPATH/src/terrascan

Expand All @@ -14,7 +15,7 @@ RUN go mod download
COPY . .

# build binary
RUN GOOS=${GOOS_VAL} GOARCH=${GOARCH_VAL} go build -v -ldflags "-w -s" -o /go/bin/terrascan ./cmd/terrascan
RUN CGO_ENABLED=${CGO_ENABLED_VAL} GOOS=${GOOS_VAL} GOARCH=${GOARCH_VAL} go build -v -ldflags "-w -s" -o /go/bin/terrascan ./cmd/terrascan


# -------- prod stage -------- #
Expand Down

0 comments on commit 62a3549

Please sign in to comment.