Docker-Wrap
A drop-in wrapper for docker-compose that runs pre/post up and pre/post build scripts.
I frequently have scripts I want to run before/after docker-compose
build/up. This wrapper creates a standard way to run everything by
just wrapping docker-compose and passing through all arguments. You
use it wherever you normally use docker-compose. You could even
symlink it as docker-compose in your /usr/local/bin.
The wrapper is smart enough to run your pre-build, even when build is
triggered by an up command.
The pre-build script runs before Dockerfile is loaded, so you can
generate your Dockerfile from your pre-build script.
If you're just pulling an image and not building a new image, the pre/post build script does not run.
Install
If you want to install system-wide but also have edits you make here reflected in that system-wide install:
python3 -m setup develop
Or just install it like you normally would:
python3 -m setup install
Eventually, this will work, but I haven't uploaded it to PyPi yet:
pip3 install docker-wrap
Use
For any service, add an associative array x-wrap with one or more
keys whose values are associative arrays named build or use.
Those associative arrays should contain pre or post keys whose
values are paths to scripts to run. See the example below.
docker-wrap will run any pre script before it runs your command,
then run any post script. A future feature will that be if a pre
script prints a valid yaml structure, docker-wrap will use that
script as the docker-compose.yml for running the command.
docker-wrap passes all arguments on to docker-compose.
Something like this would work:
docker-wrap up foo
Sample docker-compose.yml
version: "3.9"
services:
foo:
x-wrap:
build:
pre: pre-build.sh bar baz
build: bar
The default directory for running pre-build.sh will be the foo
directory. If you set context, it will be the context.
Features Roadmap
[X] Pre/post build scripts
[X] Allow pre script to replace Dockerfile
[ ] Allow pre script to replace docker-compose
[X] Pre/post up scripts
[ ] Use wrap instead of x-wrap
[ ] pip installable
Contributing
Activity is in the GitHub Repo and you can always pop in to chat.opentechstrategies.com as well.
Please run the python qa script on the code before submitting a PR. That script just runs black, isort, mypy, and tests (tho we have no tests yet).
License and Copyright
Copyright 2020 James Vasile, published under the terms of AGPLv3 or later.
Metadata
Release files for docker-wrap 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| docker-wrap-0.0.1.tar.gz | 16.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| docker_wrap-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.1 kB
Release files / docker-wrap-0.0.1.tar.gz
| Download URL | docker-wrap-0.0.1.tar.gz |
|---|---|
| Size | 16.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
296503258d3f584b51eb239a877c6c850107bf0a6eb854b304c65ca1d2a7045c
|
|
BLAKE2b-256 checksum How to use checksums |
5c3eca70d60d55379f576efa8c15167e8f54a678eabeb2d08107431827be6265
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2
|
Release files / docker_wrap-0.0.1-py3-none-any.whl
| Download URL | docker_wrap-0.0.1-py3-none-any.whl |
|---|---|
| Size | 17.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ae58cdc6b052d25d8c1eb86b58afa003b1494ee5ce89c5d13790a64f03055196
|
|
BLAKE2b-256 checksum How to use checksums |
045129ea65ed8795b51ad3917e81b8e9733df888a8ff1d2295d3e684f2fd11e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2
|
Security for docker-wrap 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.