https://github.com/keens/cargo-pack-docker
a cargo subcommand to package your application into a docker image
https://github.com/keens/cargo-pack-docker
cargo cargo-subcommand rust
Last synced: 5 months ago
JSON representation
a cargo subcommand to package your application into a docker image
- Host: GitHub
- URL: https://github.com/keens/cargo-pack-docker
- Owner: KeenS
- Created: 2017-02-22T06:59:00.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2020-02-19T07:09:33.000Z (almost 6 years ago)
- Last Synced: 2025-07-25T00:01:25.456Z (6 months ago)
- Topics: cargo, cargo-subcommand, rust
- Language: Rust
- Homepage:
- Size: 85.9 KB
- Stars: 19
- Watchers: 5
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
[](https://travis-ci.org/KeenS/cargo-pack-docker)
[](https://ci.appveyor.com/project/KeenS/cargo-pack-docker/branch/master)
# cargo-pack-docker
A [`cargo-pack`](https://github.com/KeenS/cargo-pack)er for docker; package your application into a docker image to deploy without Dockerfile
THIS PRODUCT IS ALPHA STATUS. USE AT YOUR OWN RISK
# install
## Built binary
see releases
## building
```
cargo install cargo-pack-docker
```
# Usage
```
cargo pack-docker [-p package] [--release] [TAG]
# if your configurated tag in Cargo.toml is hoge:0.1.0, the TAG will be hoge
# if TAG is omitted and you have only one `[[package.metadata.pack.docker]]` section, it will be used
```
# Configulation
``` toml
# configuration of cargo-pack
[package.metadata.pack]
default-packers = ["docker"]
# files will be placet to /opt/app
files = ["README.md"]
# configuration of cargo-pack-docker
[[package.metadata.pack.docker]]
# tag of the created image. Can be omitted.
# Default to PACKAGE_NAME:latest for debug profile
# and PACKAGE_NAME:PACKAGE_VERSION for release profile
tag = "hoge:0.1.0"
# base image of the docker image. Required.
base-image = "ubuntu:16.04"
# the bin to include into the docker image.
# will be placed to /opt/app/bin/
# can be omitted if the project have only one binary target.
bin = "aaa"
# `ENTRYPOINT` of Dockerfile. optional.
entrypoint = ["aa", "bb"]
# `CMD` of Dockerfile. optional.
cmd = ["c", "d"]
# inject command into the Dockerfile. optional
inject = "
ENV RUST_LOG debug
RUN apt install libpq-dev
"
# you can write another configuration
[[package.metadata.pack.docker]]
base-image = "ubuntu:16.04"
bin = "bbb"
```
with the first configuration, build a docker image with this Dockerfile content:
```
FROM ubuntu:16.04
RUN mkdir -p /opt/app/bin
COPY README.md /opt/app
COPY aaa /opt/app/bin
WORKDIR /opt/app
ENV RUST_LOG debug
RUN apt install libpq-dev
ENTRYPOINT ["aa", "bb"]
CMD ["c", "d"]
```
# Running cargo-pack-docker in docker
There are images
[blackenedgold/cargo-pack-docker](https://hub.docker.com/r/blackenedgold/cargo-pack-docker/)
.
To build a docker image using the cargo-pack-docker docker image, run this command.
``` console
docker run \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `which docker`:/usr//bin/docker \
-v $(pwd):/tmp/app \
-w /tmp/app
blackenedgold/cargo-pack-docker \
cargo pack-docker
```
and if you prefer docker-compose, use this yaml fragment.
``` yaml
build:
image: blackenedgold/cargo-pack-docker:0.4.0-rust-1.32.0
command: cargo pack-docker
working_dir: /tmp/app
volumes:
- ./ /tmp/app
- /var/run/docker.sock:/var/run/docker.sock
# your path to docker
- /usr/bin/docker:/usr/bin/docker
```