From f2229f937e046682169157ad0c14567daf58f45d Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Fri, 26 Jun 2015 10:22:22 -0700 Subject: [PATCH] Bring back tini-static! :tada: This allows the use of `tini` within even more minimal environments (such as images that are `FROM scratch` with a single application binary `COPY`'d in). --- CMakeLists.txt | 4 ++++ README.md | 11 +++++++++++ ci/run_build.sh | 47 +++++++++++++++++++++++----------------------- test/test.py | 2 +- tpl/README.md.in | 11 +++++++++++ tpl/travis.yml.tpl | 1 + 6 files changed, 52 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 935f5a8..8931cb8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,8 +36,12 @@ include_directories ("${PROJECT_BINARY_DIR}") add_executable (tini src/tini.c) +add_executable (tini-static src/tini.c) +set_target_properties (tini-static PROPERTIES LINK_FLAGS "-Wl,--no-export-dynamic -static") + # Installation install (TARGETS tini DESTINATION bin) +install (TARGETS tini-static DESTINATION bin) # Packaging include (InstallRequiredSystemLibraries) diff --git a/README.md b/README.md index 5ca8db6..7630f73 100644 --- a/README.md +++ b/README.md @@ -63,11 +63,22 @@ Assuming your entrypoint was `/docker-entrypoint.sh`, then you would use: ENTRYPOINT ["/tini", "--", "/docker-entrypoint.sh"] +### Statically-Linked Version ### + +Tini has very few dependencies (it only depends on libc), but if your +container fails to start, you might want to consider using the statically-built +version instead: + + ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static /tini + + ### Size Considerations ### Tini is a very small file (in the 10KB range), so it doesn't add much weight to your container. +The statically-linked version is bigger, but still < 1M. + ### Building Tini ### diff --git a/ci/run_build.sh b/ci/run_build.sh index 102072f..ffc4b20 100755 --- a/ci/run_build.sh +++ b/ci/run_build.sh @@ -22,26 +22,27 @@ make package popd # Smoke tests (actual tests need Docker to run; they don't run within the CI environment) -tini="${BUILD_DIR}/tini" -echo "Testing $tini with: true" -$tini -vvvv true - -echo "Testing $tini with: false" -if $tini -vvvv false; then - exit 1 -fi - -# Place files -mkdir -p "${DIST_DIR}" -cp "${BUILD_DIR}"/tini{,*.rpm,*deb} "${DIST_DIR}" - -# Quick audit -if which rpm; then - echo "Contents for RPM:" - rpm -qlp "${DIST_DIR}/tini"*.rpm -fi - -if which dpkg; then - echo "Contents for DEB:" - dpkg --contents "${DIST_DIR}/tini"*deb -fi +for tini in "${BUILD_DIR}/tini" "${BUILD_DIR}/tini-static"; do + echo "Testing $tini with: true" + $tini -vvvv true + + echo "Testing $tini with: false" + if $tini -vvvv false; then + exit 1 + fi + + # Move files to the dist dir for testing + mkdir -p "${DIST_DIR}" + cp "${BUILD_DIR}"/tini{,-static,*.rpm,*deb} "${DIST_DIR}" + + # Quick audit + if which rpm; then + echo "Contents for RPM:" + rpm -qlp "${DIST_DIR}/tini"*.rpm + fi + + if which dpkg; then + echo "Contents for DEB:" + dpkg --contents "${DIST_DIR}/tini"*deb + fi +done diff --git a/test/test.py b/test/test.py index de8becc..5fdb4ad 100644 --- a/test/test.py +++ b/test/test.py @@ -73,7 +73,7 @@ if __name__ == "__main__": # Funtional tests - for entrypoint in ["/tini/dist/tini"]: + for entrypoint in ["/tini/dist/tini", "/tini/dist/tini-static"]: functional_base_cmd = base_cmd + [ "--entrypoint={0}".format(entrypoint), img, diff --git a/tpl/README.md.in b/tpl/README.md.in index 40d6d1e..547bfac 100644 --- a/tpl/README.md.in +++ b/tpl/README.md.in @@ -63,11 +63,22 @@ Assuming your entrypoint was `/docker-entrypoint.sh`, then you would use: ENTRYPOINT ["/tini", "--", "/docker-entrypoint.sh"] +### Statically-Linked Version ### + +Tini has very few dependencies (it only depends on libc), but if your +container fails to start, you might want to consider using the statically-built +version instead: + + ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static /tini + + ### Size Considerations ### Tini is a very small file (in the 10KB range), so it doesn't add much weight to your container. +The statically-linked version is bigger, but still < 1M. + ### Building Tini ### diff --git a/tpl/travis.yml.tpl b/tpl/travis.yml.tpl index 67feea0..2af079c 100644 --- a/tpl/travis.yml.tpl +++ b/tpl/travis.yml.tpl @@ -29,6 +29,7 @@ deploy: secure: Yk90ANpSPv1iJy8QDXCPwfaSmEr/WIJ3bzhQ6X8JvZjfrwTosbh0HrUzQyeac3nyvNwj7YJRssolOFc21IBKPpCFTZqYxSkuLPU6ysG4HGHgN6YJhOMm4mG4KKJ6741q3DJendhZpalBhCEi+NcZK/PCSD97Vl4OqRjBUged0fs= file: - "./dist/tini" + - "./dist/tini-static" - "./dist/tini_@tini_VERSION_MAJOR@.@tini_VERSION_MINOR@.@tini_VERSION_PATCH@.deb" - "./dist/tini_@tini_VERSION_MAJOR@.@tini_VERSION_MINOR@.@tini_VERSION_PATCH@.rpm" on: