Starter / example development environment for a project containing a Java and Python service running in Docker compose. It demonstrates a number of important concepts for efficient development in Docker, such as code watching, continuous testing, and some dependency management.
Created for the purpose of this article. Have a look if you would like to learn more.
Note that the article has been written for older versions of the mentioned software. This repository is still fairly up to date with latest methods though.
Services:
python: runsmypackage/run.pywithwatchmedofor live reload.python-tests: runspyteston file changes.java: runsmvn clean compile exec:javaon file changes.go: runsgo run .on file changes.postgres: backing database for both app services.pgadminer: Adminer UI onhttp://127.0.0.1:99.
Key files:
docker-compose.common.yml: base config shared across environments.docker-compose.dev.yml: dev overrides (volumes, watchers, local builds).docker-compose.prod.yml: prod image references.python/pyproject.toml: Python package metadata and dev deps.java/pom.xml: Maven config and plugins.go/go.mod: Go module metadata.
Build and run the dev stack:
docker compose -f docker-compose.common.yml -f docker-compose.dev.yml up --build
Stop everything:
docker compose -f docker-compose.common.yml -f docker-compose.dev.yml down
Run the Python tests once:
./python-tests.sh
Quick smoke test (build, start, basic health checks):
./smoke-test.sh
- Python deps live in
python/pyproject.toml. Dev tooling is in thedevextra, andpython/requirements.txtinstalls-e .[dev]for the containers. - Java dev mode uses
entrnon-interactively; it expects file change events underjava/src. - Go dev mode uses
entrto rungo run .on any*.gofile change. - The dev compose file uses local
build:for images. Registry image lines are kept as commented references.