New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pkg-export-docker] Rewrite `hab-pkg-dockerize` as a Rust program. #3213

Merged
merged 2 commits into from Sep 21, 2017

Conversation

Projects
None yet
3 participants
@fnichol
Member

fnichol commented Sep 19, 2017

This change introduces a new implementation of the hab-pkg-dockerize
program, written in Rust as opposed to the Bash-based current
implementation. It has been renamed to hab-pkg-export-docker to
reflect where it lives in the hab subcommand tree. Future work will
plumb this program back into core/hab and then the
core/hab-pkg-dockerize can be deprecated.

Feature Set

tenor-58993064

Multi-Package Support

tenor-167405991

This exporter will take one or more package identifers (i.e.
acme/redis) and/or filepaths to Habitat artifacts (i.e. a .hart
file). These packages may contain services, but may also be additional
libraries, debugging tools, and extra userland utilities.

Service-Focused

tenor-247443130

The expectation is that the created Docker image will contain at least
one package containing a runnable service (i.e. a "service package").
The exporter will ensure that at least one of the packages provided by a
user is a service package.

Package Depot URL and Channel Selection

tenor-64841790

By default, all package identifiers provided to this exporter will be
installed from the default Depot in the "stable" release channel. You
can use the --url to install from another Depot and --channel to use
a custom release channel. For example, to export a Docker image from an
unstable build of your application called acme/myapp you could run
hab-pkg-export-docker --channel unstable acme/myapp.

Customized Image Naming

tenor-206029011

By default, the first service package name will determine the default
name for the Docker image. By default, hab-pkg-export-docker core/redis core/nginx would create a Docker image called core/redis. An option
of --image-name allows you to override this default. Additionally, as
the Docker image name determines the publish target (i.e. the name on
the Docker Hub for example), the --image-name option allows you tweak
the publish name. The value for this option may contain one or more of
the following template variables:

  • {{pkg_origin}} - the origin name of the first service package
    provided
  • {{pkg_name}} - the package name of the first service package
    provided
  • {{pkg_version}} - the package version of the first service package
    provided
  • {{pkg_release}} - the package release of the first service package
    provided
  • {{channel}} - the release channel name used to install packages

For example, hab-pkg-export-docker --image-name "jdoe/{{pkg_name}}" core/redis would create a Docker image called jdoeredis`.

Automatically Generated Image Tagging

tenor-177094694

By default, 3 image tags will be applied to the exported Docker image:

  • :{{pkg_version}}-{{pkg_release}} - the package version and release of the first service package
  • :{{pkg_version}} - the package version of the first service package
  • :latest - the latest tag allows a user to omit any explicit tag

There is an "opt-out" flag for each of these tags if these defaults
don't apply:

  • --no-tag-version-release - skips tagging with
    :{{pkg_version}}-{{pkg_release}}
  • --no-tag-version - skips tagging with :{{pkg_version}}
  • --no-tag-latest - skips tagging with :latest

There is also a --tag-custom option which allows you to provide a
custom tag. As with the --image-name option discussed above, the
--tag-custom option value may contain one or more of the template
variables: {{pkg_origin}}, {{pkg_name}}, {{pkg_version}},
{{pkg_release}}, {{channel}}.

For example, hab-pkg-export-docker --tag-custom "{{channel}}" core/redis would create a Docker image also tagged with :stable,
where stable is the default release channel.

Optional Image Publishing

tenor-258923984

If desired, this exporter can also automatically publish ("push" in the
Docker vernacular) to a Docker registry using 3 options:

  • --push-image - pushes the image (default is to not push)
  • --username - used for docker login as the "username"
  • --password - used for docker login as the "password"

Note that once --push-image is used, both --username and
--password options become required. All tags (as explained above) will
be pushed.

Optional Image Cleanup

tenor-130577322

If desired, this exporter can remove all image layers and tags from the
local Docker engine after building and/or publishing. This behavior is
"opt-in" via supplying the --rm-image flag.

(Advanced) Customized Base Packages

tenor-58941116

By default, the Habitat CLI (i.e. core/hab), the Supervisor (i.e.
core/hab-sup), and the Launcher (i.e. core/hab-launcher) will be
installed remotely from the default Depot in the "stable" channel. There
are several options which allow further customizing if necessary. Note
that in most use cases this is not necessary, but this can be handy when
testing unstable Supervisors with newer packages, etc. The following
options apply to these "base" packages:

  • --base-pkgs-url - The Depot URL used to install base packages
  • --base-pkgs-channel - The release channel used to install base
    packages
  • --hab-pkg - A package identifier or artifact file corresponding to
    the Habitat CLI (default is to install core/hab)
  • --sup-pkg - A package identifier or artifact file corresponding to
    the Supervisor (default is to install core/hab-sup)
  • --launcher-pkg - A package identifier or artifact file corresponding to
    the Launcher (default is to install core/hab-launcher)

CLI Usage

tenor-158841814

> hab-pkg-export-docker --help
hab-pkg-export-docker 0.32.0-dev/20170918005438

Authors: The Habitat Maintainers <humans@habitat.sh>

Creates (an optionally pushes) a Docker image from a set of Habitat packages

USAGE:
    hab-pkg-export-docker [FLAGS] [OPTIONS] <PKG_IDENT_OR_ARTIFACT>...

FLAGS:
        --no-push-image
            Do not push image to remote registry (default: yes)

        --no-tag-latest             Do not tag image with :"latest" (default: no)
        --no-tag-version
            Do not tag image with :"{{pkg_version}}" (default: no)

        --no-tag-version-release
            Do not tag image with :"{{pkg_version}}-{{pkg_release}}" (default: no)

        --push-image                Push image to remote registry (default: no)
        --rm-image
            Remove local image from engine after build and/or push (default: no)

        --tag-latest                Tag image with :"latest" (default: yes)
        --tag-version               Tag image with :"{{pkg_version}}" (default: yes)
        --tag-version-release
            Tag image with :"{{pkg_version}}-{{pkg_release}}" (default: yes)

    -h, --help                      Prints help information
    -V, --version                   Prints version information

OPTIONS:
        --base-pkgs-channel <BASE_PKGS_CHANNEL>
            Install base packages from the specified release channel (default:
            stable)
        --base-pkgs-url <BASE_PKGS_DEPOT_URL>
            Install base packages from the specified Depot (default:
            https://bldr.habitat.sh/v1/depot)
    -c, --channel <CHANNEL>
            Install packages from the specified release channel (default: stable)

    -u, --url <DEPOT_URL>
            Install packages from the specified Depot (default:
            https://bldr.habitat.sh/v1/depot)
        --launcher-pkg <HAB_LAUNCHER_PKG>
            Launcher package identifier (ex: acme/redis) or filepath to a Habitat
            artifact (ex: /home/acme-redis-3.0.7-21120102031201-x86_64-linux.hart)
            to install (default: core/hab-launcher)
        --hab-pkg <HAB_PKG>
            Habitat CLI package identifier (ex: acme/redis) or filepath to a Habitat
            artifact (ex: /home/acme-redis-3.0.7-21120102031201-x86_64-linux.hart)
            to install (default: core/hab)
        --sup-pkg <HAB_SUP_PKG>
            Supervisor package identifier (ex: acme/redis) or filepath to a Habitat
            artifact (ex: /home/acme-redis-3.0.7-21120102031201-x86_64-linux.hart)
            to install (default: core/hab-sup)
    -n, --image-name <IMAGE_NAME>
            Image name (default: "{{pkg_origin}}/{{pkg_name}}" supports:
            {{pkg_origin}}, {{pkg_name}}, {{pkg_version}}, {{pkg_release}},
            {{channel}})
    -P, --password <REGISTRY_PASSWORD>
            Remote registry password, required for pushing image to remote registry

    -U, --username <REGISTRY_USERNAME>
            Remote registry username, required for pushing image to remote registry

        --tag-custom <TAG_CUSTOM>
            Tag image with additional custom tag (supports: {{pkg_origin}},
            {{pkg_name}}, {{pkg_version}}, {{pkg_release}}, {{channel}})

ARGS:
    <PKG_IDENT_OR_ARTIFACT>...
            One or more Habitat package identifiers (ex: acme/redis) and/or
            filepaths to a Habitat Artifact (ex: /home/acme-redis-3.0.7-
            21120102031201-x86_64-linux.hart)

Example Invocation

tenor-268061019

This example will create and publish a fnichol/redis Docker image to
the Docker Hub with an additional tag of :stable from the core/redis
package. It will also clean up all image layers on the local Docker
engine when complete.

> hab-pkg-export-docker
    --image-name "fnichol/{{pkg_name}}" \
    --tag-custom "{{channel}}" \
    --push-image \
    --username "$DOCKER_USERNAME" \
    --password "$DOCKER_PASSWORD" \
    --rm-image \
    core/redis

» Building a runnable Docker image with: core/redis
Ω Creating build root in /tmp/hab-pkg-export-docker.zqwiZXbKFg1q
Ω Creating root filesystem
Ω Creating artifact cache symlink
» Installing core/hab from channel 'stable'
☛ Verifying core/hab/0.31.0/20170907232530
↓ Downloading core-20160810182414 public origin key
    75 B / 75 B | [=========================================] 100.00 % 768.82 KB/s
☑ Cached core-20160810182414 public origin key
✓ Installed core/hab/0.31.0/20170907232530
★ Install of core/hab/0.31.0/20170907232530 complete with 1 new packages installed.
» Installing core/hab-sup from channel 'stable'
☛ Verifying core/hab-sup/0.31.0/20170907230558
...
✓ Installed core/hab-sup/0.31.0/20170907230558
★ Install of core/hab-sup/0.31.0/20170907230558 complete with 13 new packages installed.
» Installing core/hab-launcher from channel 'stable'
☛ Verifying core/hab-launcher/4571/20170727193541
...
✓ Installed core/hab-launcher/4571/20170727193541
★ Install of core/hab-launcher/4571/20170727193541 complete with 2 new packages installed.
» Installing core/busybox-static from channel 'stable'
→ Using core/busybox-static/1.24.2/20170513215502
★ Install of core/busybox-static/1.24.2/20170513215502 complete with 0 new packages installed.
» Installing core/cacerts from channel 'stable'
→ Using core/cacerts/2017.01.18/20170513215104
★ Install of core/cacerts/2017.01.18/20170513215104 complete with 0 new packages installed.
» Symlinking basename from core/busybox-static/1.24.2/20170513215502 into /tmp/hab-pkg-export-docker.zqwiZXbKFg1q/rootfs/bin
★ Binary basename from core/busybox-static/1.24.2/20170513215502 symlinked to /tmp/hab-pkg-export-docker.zqwiZXbKFg1q/rootfs/bin/basename
...
» Symlinking hab from core/hab/0.31.0/20170907232530 into /tmp/hab-pkg-export-docker.zqwiZXbKFg1q/rootfs/bin
★ Binary hab from core/hab/0.31.0/20170907232530 symlinked to /tmp/hab-pkg-export-docker.zqwiZXbKFg1q/rootfs/bin/hab
Ω Creating cacerts symlink into /etc
» Installing core/redis from channel 'stable'
☛ Verifying core/redis/3.2.4/20170514150022
→ Using core/glibc/2.22/20170513201042
→ Using core/linux-headers/4.3/20170513200956
✓ Installed core/redis/3.2.4/20170514150022
★ Install of core/redis/3.2.4/20170514150022 complete with 1 new packages installed.
☒ Deleting artifact cache symlink
Ω Creating user 'hab' in /etc/passwd
Ω Creating group 'hab' in /etc/group
Ω Creating entrypoint script
Ω Creating image Dockerfile
Ω Creating Docker image
Sending build context to Docker daemon 121.5 MB
Step 1/7 : FROM scratch
 --->
Step 2/7 : ENV PATH /bin
 ---> Running in 3764fbf0fd48
 ---> 91f9e866d2a2
Removing intermediate container 3764fbf0fd48
Step 3/7 : ADD rootfs /
 ---> fedafdfabe25
Removing intermediate container 0856bccda165
Step 4/7 : VOLUME /hab/svc/redis/data /hab/svc/redis/config
 ---> Running in a0e74096f3dd
 ---> eeee2418cb88
Removing intermediate container a0e74096f3dd
Step 5/7 : EXPOSE 9631 6379
 ---> Running in 6892e787f824
 ---> bf594ae00b1c
Removing intermediate container 6892e787f824
Step 6/7 : ENTRYPOINT /init.sh
 ---> Running in e1925f651f79
 ---> a1c6d45e7924
Removing intermediate container e1925f651f79
Step 7/7 : CMD start core/redis
 ---> Running in 65890dc186b5
 ---> 21cca29fbcf2
Removing intermediate container 65890dc186b5
Successfully built 21cca29fbcf2
Successfully tagged fnichol/redis:3.2.4-20170514150022
Successfully tagged fnichol/redis:3.2.4
Successfully tagged fnichol/redis:latest
Successfully tagged fnichol/redis:stable
☒ Deleting temporary files
★ Docker image 'fnichol/redis' created with tags: 3.2.4-20170514150022, 3.2.4, latest, stable
Ω Creating build report /src/results/last_docker_export.env
» Pushing Docker image 'fnichol/redis' with all tags to remote registry
☒ Logging out of remote registry
Not logged in to https://index.docker.io/v1/
☛ Logging into remote registry
Login Succeeded
↑ Uploading image 'fnichol/redis:3.2.4-20170514150022' to remote registry
The push refers to a repository [docker.io/fnichol/redis]
e38a1bd11d52: Pushed
3.2.4-20170514150022: digest: sha256:aac65091cfeaa40a3bea3e5796ba6e463e60df6e6625fb622e22dbc7125f41e0 size: 529
✓ Uploaded image 'fnichol/redis:3.2.4-20170514150022'
↑ Uploading image 'fnichol/redis:3.2.4' to remote registry
The push refers to a repository [docker.io/fnichol/redis]
e38a1bd11d52: Layer already exists
3.2.4: digest: sha256:aac65091cfeaa40a3bea3e5796ba6e463e60df6e6625fb622e22dbc7125f41e0 size: 529
✓ Uploaded image 'fnichol/redis:3.2.4'
↑ Uploading image 'fnichol/redis:latest' to remote registry
The push refers to a repository [docker.io/fnichol/redis]
e38a1bd11d52: Layer already exists
latest: digest: sha256:aac65091cfeaa40a3bea3e5796ba6e463e60df6e6625fb622e22dbc7125f41e0 size: 529
✓ Uploaded image 'fnichol/redis:latest'
↑ Uploading image 'fnichol/redis:stable' to remote registry
The push refers to a repository [docker.io/fnichol/redis]
e38a1bd11d52: Layer already exists
stable: digest: sha256:aac65091cfeaa40a3bea3e5796ba6e463e60df6e6625fb622e22dbc7125f41e0 size: 529
✓ Uploaded image 'fnichol/redis:stable'
☒ Logging out of remote registry
Removing login credentials for https://index.docker.io/v1/
★ Docker image 'fnichol/redis' published with tags: 3.2.4-20170514150022, 3.2.4, latest, stable
» Cleaning up local Docker image 'fnichol/redis' with all tags
☒ Deleting local image 'fnichol/redis:3.2.4-20170514150022'
Untagged: fnichol/redis:3.2.4-20170514150022
☒ Deleting local image 'fnichol/redis:3.2.4'
Untagged: fnichol/redis:3.2.4
☒ Deleting local image 'fnichol/redis:latest'
Untagged: fnichol/redis:latest
☒ Deleting local image 'fnichol/redis:stable'
Untagged: fnichol/redis:stable
Untagged: fnichol/redis@sha256:aac65091cfeaa40a3bea3e5796ba6e463e60df6e6625fb622e22dbc7125f41e0
Deleted: sha256:21cca29fbcf2b5a47ffeaef8751cd3693dd02a3d9c954ce5d5f8a43bc3227f06
Deleted: sha256:a1c6d45e792437f74c9de2ef230826eeff89ae07aba92aae36b1a46bded3f1a2
Deleted: sha256:bf594ae00b1cb71d141e76cf72e81d214857b0082c5be55b4229c5a67c497fe6
Deleted: sha256:eeee2418cb8877c8599bdd8b52900873df91e760dfc8e86f4aac455fe2405157
Deleted: sha256:fedafdfabe2502343c820532b424735a87e4497030062291a303d38b7bba4573
Deleted: sha256:e38a1bd11d52d7e5a7e0ae32c17eaf31c29267c795d1df8167d500b23324abcc
Deleted: sha256:91f9e866d2a2ce9fe812542d9cf88a7ead1a011c38c7022c75e0bf927fe56fc4
★ Local Docker image 'fnichol/redis' with tags: 3.2.4-20170514150022, 3.2.4, latest, stable cleaned up

tenor-207461780

Closes #2940

@thesentinels

This comment has been minimized.

Show comment
Hide comment
@thesentinels

thesentinels Sep 19, 2017

Contributor

Thanks for the pull request! Here is what will happen next:

  1. Your PR will be reviewed by the maintainers
  2. If everything looks good, one of them will approve it, and your PR will be merged.

Thank you for contributing!

Contributor

thesentinels commented Sep 19, 2017

Thanks for the pull request! Here is what will happen next:

  1. Your PR will be reviewed by the maintainers
  2. If everything looks good, one of them will approve it, and your PR will be merged.

Thank you for contributing!

@fnichol

This comment has been minimized.

Show comment
Hide comment
@fnichol

fnichol Sep 20, 2017

Member

Reminder to self: update DEPOT_URL -> BLDR_URL

Member

fnichol commented Sep 20, 2017

Reminder to self: update DEPOT_URL -> BLDR_URL

@fnichol

This comment has been minimized.

Show comment
Hide comment
@fnichol

fnichol Sep 21, 2017

Member

Got a review from @reset and good to move forward…

tenor-10523

@thesentinels approve

Member

fnichol commented Sep 21, 2017

Got a review from @reset and good to move forward…

tenor-10523

@thesentinels approve

@thesentinels

This comment has been minimized.

Show comment
Hide comment
@thesentinels

thesentinels Sep 21, 2017

Contributor

🤘 I am testing your branch against master before merging it. We do this to ensure that the master branch is never failing tests.

Contributor

thesentinels commented Sep 21, 2017

🤘 I am testing your branch against master before merging it. We do this to ensure that the master branch is never failing tests.

@thesentinels

This comment has been minimized.

Show comment
Hide comment
@thesentinels
Contributor

thesentinels commented Sep 21, 2017

:neckbeard: Travis CI has started testing this PR.

@fnichol

This comment has been minimized.

Show comment
Hide comment
@fnichol

fnichol Sep 21, 2017

Member

Going to rebase this ontop of the DEPOT_URL -> BLDR_URL changes as this PR was referencing the old ones.

Member

fnichol commented Sep 21, 2017

Going to rebase this ontop of the DEPOT_URL -> BLDR_URL changes as this PR was referencing the old ones.

fnichol added some commits Aug 23, 2017

Lexically sort root `Cargo.toml`.
Signed-off-by: Fletcher Nichol <fnichol@nichol.ca>
[pkg-export-docker] Rewrite `hab-pkg-dockerize` as a Rust program.
This change introduces a new implementation of the `hab-pkg-dockerize`
program, written in Rust as opposed to the Bash-based current
implementation. It has been renamed to `hab-pkg-export-docker` to
reflect where it lives in the `hab` subcommand tree. Future work will
plumb this program back into `core/hab` and then the
`core/hab-pkg-dockerize` can be deprecated.

Feature Set
===========

Multi-Package Support
---------------------

This exporter will take one or more package identifers (i.e.
`acme/redis`) and/or filepaths to Habitat artifacts (i.e. a `.hart`
file). These packages may contain services, but may also be additional
libraries, debugging tools, and extra userland utilities.

Service-Focused
---------------

The expectation is that the created Docker image will contain at least
one package containing a runnable service (i.e. a "service package").
The exporter will ensure that at least one of the packages provided by a
user is a service package.

Package Depot URL and Channel Selection
---------------------------------------

By default, all package identifiers provided to this exporter will be
installed from the default Depot in the "stable" release channel. You
can use the `--url` to install from another Depot and `--channel` to use
a custom release channel. For example, to export a Docker image from an
unstable build of your application called `acme/myapp` you could run
`hab-pkg-export-docker --channel unstable acme/myapp`.

Customized Image Naming
-----------------------

By default, the first service package name will determine the default
name for the Docker image. By default, `hab-pkg-export-docker core/redis
core/nginx` would create a Docker image called `core/redis`. An option
of `--image-name` allows you to override this default. Additionally, as
the Docker image name determines the publish target (i.e. the name on
the Docker Hub for example), the `--image-name` option allows you tweak
the publish name. The value for this option may contain one or more of
the following template variables:

* `{{pkg_origin}}` - the origin name of the first service package
provided
* `{{pkg_name}}` - the package name of the first service package
provided
* `{{pkg_version}}` - the package version of the first service package
provided
* `{{pkg_release}}` - the package release of the first service package
provided
* `{{channel}}` - the release channel name used to install packages

For example, `hab-pkg-export-docker --image-name "jdoe/{{pkg_name}}"
core/redis` would create a Docker image called `jdoe`redis`.

Automatically Generated Image Tagging
-------------------------------------

By default, 3 image tags will be applied to the exported Docker image:

* `:{{pkg_version}}-{{pkg_release}}` - the package version and release of the first service package
* `:{{pkg_version}}` - the package version of the first service package
* `:latest` - the latest tag allows a user to omit any explicit tag

There is an "opt-out" flag for each of these tags if these defaults
don't apply:

* `--no-tag-version-release` - skips tagging with
`:{{pkg_version}}-{{pkg_release}}`
* `--no-tag-version` - skips tagging with `:{{pkg_version}}`
* `--no-tag-latest` - skips tagging with `:latest`

There is also a `--tag-custom` option which allows you to provide a
custom tag. As with the `--image-name` option discussed above, the
`--tag-custom` option value may contain one or more of the template
variables: `{{pkg_origin}}`, `{{pkg_name}}`, `{{pkg_version}}`,
`{{pkg_release}}`, `{{channel}}`.

For example, `hab-pkg-export-docker --tag-custom "{{channel}}"
core/redis` would create a Docker image also tagged with `:stable`,
where `stable` is the default release channel.

Optional Image Publishing
-------------------------

If desired, this exporter can also automatically publish ("push" in the
Docker vernacular) to a Docker registry using 3 options:

* `--push-image` - pushes the image (default is to not push)
* `--username` - used for `docker login` as the "username"
* `--password` - used for `docker login` as the "password"

Note that once `--push-image` is used, both `--username` and
`--password` options become required. All tags (as explained above) will
be pushed.

Optional Image Cleanup
----------------------

If desired, this exporter can remove all image layers and tags from the
local Docker engine after building and/or publishing. This behavior is
"opt-in" via supplying the `--rm-image` flag.

(Advanced) Customized Base Packages
-----------------------------------

By default, the Habitat CLI (i.e. `core/hab`), the Supervisor (i.e.
`core/hab-sup`), and the Launcher (i.e. `core/hab-launcher`) will be
installed remotely from the default Depot in the "stable" channel. There
are several options which allow further customizing if necessary. Note
that in most use cases this is not necessary, but this can be handy when
testing unstable Supervisors with newer packages, etc. The following
options apply to these "base" packages:

* `--base-pkgs-url` - The Depot URL used to install base packages
* `--base-pkgs-channel` - The release channel used to install base
packages
* `--hab-pkg` - A package identifier or artifact file corresponding to
the Habitat CLI (default is to install `core/hab`)
* `--sup-pkg` - A package identifier or artifact file corresponding to
the Supervisor (default is to install `core/hab-sup`)
* `--launcher-pkg` - A package identifier or artifact file corresponding to
the Launcher (default is to install `core/hab-launcher`)

CLI Usage
=========

```
> hab-pkg-export-docker --help
hab-pkg-export-docker 0.32.0-dev/20170918005438

Authors: The Habitat Maintainers <humans@habitat.sh>

Creates (an optionally pushes) a Docker image from a set of Habitat packages

USAGE:
    hab-pkg-export-docker [FLAGS] [OPTIONS] <PKG_IDENT_OR_ARTIFACT>...

FLAGS:
        --no-push-image
            Do not push image to remote registry (default: yes)

        --no-tag-latest             Do not tag image with :"latest" (default: no)
        --no-tag-version
            Do not tag image with :"{{pkg_version}}" (default: no)

        --no-tag-version-release
            Do not tag image with :"{{pkg_version}}-{{pkg_release}}" (default: no)

        --push-image                Push image to remote registry (default: no)
        --rm-image
            Remove local image from engine after build and/or push (default: no)

        --tag-latest                Tag image with :"latest" (default: yes)
        --tag-version               Tag image with :"{{pkg_version}}" (default: yes)
        --tag-version-release
            Tag image with :"{{pkg_version}}-{{pkg_release}}" (default: yes)

    -h, --help                      Prints help information
    -V, --version                   Prints version information

OPTIONS:
        --base-pkgs-channel <BASE_PKGS_CHANNEL>
            Install base packages from the specified release channel (default:
            stable)
        --base-pkgs-url <BASE_PKGS_DEPOT_URL>
            Install base packages from the specified Depot (default:
            https://bldr.habitat.sh/v1/depot)
    -c, --channel <CHANNEL>
            Install packages from the specified release channel (default: stable)

    -u, --url <DEPOT_URL>
            Install packages from the specified Depot (default:
            https://bldr.habitat.sh/v1/depot)
        --launcher-pkg <HAB_LAUNCHER_PKG>
            Launcher package identifier (ex: acme/redis) or filepath to a Habitat
            artifact (ex: /home/acme-redis-3.0.7-21120102031201-x86_64-linux.hart)
            to install (default: core/hab-launcher)
        --hab-pkg <HAB_PKG>
            Habitat CLI package identifier (ex: acme/redis) or filepath to a Habitat
            artifact (ex: /home/acme-redis-3.0.7-21120102031201-x86_64-linux.hart)
            to install (default: core/hab)
        --sup-pkg <HAB_SUP_PKG>
            Supervisor package identifier (ex: acme/redis) or filepath to a Habitat
            artifact (ex: /home/acme-redis-3.0.7-21120102031201-x86_64-linux.hart)
            to install (default: core/hab-sup)
    -n, --image-name <IMAGE_NAME>
            Image name (default: "{{pkg_origin}}/{{pkg_name}}" supports:
            {{pkg_origin}}, {{pkg_name}}, {{pkg_version}}, {{pkg_release}},
            {{channel}})
    -P, --password <REGISTRY_PASSWORD>
            Remote registry password, required for pushing image to remote registry

    -U, --username <REGISTRY_USERNAME>
            Remote registry username, required for pushing image to remote registry

        --tag-custom <TAG_CUSTOM>
            Tag image with additional custom tag (supports: {{pkg_origin}},
            {{pkg_name}}, {{pkg_version}}, {{pkg_release}}, {{channel}})

ARGS:
    <PKG_IDENT_OR_ARTIFACT>...
            One or more Habitat package identifiers (ex: acme/redis) and/or
            filepaths to a Habitat Artifact (ex: /home/acme-redis-3.0.7-
            21120102031201-x86_64-linux.hart)

```

Example Invocation
==================

This example will create and publish a `fnichol/redis` Docker image to
the Docker Hub with an additional tag of `:stable` from the `core/redis`
package. It will also clean up all image layers on the local Docker
engine when complete.

```
> hab-pkg-export-docker
    --image-name "fnichol/{{pkg_name}}" \
    --tag-custom "{{channel}}" \
    --push-image \
    --username "$DOCKER_USERNAME" \
    --password "$DOCKER_PASSWORD" \
    --rm-image \
    core/redis

» Building a runnable Docker image with: core/redis
Ω Creating build root in /tmp/hab-pkg-export-docker.zqwiZXbKFg1q
Ω Creating root filesystem
Ω Creating artifact cache symlink
» Installing core/hab from channel 'stable'
☛ Verifying core/hab/0.31.0/20170907232530
↓ Downloading core-20160810182414 public origin key
    75 B / 75 B | [=========================================] 100.00 % 768.82 KB/s
☑ Cached core-20160810182414 public origin key
✓ Installed core/hab/0.31.0/20170907232530
★ Install of core/hab/0.31.0/20170907232530 complete with 1 new packages installed.
» Installing core/hab-sup from channel 'stable'
☛ Verifying core/hab-sup/0.31.0/20170907230558
...
✓ Installed core/hab-sup/0.31.0/20170907230558
★ Install of core/hab-sup/0.31.0/20170907230558 complete with 13 new packages installed.
» Installing core/hab-launcher from channel 'stable'
☛ Verifying core/hab-launcher/4571/20170727193541
...
✓ Installed core/hab-launcher/4571/20170727193541
★ Install of core/hab-launcher/4571/20170727193541 complete with 2 new packages installed.
» Installing core/busybox-static from channel 'stable'
→ Using core/busybox-static/1.24.2/20170513215502
★ Install of core/busybox-static/1.24.2/20170513215502 complete with 0 new packages installed.
» Installing core/cacerts from channel 'stable'
→ Using core/cacerts/2017.01.18/20170513215104
★ Install of core/cacerts/2017.01.18/20170513215104 complete with 0 new packages installed.
» Symlinking basename from core/busybox-static/1.24.2/20170513215502 into /tmp/hab-pkg-export-docker.zqwiZXbKFg1q/rootfs/bin
★ Binary basename from core/busybox-static/1.24.2/20170513215502 symlinked to /tmp/hab-pkg-export-docker.zqwiZXbKFg1q/rootfs/bin/basename
...
» Symlinking hab from core/hab/0.31.0/20170907232530 into /tmp/hab-pkg-export-docker.zqwiZXbKFg1q/rootfs/bin
★ Binary hab from core/hab/0.31.0/20170907232530 symlinked to /tmp/hab-pkg-export-docker.zqwiZXbKFg1q/rootfs/bin/hab
Ω Creating cacerts symlink into /etc
» Installing core/redis from channel 'stable'
☛ Verifying core/redis/3.2.4/20170514150022
→ Using core/glibc/2.22/20170513201042
→ Using core/linux-headers/4.3/20170513200956
✓ Installed core/redis/3.2.4/20170514150022
★ Install of core/redis/3.2.4/20170514150022 complete with 1 new packages installed.
☒ Deleting artifact cache symlink
Ω Creating user 'hab' in /etc/passwd
Ω Creating group 'hab' in /etc/group
Ω Creating entrypoint script
Ω Creating image Dockerfile
Ω Creating Docker image
Sending build context to Docker daemon 121.5 MB
Step 1/7 : FROM scratch
 --->
Step 2/7 : ENV PATH /bin
 ---> Running in 3764fbf0fd48
 ---> 91f9e866d2a2
Removing intermediate container 3764fbf0fd48
Step 3/7 : ADD rootfs /
 ---> fedafdfabe25
Removing intermediate container 0856bccda165
Step 4/7 : VOLUME /hab/svc/redis/data /hab/svc/redis/config
 ---> Running in a0e74096f3dd
 ---> eeee2418cb88
Removing intermediate container a0e74096f3dd
Step 5/7 : EXPOSE 9631 6379
 ---> Running in 6892e787f824
 ---> bf594ae00b1c
Removing intermediate container 6892e787f824
Step 6/7 : ENTRYPOINT /init.sh
 ---> Running in e1925f651f79
 ---> a1c6d45e7924
Removing intermediate container e1925f651f79
Step 7/7 : CMD start core/redis
 ---> Running in 65890dc186b5
 ---> 21cca29fbcf2
Removing intermediate container 65890dc186b5
Successfully built 21cca29fbcf2
Successfully tagged fnichol/redis:3.2.4-20170514150022
Successfully tagged fnichol/redis:3.2.4
Successfully tagged fnichol/redis:latest
Successfully tagged fnichol/redis:stable
☒ Deleting temporary files
★ Docker image 'fnichol/redis' created with tags: 3.2.4-20170514150022, 3.2.4, latest, stable
Ω Creating build report /src/results/last_docker_export.env
» Pushing Docker image 'fnichol/redis' with all tags to remote registry
☒ Logging out of remote registry
Not logged in to https://index.docker.io/v1/
☛ Logging into remote registry
Login Succeeded
↑ Uploading image 'fnichol/redis:3.2.4-20170514150022' to remote registry
The push refers to a repository [docker.io/fnichol/redis]
e38a1bd11d52: Pushed
3.2.4-20170514150022: digest: sha256:aac65091cfeaa40a3bea3e5796ba6e463e60df6e6625fb622e22dbc7125f41e0 size: 529
✓ Uploaded image 'fnichol/redis:3.2.4-20170514150022'
↑ Uploading image 'fnichol/redis:3.2.4' to remote registry
The push refers to a repository [docker.io/fnichol/redis]
e38a1bd11d52: Layer already exists
3.2.4: digest: sha256:aac65091cfeaa40a3bea3e5796ba6e463e60df6e6625fb622e22dbc7125f41e0 size: 529
✓ Uploaded image 'fnichol/redis:3.2.4'
↑ Uploading image 'fnichol/redis:latest' to remote registry
The push refers to a repository [docker.io/fnichol/redis]
e38a1bd11d52: Layer already exists
latest: digest: sha256:aac65091cfeaa40a3bea3e5796ba6e463e60df6e6625fb622e22dbc7125f41e0 size: 529
✓ Uploaded image 'fnichol/redis:latest'
↑ Uploading image 'fnichol/redis:stable' to remote registry
The push refers to a repository [docker.io/fnichol/redis]
e38a1bd11d52: Layer already exists
stable: digest: sha256:aac65091cfeaa40a3bea3e5796ba6e463e60df6e6625fb622e22dbc7125f41e0 size: 529
✓ Uploaded image 'fnichol/redis:stable'
☒ Logging out of remote registry
Removing login credentials for https://index.docker.io/v1/
★ Docker image 'fnichol/redis' published with tags: 3.2.4-20170514150022, 3.2.4, latest, stable
» Cleaning up local Docker image 'fnichol/redis' with all tags
☒ Deleting local image 'fnichol/redis:3.2.4-20170514150022'
Untagged: fnichol/redis:3.2.4-20170514150022
☒ Deleting local image 'fnichol/redis:3.2.4'
Untagged: fnichol/redis:3.2.4
☒ Deleting local image 'fnichol/redis:latest'
Untagged: fnichol/redis:latest
☒ Deleting local image 'fnichol/redis:stable'
Untagged: fnichol/redis:stable
Untagged: fnichol/redis@sha256:aac65091cfeaa40a3bea3e5796ba6e463e60df6e6625fb622e22dbc7125f41e0
Deleted: sha256:21cca29fbcf2b5a47ffeaef8751cd3693dd02a3d9c954ce5d5f8a43bc3227f06
Deleted: sha256:a1c6d45e792437f74c9de2ef230826eeff89ae07aba92aae36b1a46bded3f1a2
Deleted: sha256:bf594ae00b1cb71d141e76cf72e81d214857b0082c5be55b4229c5a67c497fe6
Deleted: sha256:eeee2418cb8877c8599bdd8b52900873df91e760dfc8e86f4aac455fe2405157
Deleted: sha256:fedafdfabe2502343c820532b424735a87e4497030062291a303d38b7bba4573
Deleted: sha256:e38a1bd11d52d7e5a7e0ae32c17eaf31c29267c795d1df8167d500b23324abcc
Deleted: sha256:91f9e866d2a2ce9fe812542d9cf88a7ead1a011c38c7022c75e0bf927fe56fc4
★ Local Docker image 'fnichol/redis' with tags: 3.2.4-20170514150022, 3.2.4, latest, stable cleaned up
```

Signed-off-by: Fletcher Nichol <fnichol@nichol.ca>

Signed-off-by: Fletcher Nichol <fnichol@nichol.ca>
@thesentinels

This comment has been minimized.

Show comment
Hide comment
@thesentinels

thesentinels Sep 21, 2017

Contributor

💔 Travis CI reports this PR failed to pass the test suite.

The next step is to examine the job and figure out why. If it is transient, you can try re-triggering the Travis CI Job - if it passes, this PR will be automatically merged. If it is not transient, you should fix the issue and update this pull request, and issue approve again. If you believe it will never pass, and you are feeling :godmode:, you can issue a force to merge this PR anyway.

Contributor

thesentinels commented Sep 21, 2017

💔 Travis CI reports this PR failed to pass the test suite.

The next step is to examine the job and figure out why. If it is transient, you can try re-triggering the Travis CI Job - if it passes, this PR will be automatically merged. If it is not transient, you should fix the issue and update this pull request, and issue approve again. If you believe it will never pass, and you are feeling :godmode:, you can issue a force to merge this PR anyway.

@fnichol

This comment has been minimized.

Show comment
Hide comment
@fnichol
Member

fnichol commented Sep 21, 2017

@thesentinels approve

@thesentinels

This comment has been minimized.

Show comment
Hide comment
@thesentinels

thesentinels Sep 21, 2017

Contributor

🤘 I am testing your branch against master before merging it. We do this to ensure that the master branch is never failing tests.

Contributor

thesentinels commented Sep 21, 2017

🤘 I am testing your branch against master before merging it. We do this to ensure that the master branch is never failing tests.

@thesentinels

This comment has been minimized.

Show comment
Hide comment
@thesentinels
Contributor

thesentinels commented Sep 21, 2017

:neckbeard: Travis CI has started testing this PR.

@thesentinels

This comment has been minimized.

Show comment
Hide comment
@thesentinels

thesentinels Sep 21, 2017

Contributor

💖 Travis CI reports this PR passed.

It always makes me feel nice when humans approve of one anothers work. I'm merging this PR now.

I just want you and the contributor to answer me one question:

gif-keyboard-3280869874741411265

Contributor

thesentinels commented Sep 21, 2017

💖 Travis CI reports this PR passed.

It always makes me feel nice when humans approve of one anothers work. I'm merging this PR now.

I just want you and the contributor to answer me one question:

gif-keyboard-3280869874741411265

@thesentinels thesentinels merged commit 56a4cf1 into master Sep 21, 2017

2 of 3 checks passed

continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
DCO This commit has a DCO Signed-off-by line
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@thesentinels thesentinels deleted the fnichol/dockerize-rs branch Sep 21, 2017

@eeyun eeyun added I-linux and removed P-linux labels Mar 6, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment