forked from karitra/mp707
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compile static binaries for i386 and x86_64. Use docker to simplify cross-compilation process.
- Loading branch information
1 parent
57354cf
commit 9f6adb9
Showing
5 changed files
with
74 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.git/ | ||
.gitignore | ||
|
||
.idea/ | ||
|
||
.dockerignore | ||
Dockerfile | ||
|
||
cmd/mp707/mp707 | ||
|
||
LICENSE | ||
README.md | ||
|
||
release/ | ||
scripts/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
* | ||
!*/ | ||
!**/*.go | ||
!go.mod | ||
!LICENSE | ||
!Makefile | ||
!README.md | ||
.idea/ | ||
|
||
release/ | ||
|
||
cmd/mp707/mp707 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
ARG FROM=golang:1.15-buster | ||
|
||
FROM $FROM as builder | ||
|
||
ARG DEVUAN_KEY=BB23C00C61FC752C | ||
|
||
# Debian's libudev-dev package doesn't include a static library (libudev.a) needed for static linking. | ||
# Fortunately we can install libeudev-dev package from Devuan repositories which provides udev-compatible | ||
# development files and a static library as well. | ||
RUN echo deb http://deb.devuan.org/merged ascii main > /etc/apt/sources.list.d/devuan.list | ||
RUN gpg --keyserver keys.gnupg.net --recv-key $DEVUAN_KEY && gpg -a --export $DEVUAN_KEY | apt-key add - | ||
|
||
RUN apt update && apt install --no-install-recommends -y libusb-1.0-0-dev libeudev-dev | ||
|
||
WORKDIR /go/mp707 | ||
ADD . . | ||
RUN make static | ||
|
||
FROM scratch | ||
COPY --from=builder /go/mp707/cmd/mp707/mp707 / | ||
ENTRYPOINT ["/mp707"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
set -exo pipefail | ||
|
||
mkdir -p "$(dirname "$OUTPUT")" | ||
|
||
FROM=${FROM:-golang:1.15-buster} | ||
GOARCH=${GOARCH:amd64} | ||
|
||
DIGEST=$(docker manifest inspect "$FROM" | jq -r '.manifests[] | select(.platform.architecture == "'"$GOARCH"'") | .digest') | ||
FROM=$FROM@$DIGEST | ||
|
||
TAG=$SLUG:$GOARCH | ||
|
||
docker build \ | ||
--pull \ | ||
-t "$TAG" \ | ||
--build-arg FROM="$FROM" \ | ||
. | ||
|
||
CONTAINER=$(docker create "$TAG") | ||
|
||
docker cp "$CONTAINER":/"$NAME" "$OUTPUT" | ||
docker rm "$CONTAINER" |