Repository navigation
Docker
This document provides instructions on how to set up and run the infrastructure services using Docker Compose. The services included are PostgreSQL, Oracle Database and the oracle tables. Docker is a platform that enables developers to package applications into containers—standardized executable components that combine application source code with all the operating system libraries and dependencies required to run that code in any environment. Docker Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application's services, networks, and volumes. Then, with a single command, you create and start all the services from your configuration.
This setup uses Docker Compose to orchestrate multiple infrastructure services, making it easy to start, stop, and manage them as a unified environment.
Before you begin, ensure you have the following installed on your machine:
- Docker or Podman
- Docker Compose (or Podman Compose)
The Docker Compose configuration defines several infrastructure services that work together to support the Waste Plus application. The key infrastructure services are:
The PostgreSQL database serves as the primary data store for the modern backend service. This service:
- Runs PostgreSQL 13.23
- Listens on port
5432 - Uses the default credentials:
postgres/default - Is automatically initialized and migrated by the backend application on startup
The backend service connects to this database and handles all schema creation and data migrations internally. There is no need for external migration tools like Flyway for PostgreSQL, as the backend application manages its own database schema using its built-in migration capabilities.
The Oracle database is a legacy system that the legacy service connects to. This service:
- Runs Oracle Database Free 23.9
- Listens on port
1521 - Uses the schema user
THEwith passworddefault - Requires explicit migration scripts to set up the schema and initial data
Unlike the PostgreSQL database, the Oracle database requires manual schema management because it represents a legacy system with a fixed schema structure, and our legacy service expects this schema to be pre-defined.
The Flyway service is a dedicated migration tool that initializes and manages the Oracle database schema. This service:
- Runs automatically after the
legacydbservice is healthy - Executes SQL migration scripts from
legacy/src/test/resources/db/migration - Creates the necessary tables, views, and initial data in the Oracle database
- Only runs once during initial setup or when new migrations are added
Why Flyway for Oracle but not PostgreSQL?
The legacy Oracle database requires Flyway because:
- It represents a legacy system with a pre-defined, fixed schema
- The schema needs to be created from SQL scripts before the legacy service can use it
- The legacy service doesn't have built-in migration capabilities
The PostgreSQL database doesn't need Flyway because:
- The backend service is a modern Spring Boot application with built-in migration support
- The backend automatically creates and updates its database schema on startup
- This approach keeps database management logic within the application itself
To start the infrastructure services, navigate to the directory containing the docker-compose.yml file and run the following command:
docker compose up -d database legacydb legacyflywayThe most recent versions of Docker support the
docker composecommand natively. If you are using an older version, you may need to usedocker-composeinstead.
Depending on your company policies, you might need to use podman instead of docker. In that case, use the following command:
podman-compose up -d database legacydb legacyflywayThis command will start the PostgreSQL database, Oracle database, and Flyway migration service in detached mode.
Once the infrastructure services are up and running, you can start the backend and legacy services. The backend service will connect to the PostgreSQL database, and the legacy service will connect to the Oracle database.
Make sure to read the Backend Structure documentation for instructions on how to setup the required parameters for the backend and legacy services to connect to the databases.
In order for it to run, you can use the following command from the root of the project:
docker compose up -d backend legacyThis command will start both backend services in detached mode.
After the backend services are running, you can start the frontend service. The frontend service connects to the backend services to provide the user interface for the Waste Plus application.
To start the frontend service, use the following command from the root of the project:
docker compose up -d frontendMake sure to set all the appropriate environment variables for the frontend service to connect to the backend services. Refer to the Frontend Structure documentation for more details on the required configuration.
As you may have guessed, the provided docker-compose.yml file is a basic setup for local development and testing purposes, but it does not cover all the configuration options needed for each application. In order for it to work properly, you will need to set up your own configuration files or environment variables for each service. To avoid committing sensitive information to version control, it is recommended to use environment variable files (.env files) or the docker compose override feature to manage your configurations securely.
Docker Compose automatically loads environment variables from a .env file located in the same directory as your docker-compose.yml file. This is useful for managing configuration values that may differ between environments or contain sensitive information.
How to set up a .env file:
-
Create a new file named
.envin the root directory of the project (wheredocker-compose.ymlis located) -
Add your environment variables in the format
KEY=VALUE, one per line:# Database credentials POSTGRES_USER=myuser POSTGRES_PASSWORD=mysecretpassword POSTGRES_DATABASE=mydb # Application settings BACKEND_PORT=8080 LEGACY_PORT=9090
-
Reference these variables in your
docker-compose.ymlor override file using the${VARIABLE_NAME}syntax
Important: The .env file is already configured to be ignored by Git (listed in .gitignore), so you can safely store local configuration and secrets without accidentally committing them to version control.
For more information about environment variables in Docker Compose, refer to the official documentation.
Docker Compose supports an override mechanism that allows you to customize the configuration without modifying the base docker-compose.yml file. This is particularly useful for:
- Adding local development settings
- Overriding ports, volumes, or environment variables
- Enabling debugging features
- Mounting local code directories for hot-reload during development
How to use docker-compose.override.yml:
-
Create a new file named
docker-compose.override.ymlin the same directory asdocker-compose.yml -
Define only the services and settings you want to override or extend:
services: backend: environment: SPRING_PROFILES_ACTIVE: local DEBUG: "true" volumes: - ./backend/src:/app/src # Mount source code for hot-reload ports: - "8081:8080" # Use a different host port frontend: environment: VITE_API_URL: http://localhost:8081 command: npm run dev # Override to use dev mode
-
When you run
docker compose up, Docker Compose automatically mergesdocker-compose.ymlwithdocker-compose.override.yml
Key features of override files:
- Override files are applied on top of the base configuration
- You can override individual properties (like environment variables or ports) without duplicating the entire service definition
- Arrays (like
portsorvolumes) are merged, not replaced - The override file takes precedence when there are conflicts
Important: The docker-compose.override.yml file is also configured to be ignored by Git (listed in .gitignore), allowing you to customize your local setup without affecting other developers or the repository.
Alternative override files:
You can also use named override files for specific scenarios:
# Use a specific override file
docker compose -f docker-compose.yml -f docker-compose.dev.yml up
# Use multiple override files
docker compose -f docker-compose.yml -f docker-compose.dev.yml -f docker-compose.debug.yml upFor comprehensive information about Docker Compose override files and their behavior, consult the official Docker Compose documentation on extending services.
-
Never commit sensitive data: Both
.envanddocker-compose.override.ymlare git-ignored to prevent accidental commits of secrets -
Document required variables: Create a
.env.examplefile with placeholder values to help other developers understand what variables are needed -
Use override files for local customization: Keep the base
docker-compose.ymlgeneric and use override files for environment-specific settings - Keep it simple: Only override what you need to change; unnecessary overrides can make the configuration harder to maintain
This wiki documents NR Waste Plus for users and developers. Verify security and deployment guidance against the current application configuration before applying it elsewhere.
- Report an issue or ask a question in the GitHub repository.
- Follow the Contributing Guidelines to propose an update.
- Read the Code of Conduct.
Collection indexes support human browsing and machine retrieval. Keep both current when adding or moving wiki pages.
NR Waste Plus Wiki | GitHub Repository