The deployment of Etendo as a Docker image involves setting up a containerized environment where the Etendo application runs within a Docker container, orchestrated by Docker Compose. This setup ensures a consistent and isolated environment, making the deployment process more streamlined and less prone to errors due to variations in the underlying host system.
Docker Container: A lightweight, standalone, executable package that includes everything needed to run the Etendo application - code, runtime, system tools, libraries, and settings.
Docker Compose: A tool for defining and running multi-container Docker applications. It uses a YAML file (docker-compose.yml
) to configure the application's services, networks, and volumes.
Dockerfile: A text file containing a series of commands used to assemble the Docker image for the Etendo application.
PostgreSQL Container: A separate container running the PostgreSQL database, linked to the Etendo application container for data storage.
Volumes: Persistent storage used by Docker containers, particularly for the PostgreSQL database, to ensure data persistence across container restarts and updates.
Network: An isolated network created by Docker Compose, allowing containers to communicate with each other.
Building the Image: The Dockerfile defines the steps to build the Etendo application image, starting from a base Java image, adding the application code, and configuring the necessary environment.
Defining Services: The docker-compose.yml
file describes the services (Etendo app and PostgreSQL database), their configuration, networks, and volumes.
Running the Containers: Docker Compose reads the docker-compose.yml
file and starts the containers as defined. The Etendo application container connects to the PostgreSQL container for database operations.
Accessing the Application: Once the containers are running, the Etendo application becomes accessible on the specified port.
Isolation: Each component (application and database) runs in its own container, providing isolation and reducing conflicts between different environments.
Scalability: Docker Compose allows for easy scaling of the application, facilitating the management of multiple instances.
Portability: The Docker setup ensures that the application can be easily moved and deployed across different environments without compatibility issues.
Ease of Deployment: Streamlines the deployment process, reducing the complexity and potential errors associated with manual setups.
Multi-stage builds in Docker allow you to create cleaner Docker images by separating the build process into multiple stages. This method is particularly useful for applications like Etendo, where the build process involves several steps and potentially requires different tools and environments.
First Stage: Building the Application (as builder
)
java jdk
as the base image../gradlew setup
, ./gradlew install
or ./gradlew update.database
, and ./gradlew smartbuild
) to compile and prepare the application../gradlew antWar
) for deployment.Second Stage: Creating the Runtime Image
tomcat
as the base image for the runtime environment.etendo.war
file from the builder
stage. This is the key step that ensures the final image does not contain the source code, only the compiled application.The final Docker image created by this Dockerfile contains only the necessary components to run the Etendo application on a Tomcat server. It includes the WAR file (etendo.war
) but does not include the source code or any of the build tools used in the first stage. This approach ensures that the final image is optimized for size, security, and performance.
By using multi-stage builds, you effectively separate the build environment from the runtime environment, resulting in a clean, minimal final Docker image for deployment.
Clone the Etendo repository:
git clone https://github.com/etendosoftware/etendo
Copy gradle.properties
from the template:
cp gradle.properties.template gradle.properties
If you already have a custom Etendo source folder, ensure it is named "etendo" and proceed with the next steps.
Copy the .env
file from the template:
cp .env.template .env
Edit .env
to include your GitHub credentials:
GITHUB_USER=[Your GitHub Username]
GITHUB_TOKEN=[Your GitHub Token]
For macOS Users: Uncomment the following line to the .env file to configure the host address:
HOST_ADDRESS=host.docker.internal
This setting is necessary to ensure proper networking behavior on macOS systems.
Open gradle.properties
(ensure it's already in your existing source or created in Option A) and set your GitHub credentials:
githubUser=[Your GitHub Username]
githubToken=[Your GitHub Token]
To build and start the PostgreSQL database, run:
docker compose up -d postgres
In case of a fresh start (needed for Step 1 Option A), for the initial build (with database installation):
docker compose build --build-arg network=host --build-arg INSTALL=true
For subsequent builds:
docker compose build --build-arg network=host
To start the Tomcat server with the Etendo deployment:
docker compose up -d
Once the application is up, you can access it at http://localhost:8080/etendo
.
.env
.For more detailed information about Etendo, visit the official documentation.