Encapsulate your project's development environment inside a Docker container.
This repository is distributed under the terms of the Apache 2.0 license.
Installation in a project is a short manual process, detailed as follows:
- Copy/paste all files in
/src
into your project's/docker
directory. - Also create a
Dockerfile
in your project's/docker
directory to define its development environment. This image is not intended to run in production, just during development. You should use one of the templates in/templates
as a starting point. - Optionally, create a
compose.yaml
file in your$HOME/.config/docker-env
directory using theuser.compose.yaml
template in/templates
. This file will be used to mount your personal configurations in your development containers. - Run
./docker/env.sh init
Now you're ready to start using docker-env
in your project. Run ./docker/env.sh --help
for
more information on general usage.
You should create an alias for ./docker/env.sh
as it's going to be tedious to type it all the
time otherwise.
To speed up development and continuous integration, it's recommended to push your dev image to
your organization's registry. Doing so will allow docker-env
to pull its latest version and
use it as cache when rebuilding the image. To do so, simply set the registry variable in your
environment:
export DOCKER_ENV_REGISTRY="ghcr.io/<FOO>" # or any other container registry
Assuming your Docker daemon is running:
./docker/env.sh init
To pull and/or build the image and create host files../docker/env.sh up
To create and start a dev container../docker/env.sh shell
To open a shell inside the running dev container.- Develop (optionally, attach your editor/IDE to the running dev container).
exit
to close the shell and return to the host computer../docker/env.sh down
To stop and remove the running dev container.
Again, using a
$HOME/.config/docker-env/compose.yaml
file will allow you to mount your personal configurations in the container for a more familiar environment.
./docker/env.sh init
To pull and/or build the image and host files../docker/env.sh up
To create and start a dev container../docker/env.sh exec COMMAND
To run a command inside the dev container (like running tests)../docker/env.sh down
To stop and remove the running dev container.
You can also use the
tag
,push
andpull
subcommands to manage your dev image registry versioning.
git clone [email protected]:logisparte/docker-env.git
cd docker-env
git config --local core.hooksPath "$PWD/hooks"
The git hooks will format and lint code before commit, and the git messages will be linted using
commitlint
.
The docker-env
project uses itself to encapsulate its development environment inside a Docker
container! To achieve this, there are some symlinks set up in /docker
that point to the source
files alongside the project's Dockerfile
. This allows to have quick, local feedback on
changes.
shfmt is used to format shell files. Prettier is used to format markdown and yaml files. To format dirty files:
./scripts/format.sh
To format all files:
./scripts/format.sh all
ShellCheck is used to analyze shell code. MarkdownLint is used to analyze markdown code. To analyze dirty files:
./scripts/lint.sh
To analyze all files:
./scripts/lint.sh all