From 4fb0230d80ca9994124c32ed4cf1c6078fc14b33 Mon Sep 17 00:00:00 2001 From: akvlad Date: Wed, 4 Oct 2023 13:26:44 +0300 Subject: [PATCH 1/4] feat: musl build --- .github/workflows/go.yml | 59 ++++------------------------------------ Dockerfile_musl | 30 ++++++++++++++++++++ build.sh | 1 + pkg-config-static.sh | 2 ++ 4 files changed, 38 insertions(+), 54 deletions(-) create mode 100644 Dockerfile_musl create mode 100755 pkg-config-static.sh diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 71a374c..2b79ac2 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -15,59 +15,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Rust - uses: actions-rs/toolchain@v1.0.6 - with: - toolchain: stable - override: true - components: rustfmt, clippy - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: 1.18 - - - name: Cache Flux Build - id: cacheflux - uses: actions/cache@v3.0.11 - with: - path: | - flux - ~/.cache/go-build - ~/go/pkg/mod - key: ${{ runner.os }}-fluxpipe-${{ hashFiles('**/fluxpipe-server.go') }} - - - name: Cache Status - run: | - echo ${{steps.cacheflux.outputs.cache-hit}} - - - name: Get Flux - if: steps.cacheflux.outputs.cache-hit != 'true' - uses: GuillaumeFalourd/clone-github-repo-action@v2 - with: - owner: 'InfluxCommunity' - repository: 'flux' - - - name: Compile Flux - if: steps.cacheflux.outputs.cache-hit != 'true' - run: | - cd flux - git checkout tags/v0.194.3 - go mod tidy - go get ./... - make - - name: Build Fluxpipe - run: | - sed -i 's:/usr/src:'`pwd`':' flux.pc - ./build.sh - - - name: Compress Fluxpipe - run: | - strip fluxpipe-server - strip fluxpipe-lambda - strip fluxpipelib.a - upx fluxpipe-server + run: docker build --target export -t test . -f Dockerfile_musl --output out + - name: Get Timestamp if: github.event_name != 'pull_request' id: time @@ -87,9 +38,9 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: release_config: | - fluxpipe-server - fluxpipe-lambda - fluxpipelib.a + out/fluxpipe-server + out/fluxpipe-lambda + out/fluxpipelib.a tag_name: ${{ env.VERSION }} release_name: fluxpipe_${{ env.VERSION }} draft: false diff --git a/Dockerfile_musl b/Dockerfile_musl new file mode 100644 index 0000000..3eee5e6 --- /dev/null +++ b/Dockerfile_musl @@ -0,0 +1,30 @@ +FROM rust:1.70-alpine as RUSTBUILD + +FROM golang:1.19-alpine as BUILDER + +# Install rust and rust tooling +COPY --from=RUSTBUILD /usr/local/cargo /usr/local/cargo +COPY --from=RUSTBUILD /usr/local/rustup /usr/local/rustup + +RUN apk add pkgconfig musl-dev gcc upx + +ENV RUSTUP_HOME=/usr/local/rustup \ + CARGO_HOME=/usr/local/cargo \ + PATH=/go/bin:/usr/local/cargo/bin:/usr/local/bin:/usr/local/ragel7/bin:$PATH + + +RUN go install github.com/influxdata/pkg-config@latest + +COPY . /src + +RUN cd /src && sh build.sh && \ + strip fluxpipe-server && \ + strip fluxpipe-lambda && \ + strip fluxpipelib.a && \ + upx fluxpipe-server + +FROM scratch as export + +COPY --from=BUILDER /src/fluxpipe-server /fluxpipe-server +COPY --from=BUILDER /src/fluxpipe-lambda /fluxpipe-lambda +COPY --from=BUILDER /src/fluxpipelib.a /fluxpipelib.a diff --git a/build.sh b/build.sh index 02c4db3..a24ea6c 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,6 @@ #!/bin/sh export PKG_CONFIG_PATH=$(pwd) +export PKG_CONFIG=`pwd`/pkg-config-static.sh echo "Building fluxpipe-server ..." go build -a -ldflags '-extldflags "-static -w -ldl"' -o fluxpipe-server ./cmd/server diff --git a/pkg-config-static.sh b/pkg-config-static.sh new file mode 100755 index 0000000..e81d2cf --- /dev/null +++ b/pkg-config-static.sh @@ -0,0 +1,2 @@ +#!/bin/sh +pkg-config --static "$@" \ No newline at end of file From cc2fac433c4d6595b1b15cc1eefc92618295491c Mon Sep 17 00:00:00 2001 From: akvlad Date: Wed, 4 Oct 2023 13:37:24 +0300 Subject: [PATCH 2/4] feat: test build --- .github/workflows/test.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..2ec61c9 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,14 @@ +name: Build-n-Release + +on: + pull_request: + branches: [master] + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build Fluxpipe + run: docker build --target export -t test . -f Dockerfile_musl --output out From 01b7cabc0edff1b22a7b11b5034ce44da8d0f192 Mon Sep 17 00:00:00 2001 From: akvlad Date: Wed, 4 Oct 2023 13:37:59 +0300 Subject: [PATCH 3/4] feat: test build --- .github/workflows/test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2ec61c9..9a01ca8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,10 +2,9 @@ name: Build-n-Release on: pull_request: - branches: [master] + branches: [main] jobs: - build: runs-on: ubuntu-latest steps: From 078b9f7dc621d8956f1c8d56bb7b9a59e3919fc2 Mon Sep 17 00:00:00 2001 From: akvlad Date: Wed, 4 Oct 2023 13:38:39 +0300 Subject: [PATCH 4/4] fix: test build --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9a01ca8..d220c23 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Build-n-Release +name: Test build on: pull_request: