Skip to content

Commit

Permalink
Support musl docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkvdb committed Aug 30, 2024
1 parent 2531574 commit b2d0a65
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/build/
/docker/
/deps/vcpkg/buildtrees
/deps/vcpkg/packages
/vcpkgs*
/.git
/.cache
.DS_Store
justfile
2 changes: 2 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
targets=["package"],
build_config=args.build_config,
run_tests_after_build=args.run_tests,
git_hash=args.git_hash,
)
else:
vcpkg.build_project(
Expand All @@ -62,6 +63,7 @@
build_name=build_dir,
build_config=args.build_config,
run_tests_after_build=args.run_tests,
git_hash=args.git_hash,
)
except KeyboardInterrupt:
print("\nInterrupted")
Expand Down
1 change: 1 addition & 0 deletions dist/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "E-MAP emission mapper")
set(CPACK_PACKAGE_EXECUTABLES ${PROJECT_NAME})
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
set(CPACK_PACKAGE_DIRECTORY "${CMAKE_BINARY_DIR}/packages")
set(CPACK_NSIS_DISPLAY_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION})
set(CPACK_SOURCE_GENERATOR "TGZ;TZ")
set(CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION})
Expand Down
10 changes: 10 additions & 0 deletions docker/MuslStaticBuild.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM alpine:3.20.2 AS builder

ARG GIT_HASH=dev
WORKDIR /project
RUN apk add bash linux-headers gcc g++ curl zip unzip tar git python3 cmake ninja-is-really-ninja make automake autoconf autoconf-archive libtool pkgconfig
RUN echo insecure >> $HOME/.curlrc

COPY . .
RUN python3 bootstrap.py --triplet=x64-linux-static
RUN python3 build.py --triplet=x64-linux-static --dist --git-hash=${GIT_HASH}
11 changes: 11 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
git_hash := `git rev-parse HEAD`

cleangitcondition:
git diff --exit-code

buildmusl:
echo "Building static musl binary: {{git_hash}}"
docker build --build-arg="GIT_HASH={{git_hash}}" -f ./docker/MuslStaticBuild.Dockerfile -t emapmuslbuild .
docker create --name extract emapmuslbuild
docker cp extract:/project/build/emap-release-x64-linux-static-Release-dist/packages ./build
docker rm extract

0 comments on commit b2d0a65

Please sign in to comment.