Skip to content

Commit

Permalink
chore: enable cgo (#2039)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs47 authored Dec 2, 2023
1 parent 3baba1f commit 03bade6
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 86 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/build-docker-image-and-binaries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ on:
description: Github tag to release binaries for (reusing an existing tag will make the pipeline fail)
required: true
default: latest

cgo:
description: Whether to enable cgo ("true"/"false")
required: true
default: "true"
wasm:
description: Whether to enable wasm ("true"/"false")
required: true
default: "true"
jobs:
release-binaries:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -64,7 +71,12 @@ jobs:
ARCH: ${{ matrix.arch }}
OS_TYPE: ${{ matrix.os }}
SEMVER: ${{ github.event.inputs.tag }}
WASM: ${{ github.event.inputs.WASM }}
CGO_ENABLED: 0
run: |
if [ "${{ github.event.inputs.cgo }}" == "true" ]; then
export CGO_ENABLED=1
fi
OS=$(echo "$OS_TYPE" | sed -e 's/ubuntu-20.04/linux/; s/macos-latest/darwin/')
make build-binaries-multiarch
mv ./bin/axelard ./bin/axelard-"$OS"-"$ARCH"-"$SEMVER"
Expand Down Expand Up @@ -166,10 +178,15 @@ jobs:

- name: Build and push docker images
run: |
if [ "${{ github.event.inputs.cgo }}" == "true" ]; then
export CGO_ENABLED=1
fi
make build-push-docker-images
env:
PLATFORM: ${{ matrix.platform }}
SEMVER: ${{ github.event.inputs.tag }}
WASM: ${{ github.event.inputs.wasm }}
CGO_ENABLED: 0

combine-sign:

Expand Down
72 changes: 0 additions & 72 deletions .github/workflows/build-docker-image-rosetta.yaml

This file was deleted.

22 changes: 17 additions & 5 deletions .github/workflows/build-latest-docker-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ on:
description: Whether or build the debug image ("true"/"false")
required: true
default: "false"
cgo:
description: Whether to enable cgo ("true"/"false")
required: true
default: "true"
wasm:
description: Whether to enable wasm ("true"/"false")
required: true
default: "false"
default: "true"

jobs:
build-and-push-latest-docker-image:
Expand Down Expand Up @@ -47,9 +51,13 @@ jobs:

- name: Build docker image (normal)
env:
WASM: ${{ github.event.inputs.WASM }}
WASM: ${{ github.event.inputs.wasm }}
CGO_ENABLED: 0
run: |
make WASM="${WASM}" docker-image
if [ "${{ github.event.inputs.cgo }}" == "true" ]; then
export CGO_ENABLED=1
fi
make docker-image
- name: Push to ECR (normal)
env:
Expand All @@ -63,9 +71,13 @@ jobs:
- name: Build docker image (debug)
if: github.event.inputs.buildDebug != 'false'
env:
WASM: ${{ github.event.inputs.WASM }}
WASM: ${{ github.event.inputs.wasm }}
CGO_ENABLED: 0
run: |
make WASM="${WASM}" docker-image-debug
if [ "${{ github.event.inputs.cgo }}" == "true" ]; then
export CGO_ENABLED=1
fi
make docker-image-debug
- name: Push to ECR (debug)
if: github.event.inputs.buildDebug != 'false'
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
FROM golang:1.21-alpine3.18 as build

ARG ARCH=x86_64
ARG WASM=false
ARG WASM=true

RUN apk add --no-cache --update \
ca-certificates \
Expand All @@ -30,8 +30,8 @@ RUN if [[ "${WASM}" == "true" ]]; then \

COPY . .

ENV CGO_ENABLED=0
RUN make WASM="${WASM}" MUSLC="${WASM}" build
ENV CGO_ENABLED=1
RUN make MUSLC="${WASM}" build

FROM alpine:3.18

Expand Down
6 changes: 3 additions & 3 deletions Dockerfile.binaries
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ RUN apt update && apt install \

WORKDIR $GOPATH/src/github.com/axelarnetwork/axelar-core
ARG SEMVER
ARG WASM=false
ARG WASM=true

COPY ./go.mod .
COPY ./go.sum .
RUN go mod download

COPY . .
ENV CGO_ENABLED=0
RUN make WASM="${WASM}" build-binaries
ENV CGO_ENABLED=1
RUN make build-binaries
5 changes: 3 additions & 2 deletions Dockerfile.debug
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RUN groupadd -r -g 1001 axelard && useradd -m -r -u 1000 -g axelard axelard

WORKDIR /axelar
RUN chown -R axelard:axelard /axelar
ARG WASM=false
ARG WASM=true

RUN go install github.com/go-delve/delve/cmd/dlv@latest

Expand All @@ -15,7 +15,8 @@ RUN go mod download

COPY . .
RUN git config --global --add safe.directory /axelar
RUN make WASM="${WASM}" debug
ENV CGO_ENABLED=1
RUN make debug
RUN cp /axelar/bin/* /usr/local/bin

# The home directory of axelar-core where configuration/genesis/data are stored
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bu
HTTPS_GIT := https://github.com/axelarnetwork/axelar-core.git
PUSH_DOCKER_IMAGE := true

$(info $$WASM is [${WASM}])
$(info $$CGO_ENABLED is [${CGO_ENABLED}])

ifeq ($(WASM), true)
WASM_ENABLED := "true"
ifndef $(WASM_CAPABILITIES)
Expand Down

0 comments on commit 03bade6

Please sign in to comment.