Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3213 from habitat-sh/fnichol/dockerize-rs
Approved by: @nobody from Nowhere Merged by: The Sentinels
- Loading branch information
Showing
21 changed files
with
2,080 additions
and
10 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,33 @@ | ||
[package] | ||
name = "habitat_pkg_export_docker" | ||
version = "0.0.0" | ||
authors = ["Fletcher Nichol <fnichol@habitat.sh>"] | ||
build = "../build.rs" | ||
workspace = "../../" | ||
|
||
[lib] | ||
name = "habitat_pkg_export_docker" | ||
|
||
[[bin]] | ||
name = "hab-pkg-export-docker" | ||
path = "src/main.rs" | ||
doc = false | ||
|
||
[dependencies] | ||
clap = { version = "*", features = ["suggestions", "color", "unstable"] } | ||
clippy = { version = "*", optional = true } | ||
env_logger = "*" | ||
hab = { path = "../hab" } | ||
habitat_core = { path = "../core" } | ||
habitat_common = { path = "../common" } | ||
handlebars = { version = "*", features = ["partial4"], default-features = false } | ||
lazy_static = "*" | ||
log = "*" | ||
serde = { version = "*", features = ["rc"] } | ||
serde_json = "*" | ||
tempdir = "*" | ||
url = "*" | ||
|
||
[features] | ||
default = [] | ||
functional = [] |
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,7 @@ | ||
FROM scratch | ||
ENV PATH {{path}} | ||
ADD {{rootfs}} / | ||
VOLUME {{volumes}} | ||
EXPOSE 9631 {{exposes}} | ||
ENTRYPOINT ["/init.sh"] | ||
CMD ["start", "{{primary_svc_ident}}"] |
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,23 @@ | ||
root:x:0: | ||
bin:x:1:daemon | ||
sys:x:2: | ||
kmem:x:3: | ||
tape:x:4: | ||
tty:x:5: | ||
daemon:x:6: | ||
floppy:x:7: | ||
disk:x:8: | ||
lp:x:9: | ||
dialout:x:10: | ||
audio:x:11: | ||
video:x:12: | ||
utmp:x:13: | ||
usb:x:14: | ||
cdrom:x:15: | ||
adm:x:16: | ||
messagebus:x:18: | ||
systemd-journal:x:23: | ||
input:x:24: | ||
mail:x:34: | ||
nogroup:x:99: | ||
users:x:999: |
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,9 @@ | ||
passwd: files | ||
group: files | ||
shadow: files | ||
|
||
hosts: files dns | ||
networks: files | ||
|
||
rpc: files | ||
services: files |
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,4 @@ | ||
root:x:0:0:root:/root:/bin/sh | ||
bin:x:1:1:bin:/dev/null:/bin/false | ||
daemon:x:6:6:Daemon User:/dev/null:/bin/false | ||
nobody:x:99:99:Unprivileged User:/dev/null:/bin/false |
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,2 @@ | ||
nameserver 8.8.8.8 | ||
nameserver 8.8.4.4 |
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,7 @@ | ||
#!{{busybox_shell}} | ||
export PATH="{{path}}" | ||
case "$1" in | ||
-h|--help|help|-V|--version) exec {{sup_bin}} "$@";; | ||
-*) exec {{sup_bin}} start {{primary_svc_ident}} "$@";; | ||
*) exec {{sup_bin}} "$@";; | ||
esac |
4 changes: 4 additions & 0 deletions
4
components/pkg-export-docker/defaults/last_docker_export.env.hbs
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,4 @@ | ||
id={{id}} | ||
name={{name}} | ||
tags={{tags}} | ||
name_tags={{name_tags}} |
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,82 @@ | ||
pkg_name=hab-pkg-export-docker | ||
_pkg_distname=$pkg_name | ||
pkg_origin=core | ||
pkg_version=$(cat "$PLAN_CONTEXT/../../VERSION") | ||
pkg_maintainer="The Habitat Maintainers <humans@habitat.sh>" | ||
pkg_license=('Apache-2.0') | ||
# The result is a portable, static binary. However, we shell out to the | ||
# Docker command which we need at runtime. | ||
pkg_deps=(core/docker) | ||
pkg_build_deps=( | ||
core/musl core/zlib-musl core/xz-musl core/bzip2-musl core/libarchive-musl | ||
core/openssl-musl core/libsodium-musl | ||
core/coreutils core/rust core/gcc | ||
) | ||
pkg_bin_dirs=(bin) | ||
|
||
bin=$_pkg_distname | ||
|
||
_common_prepare() { | ||
do_default_prepare | ||
|
||
# Can be either `--release` or `--debug` to determine cargo build strategy | ||
build_type="--release" | ||
build_line "Building artifacts with \`${build_type#--}' mode" | ||
|
||
# Used by the `build.rs` program to set the version of the binaries | ||
export PLAN_VERSION="${pkg_version}/${pkg_release}" | ||
build_line "Setting PLAN_VERSION=$PLAN_VERSION" | ||
|
||
if [ -z "$HAB_CARGO_TARGET_DIR" ]; then | ||
# Used by Cargo to use a pristine, isolated directory for all compilation | ||
export CARGO_TARGET_DIR="$HAB_CACHE_SRC_PATH/$pkg_dirname" | ||
else | ||
export CARGO_TARGET_DIR="$HAB_CARGO_TARGET_DIR" | ||
fi | ||
build_line "Setting CARGO_TARGET_DIR=$CARGO_TARGET_DIR" | ||
} | ||
|
||
do_prepare() { | ||
_common_prepare | ||
|
||
export rustc_target="x86_64-unknown-linux-musl" | ||
build_line "Setting rustc_target=$rustc_target" | ||
|
||
la_ldflags="-L$(pkg_path_for zlib-musl)/lib -lz" | ||
la_ldflags="$la_ldflags -L$(pkg_path_for xz-musl)/lib -llzma" | ||
la_ldflags="$la_ldflags -L$(pkg_path_for bzip2-musl)/lib -lbz2" | ||
la_ldflags="$la_ldflags -L$(pkg_path_for openssl-musl)/lib -lssl -lcrypto" | ||
|
||
export LIBARCHIVE_LIB_DIR=$(pkg_path_for libarchive-musl)/lib | ||
export LIBARCHIVE_INCLUDE_DIR=$(pkg_path_for libarchive-musl)/include | ||
export LIBARCHIVE_LDFLAGS="$la_ldflags" | ||
export LIBARCHIVE_STATIC=true | ||
export OPENSSL_LIB_DIR=$(pkg_path_for openssl-musl)/lib | ||
export OPENSSL_INCLUDE_DIR=$(pkg_path_for openssl-musl)/include | ||
export OPENSSL_STATIC=true | ||
export SODIUM_LIB_DIR=$(pkg_path_for libsodium-musl)/lib | ||
export SODIUM_STATIC=true | ||
|
||
# Used to find libgcc_s.so.1 when compiling `build.rs` in dependencies. Since | ||
# this used only at build time, we will use the version found in the gcc | ||
# package proper--it won't find its way into the final binaries. | ||
export LD_LIBRARY_PATH=$(pkg_path_for gcc)/lib | ||
build_line "Setting LD_LIBRARY_PATH=$LD_LIBRARY_PATH" | ||
} | ||
|
||
do_build() { | ||
pushd $PLAN_CONTEXT > /dev/null | ||
cargo build ${build_type#--debug} --target=$rustc_target --verbose | ||
popd > /dev/null | ||
} | ||
|
||
do_install() { | ||
install -v -D $CARGO_TARGET_DIR/$rustc_target/${build_type#--}/$bin \ | ||
$pkg_prefix/bin/$bin | ||
} | ||
|
||
do_strip() { | ||
if [[ "$build_type" != "--debug" ]]; then | ||
do_default_strip | ||
fi | ||
} |
Oops, something went wrong.