Docker entypoint tool
Project description
Encab: A Docker Entrypoint Tool
Encab is essentially a replacement for complex, hand-written Docker Container Entrypoint scripts, especially when dockerizing complex legacy applications.
Add it as your Dockerfile Entrypoint,
together with the encab configuration file encab.yml
,
...
ADD encab.yml .
ENTRYPOINT ["encab"]
define what you want to run in your container in encab.yml
,
programs:
cron:
command: cron -f
main:
command: httpd-foreground
and encab cares for the rest. Run it and you'll always know who's logging what...
INFO encab: encab 0.0.1
INFO encab: Using configuration file ./encab.yml, source: Default location.
ERROR main: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
ERROR main: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
ERROR main: [Wed Jan 18 09:47:12.417275 2023] [mpm_event:notice] [pid 12:tid 140142563044672] AH00489: Apache/2.4.54 (Unix) configured -- resuming normal operations
ERROR main: [Wed Jan 18 09:47:12.417830 2023] [core:notice] [pid 12:tid 140142563044672] AH00094: Command line: 'httpd -D FOREGROUND'
INFO cron: Hello Wed Jan 18 09:48:01 UTC 2023
It shares some similarities with supervisord which I've used before I wrote encab but supervisord is a process controll system not designed to run in a Container environment.
Note
This tool is still under development. Sufficient for local experiments but not mature enough for production use!
Features
- run multiple programs in a container at a time with transparent logging
- run programs as different users
- handle environment variables in a flexible way
- simplify container debugging
- load, build, validate environment variables
Documentation
Installation
From Source
Encab is not yet at pypi so installation from source is the only option right now.
Prerequisites
- Docker from your Linux distribution or Docker Desktop.
- git distributed version control system
- Python Version >= 3.7
- activated Python virtual environment such as miniconda or virtualenv
Download
git clone https://github.com/skuebeck/encab.git
cd encab
pip install -r requirements.txt
Build Wheel
make dist
If all goes well, the encab wheel file will be in the dist
directory.
It's named encab-<version>-py3-none-any.whl
Testing (optional)
run unit tests:
make test
run localy:
python -m encab
It'll use the sample encab.yml
file.
The result will be something like this:
INFO encab: encab 0.0.1
INFO encab: Using configuration file ./encab.yml, source: Default location.
INFO encab: Dry run. No program will be started.
INFO encab: settings are valid.
INFO encab: settings are valid.
INFO encab: settings are valid.
INFO encab: Dry run succeeded. Exiting.
Deployment
-
Copy the generated wheel file into your Docker project directory.
-
Create a configuration file
encab.yml
(see Configuration section for details).programs: main: sh: echo 'Hello World'
-
Add Encab to your Docker file.
FROM python:3.10.8-slim-bullseye # -------------------------------------------- # Install Encab # ARG ENCAB_WHEEL=encab-0.0.1-py3-none-any.whl ENV PATH=$PATH:/root/.local/bin RUN python3 -m pip install --user pipx ADD ${ENCAB_WHEEL} . RUN python3 -m pipx install ./${ENCAB_WHEEL} # ------------------------------------------- # add configuration file # ADD encab.yml . # ------------------------------------------- # set encab as entrypoint ENTRYPOINT ["encab"]
-
Build container
docker build --build-arg ENCAB_WHEEL=`ls encab-*.whl` -t encab_minimum .
-
Run container
docker run encab_minimum
Result:
INFO encab: encab 0.0.1 INFO encab: Using configuration file ./encab.yml, source: Default location. INFO main: Hello world! INFO main: Exited with rc: 0
Similar Projects
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file encab-0.0.2.tar.gz
.
File metadata
- Download URL: encab-0.0.2.tar.gz
- Upload date:
- Size: 23.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1746fa21cf0569fbd6e8b6f530a6e1e49a394fecf3e737dba44342214103c340 |
|
MD5 | 18729b716cea3626b792df8081a43c77 |
|
BLAKE2b-256 | 4d3993a3c2fc304b4bd25515ac49d969d44cccfe6cda35db95aa720c2b448aa3 |
File details
Details for the file encab-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: encab-0.0.2-py3-none-any.whl
- Upload date:
- Size: 26.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9baafd64e1e3d74308947271443341b0aeb632f2bb56308e0288bbe5b34fb000 |
|
MD5 | 15fad998fed1902f6324f46456632f04 |
|
BLAKE2b-256 | e1cfe9984e32f68ba27f074e08d83d096d03334b30b2e8236c6fe078ecf807d9 |