A batteries-included, fully containerized Java (Gradle) project template. (With IntelliJ support)
- Docker
- traefik-localdev instance
By default, the template has the following structure:
java-project/ # Project root
|-- config/ # Configuration files
|-- docs/ # Project documentation
|-- gradle/ # Gradle wrapper and properties
|-- src/ # Actual Java source code
|-- build.gradle # Gradle build configuration
|-- settings.gradle # Gradle settings file
|-- gradlew # Gradle wrapper script (Unix)
|-- gradlew.bat # Gradle wrapper script (Windows)
|-- .env.example # Example .env file (template for .development.env and .production.env)
|-- .init.env.example # Example .init.env file, used for initializing a new MariaDB instance
|-- Dockerfile # Dockerfile describing the project assembly
|-- docker-compose.development.yml # Docker Compose file describing the hosting stack used for development
|-- docker-compose.production.yml # Docker Compose file describing the hosting stack used for production
Dynamic configuration (like domain name, database settings, ...) gets done with .env files. Both compose files (production and development) source their own .env file (.production.env
and .development.env
respectively). An example .env is provided in this repository.
For the initialization of a MariaDB database, the .init.env
file can be used to set an additional user, create an empty database and changing the root user's password. An example of this file is also provided in this repository.
-
Create a .development.env file to configure your project instance
-
(Optional) Create an .init.env to initialize the MariaDB instance
-
Launch hosting stack:
docker compose --env-file .development.env -f docker-compose.development.yml up -d
All source code and configuration files are accessible for the container through "bind" mounts. You can edit them on the fly, without the need to restart the Docker container.
-
Create a .production.env file to configure your project instance
-
(Optional) Create an .init.env to initialize the MariaDB instance
-
Create a docker-compose.hosting.yml with the necessary networking and proxy configuration. You can see an example in the docker-compose.hosting.yml.example file.
-
Launch hosting stack:
docker compose --env-file .production.env -f docker-compose.production.yml -f docker-compose.hosting.yml up -d
The source code, dependencies and configuration files are baked into the Docker image. The SQL database storage is mounted as Docker volumes.