diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3f0dd70a2..085bd8fa2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,6 +7,8 @@ on: - main - release/** - upgrade/** + # TODO: debugging + - feature/upload_build_artifact permissions: contents: read @@ -20,9 +22,10 @@ jobs: strategy: matrix: go-arch: ["amd64"] + go-os: ["linux"] steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 with: go-version: "^1.21" - uses: technote-space/get-diff-action@v6.1.2 @@ -36,6 +39,33 @@ jobs: **/go.sum **/Makefile Makefile - - name: Build - if: env.GIT_DIFF - run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false make build + # TODO: reenable once everything is working + # Non-static build with Go + # - name: Non-static Build with Go + # run: | + # GOARCH=${{ matrix.go-arch }} GOOS=${{ matrix.go-os }} LEDGER_ENABLED=false make build + # mv ./build/cantod ./build/cantod-nonstatic-${{ matrix.go-os }}-${{ matrix.go-arch }} + - name: Install musl-tools + run: sudo apt-get update && sudo apt-get install -y musl-tools + - name: Static Build + env: + CC: musl-gcc + CGO_ENABLED: 1 + GOARCH: ${{ matrix.go-arch }} + GOOS: ${{ matrix.go-os }} + LEDGER_ENABLED: false + LDFLAGS: "-extldflags -static" + run: | + # TODO: move to env or line break + # CC=musl-gcc CGO_ENABLED=1 GOARCH=${{ matrix.go-arch }} GOOS=${{ matrix.go-os }} LEDGER_ENABLED=false make build LDFLAGS="-extldflags \"-static\"" + make build + # TODO debugging + ls -lh build/cantod + file build/cantod + build/cantod + mv build/cantod ./build/cantod-${{ matrix.go-os }}-${{ matrix.go-arch }} + - name: Upload cantod Binary (Static) + uses: actions/upload-artifact@v4 + with: + name: cantod-${{ matrix.go-os }}-${{ matrix.go-arch }} + path: ./build/cantod-${{ matrix.go-os }}-${{ matrix.go-arch }} diff --git a/Dockerfile b/Dockerfile index 3fbf07455..b980da766 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,25 @@ -FROM golang:stretch AS build-env +# TODO: debugging +FROM golang:1.21 AS build-env WORKDIR /go/src/github.com/canto/canto RUN apt-get update -y RUN apt-get install git -y +RUN curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun COPY . . RUN make build -FROM golang:stretch - -RUN apt-get update -y -RUN apt-get install ca-certificates jq -y - -WORKDIR /root - -COPY --from=build-env /go/src/github.com/canto/canto/build/cantod /usr/bin/cantod - -EXPOSE 26656 26657 1317 9090 - -CMD ["cantod"] +# FROM golang:stretch +# +# RUN apt-get update -y +# RUN apt-get install ca-certificates jq -y +# +# WORKDIR /root +# +# COPY --from=build-env /go/src/github.com/canto/canto/build/cantod /usr/bin/cantod +# +# EXPOSE 26656 26657 1317 9090 +# +# CMD ["cantod"]