Skip to content

Commit

Permalink
static linux release
Browse files Browse the repository at this point in the history
  • Loading branch information
mosajjal committed Feb 27, 2022
1 parent 620c39f commit fa2d684
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Publish binaries on Release
on:
release:
types: [created]

jobs:
build:
name: Build
runs-on: ubuntu-20.04
steps:

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Get dependencies
run: |
docker build -t myrepo:latest -f Dockerfile .
id=$(docker create myrepo:latest)
docker cp $id:/tcpshark /tmp/tcpshark.bin
strip --strip-all /tmp/tcpshark.bin
- name: Upload Linux binary to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: /tmp/tcpshark.bin
asset_name: tcpshark-static-musl-linux.bin
tag: ${{ github.ref }}
overwrite: true
body: ""

17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM alpine:edge
LABEL maintainer "Ali Mosajjal <[email protected]>"

SHELL ["/bin/ash", "-c"]

RUN apk add --no-cache libcap-static libpcap-dev linux-headers git go file rpm --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing/

ENV DST="/tmp/tcpshark/"
ENV REPO="github.com/mosajjal/tcpshark"
RUN git clone https://${REPO}.git ${DST} --depth 1 \
&& cd ${DST} \
&& go build --ldflags "-L /usr/lib/libcap.a -linkmode external -extldflags \"-static\"" -o ${DST}/tcpshark


FROM scratch
COPY --from=0 /tmp/tcpshark/tcpshark /tcpshark
ENTRYPOINT ["/tcpshark"]

0 comments on commit fa2d684

Please sign in to comment.