Skip to content

Commit

Permalink
propagate env var from github action
Browse files Browse the repository at this point in the history
  • Loading branch information
burdzwastaken committed Mar 26, 2024
1 parent 81a3599 commit d37aedd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ jobs:
context: .
push: false
tags: pgweb:latest
platforms: linux/amd64,linux/arm64,linux/arm/v5,linux/arm/v7
platforms: linux/amd64,linux/arm64,linux/arm/v7
build-args: |
"CGO_ENABLED=${{ env.CGO_ENABLED }}"
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
# ------------------------------------------------------------------------------
FROM golang:1.20-bullseye AS build

# Set default build argument for CGO_ENABLED=0. This can be overriden by build-args
ARG CGO_ENABLED=0
ENV CGO_ENABLED ${CGO_ENABLED}

WORKDIR /build

RUN git config --global --add safe.directory /build
Expand All @@ -12,7 +16,7 @@ COPY Makefile main.go ./
COPY static/ static/
COPY pkg/ pkg/
COPY .git/ .
RUN make build STATIC=true
RUN make build

# ------------------------------------------------------------------------------
# Fetch signing key
Expand Down
10 changes: 3 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ LDFLAGS += -X $(PKG)/pkg/command.GitCommit=$(GIT_COMMIT)
LDFLAGS += -X $(PKG)/pkg/command.BuildTime=$(BUILD_TIME)
LDFLAGS += -X $(PKG)/pkg/command.GoVersion=$(GO_VERSION)

ifeq ($(STATIC), true)
CGO_ENABLED = 0
endif

usage:
@echo ""
@echo "Task : Description"
Expand Down Expand Up @@ -46,16 +42,16 @@ dev:
@echo "You can now execute ./pgweb"

build:
CGO_ENABLED=$(CGO_ENABLED) go build -ldflags '${LDFLAGS}'
go build -ldflags '${LDFLAGS}'
@echo "You can now execute ./pgweb"

install:
CGO_ENABLED=$(CGO_ENABLED) go install -ldflags '${LDFLAGS}'
go install -ldflags '${LDFLAGS}'
@echo "You can now execute pgweb"

release: clean
@echo "Building binaries..."
@CGO_ENABLED=$(CGO_ENABLED) LDFLAGS='${LDFLAGS}' ./script/build_all.sh
@LDFLAGS='${LDFLAGS}' ./script/build_all.sh

clean:
@echo "Removing all artifacts"
Expand Down

0 comments on commit d37aedd

Please sign in to comment.