dork-compose
is a drop in replacement for the docker-compose command line
tool, adding some convenience features for running multiple compose projects on
the same host.
- Volume snapshots with automatic versioning.
- Separation of Docker setup (
Dockerfile
anddocker-compose.yml
) from application source code. - Automatic launch of and connection to auxiliary services, like nginx or a DNS server.
- Your local development workstation, hosting multiple different projects built on the same framework, and therefore requiring similar infrastructure and setup steps.
- A staging server running multiple versions of the same project, doing fast upgrade testing by using volume snapshots.
- A continuous integration server, running automatic tests on pull requests.
dork-compose
uses the same installation procedures as docker-compose.
Either using pip:
pip install dork-compose
Everything dork-compose
does additionally to docker-compose
is implemented
using plugins. The DORK_PLUGINS
environment variable controls which plugins
are loaded and in which order they are executed. Plugins are able to alter
environment variables, modify the configuration from docker-compose.yml
and
act on certain events throughout the docker-compose
command processes.
By default the DORK_PLUGINS
variable looks like this:
export DORK_PLUGINS="env:multi:lib:autobuild:hotcode:filesystem:proxy:dns:vault"
That's the default workstation setup. Plugins are executed from left to right.
If two plugins to the same, the right one wins.
Let's run through this example:
-
env: Scans parent directories for
.env
or.dork.env
files and populates the environment with their contents. -
multi: Run multiple different projects on the same host. The project name will be the name ofthe containing directory. It is used to prefix snapshots and build the domain.
-
lib: If there is a
DORK_LIBRARY
environment variable that contains a valid directory,dork-compose
will assume thedocker-compose.yml
is there.dork-compose
will take care of handling the container build process accordingly. -
autbuild: Automatically build docker images of application sources if using onbuild images.
-
hotcode: Mount code directories you work on into your local codebase and provide vendor code to your IDE.
-
filesystem: Implements snapshots as plain rsync. Not particularly fast or disk space economic, but works out of the box everywhere.
-
proxy: Spins up a proxy service that serves your project at http://project.dork.io.
-
dns: Runs a dns server and configures your system to use it. Enables you to use the domain
dork.io
. -
vault: Exposes secrets (e.g. the github private token) to the build process without leaving any traces in the image.
There are no configuration files. Plugins can be configured using environment variables, which you define in your shell environment for by using the env plugin. For a complete list of plugins and their options please refer to Appendix: Plugins. For an in-action example of these plugins, please refer to the drupal-simple in the recipes repository.
It's possible to create and load custom plugins. Simply create a Python file
with one class called Plugin that extends dork_compose.plugin.Plugin
and
attach it to the DORK_PLUGINS
variable:
export DORK_SOURCE="env:multi:lib:autobuild:hotcode:dependencies:filesystem:proxy:dns:vault:my_plugin=~/path/to/myplugin.py"
For example plugins have a look at the plugins
directory inside the dork-compose
source.
dork-compose
is able to create snapshots of all data volumes used in a compose
project. This is done by using the additional dork-compose snapshot
command.
For an example of how to work with snapshots, please refer to the
drupal-simple example in the recipes repository.
Snapshots are organized in projects and instances. dork-compose
assumes
that instances of the same project are compatible. Aside from building the proxy
domain, the major purpose is to restrict snapshots to be used by instances of
the same project only.
The current project and instance is determined by plugins (like multi in
the default setup) or by the DORK_PROJECT
and DORK_INSTANCE
environment
variables.
If the snapshot identifier is omitted from the snapshot save
and
snapshot load
command, dork-compose
will rely on plugins to provide one.
The git plugin in the default setup for example will store snapshots by the
current HEAD hash and will try to load the closest available ancestor to the
current checkout. This avoids breaking your development database by switching
between feature branches.
TODO: explain all builtin plugins.