Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: musl build #21

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 5 additions & 53 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,58 +15,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set up Rust
uses: actions-rs/[email protected]
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/[email protected]
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
Expand All @@ -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
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions Dockerfile_musl
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions pkg-config-static.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
pkg-config --static "$@"