diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 50821c9..2b79ac2 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -15,58 +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 - 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 @@ -86,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/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..d220c23 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,13 @@ +name: Test build + +on: + pull_request: + branches: [main] + +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 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 15974ea..c60a9ff 100755 --- a/build.sh +++ b/build.sh @@ -4,6 +4,7 @@ # Make sure you have a complete flux build at `/usr/src/flux` 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