Metadata-Version: 2.1
Name: dugaire
Version: 0.0.3
Summary: Build Docker images with custom packages for local development, testing and daily tasks.
Home-page: https://github.com/tadeugr/dugaire
Author: Tadeu Granemann
License: Apache License, Version 2.0
Platform: UNKNOWN
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 3
Description-Content-Type: text/markdown
Requires-Dist: certifi (==2020.11.8)
Requires-Dist: chardet (==3.0.4)
Requires-Dist: click (==7.1.2)
Requires-Dist: docker (==4.3.1)
Requires-Dist: idna (==2.10)
Requires-Dist: Jinja2 (==2.11.2)
Requires-Dist: MarkupSafe (==1.1.1)
Requires-Dist: requests (==2.25.0)
Requires-Dist: six (==1.15.0)
Requires-Dist: urllib3 (==1.26.2)
Requires-Dist: websocket-client (==0.57.0)

# Build Docker images with custom packages

Install `vim` and `curl` using `apt-get`.

```
docker run -it --rm $(dugaire build -apt=vim,curl)
```

Install `vim`, `python3`, `pip3` using `apt-get` and install `ansible` using `pip3`.

```
docker run -it --rm $(dugaire build -apt=vim,python3-pip -pip3=ansible)
```

Install `kubectl` binary version `v1.15.0` (use `--with-kubectl=latest` to install the latest version).

```
docker run -it --rm $(dugaire build -apt=vim --with-kubectl=1.15.0)
```

# Install (on Linux)

Clone this repository.

```
git clone https://github.com/tadeugr/dugaire.git
```

`cd` to its directory.

```
cd dugaire
```

Install it (`pip3` is a requirement).

```
make install
```

You should have the command available.

```
dugaire build --help
```

# Usage

```
Usage: dugaire build [OPTIONS]

  Build Docker images with custom packages.

  Examples:

  Build an image and install vim and curl using apt-get.

  $ dugaire build -apt=vim,curl

  Build an image and install python3 using apt-get and ansible using pip3.

  $ dugaire build -apt=python3-pip -pip3=ansible

  Build an image and install the latest version of kubectl.

  $ dugaire build --with-kubectl=latest

Options:
  -apt, --apt-install TEXT        Comma separeted list of packages (no blank
                                  space) to install using apt-get install.
                                  Example: -apt=curl,vim

  -pip3, --pip3-install TEXT      Comma separeted list of packages (no blank
                                  space) to install using pip3 install.
                                  WARNING: requires -apt=python3-pip. Example:
                                  -apt=python3-pip -pip3=ansible,jinja2

  --with-kubectl TEXT             Install kubectl version. Examples: --with-
                                  kubectl=latest / --with-kubectl=1.17.0

  -n, --name TEXT                 Image name.  [default: random]
  --dry-run                       Do not build image.  [default: False]
  -o, --output [image-id|image-name|dockerfile]
                                  Command output options.  [default: image-id]
  --help                          Show this message and exit.
```

# Supported features

## Base images

* `ubuntu:18.04`

## Package/Dependency managers

* `apt-get`: you can install any package using `apt`. Use a comma separated (no blank space) list of packages you want to install. Example: `-apt=wget,iputils-ping`

* `pip3`: you can install any package using `pip3`. Use a comma separated (no blank space) list of packages you want to install. Example: `-pip3=jinja2,pyyaml`. **WARNING** to use `pip3` you must explicitly install `pip3` using `apt`: `-apt=python3-pip`.

## Packages

* `kubectl`: use the parameter `--with-kubectl=latest` to install the latest version. For specific versions use the following format: `--with-kubectl=1.17.0`

# Useful commands

## List images generated by dugaire

```
docker images -f label='builtwith=dugaire'
```

# Known issues

## RuntimeError: Python 3 was configured to use ASCII as encoding for the environment

If you get an error like this one:

```
RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment. Consult https://click.palletsprojects.com/python3/ for mitigation steps.
```

It is because `dugaire` uses Python3 and [Click](https://github.com/pallets/click), and according to Click "in Python 3, the encoding detection is done in the interpreter, and on Linux and certain other operating systems, its encoding handling is problematic". [Read more](https://click.palletsprojects.com/en/5.x/python3/#python-3-surrogate-handling).

### Solution

Setup your locale correctly, for example if you are using `en_US.UTF-8`, run:

```
apt update && apt-get -y install locales
locale-gen --purge en_US.UTF-8

export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"

# Alternatively you can run: 
#sudo dpkg-reconfigure locales
```

Then you should be able to run `dugaire`.

