Docker Deployment
Overview
The Ed-Fi ODS Docker deployment scripts install and configure components of the Ed-Fi ODS / API on Docker containers. The example Docker Compose files automate the numerous configuration steps required to get the ODS / API up and running on Linux containers backed by PostgreSQL or an external SQL Server. These scripts can be used for scenarios where a default ODS / API is needed without extensions or customizations.
Please have a look at Ed-Fi Docker Compose Architecture for more information on the components and configuration options provided by the Ed-Fi Docker solution.
The Ed-Fi Alliance does not have expertise in production deployments. Before you deploy into a production environment, please review and adjust the orchestration appropriately for your needs.
If running in a cloud provider, it might be wise to use native services to host the containers. In such situations, using the provided NGiNX container as a reverse proxy might not be necessary or advisable. Similarly, PgBouncer might not be required in some cases. The roles played by NGiNX and PgBouncer are explained in the following section.
Running in Docker Desktop
Docker Containers have the added benefit of running anywhere (e.g., VMs, on-premises, in the cloud), which is a massive advantage for both development and deployment. Leading cloud providers, including Google Cloud, Amazon Web Services (AWS), and Microsoft Azure, have adopted it. For simplicity, the steps below describe how to use Docker Compose to deploy the Ed-Fi ODS/API and related tools on Docker Desktop.
Setup
Step 1. Download the Source Code or Clone the Repo
The Ed-Fi ODS Docker deployment source code is in the Ed-Fi repository hosted by GitHub. A link to the repository is provided in the download panel on the right. You can clone the repository or download the source code as a ZIP file.
Step 2. Setup Runtime Environment
2a. Docker Desktop
To work with the material in this repository, set up a Docker environment by referring to the article Set Up Your Docker Environment.
2b. Microsoft SQL Server
Experimental - this is not a widely tested deployment path.
The default configurations use PostgreSQL. The Ed-Fi Alliance does not distribute pre-configured Microsoft SQL Server (MSSQL) containers. To run with MSSQL instead of PostgreSQL, whether MSSQL is running in Docker, as a managed cloud service, or on a "bare metal" / on-prem virtual machine, you must install the databases yourself. The following notes will help guide a decision and approach,
Step 3. Setup Your Environment Variables
Configure your deployments using an environment file. The repository includes a .env.example listing the supported environment variables. Copy .env.example file and name it .env. Update the values as desired.
Sample .env files for a PostgreSQL and SQL Server are provided below. Please change these values to more secure settings before using them in a deployed environment.
The LOGS_FOLDER
is a local directory for permanent storage of log files, and thus, the file path is on the Docker Desktop host, not inside a container. In Windows, use forward slashes rather than backslashes.
Values containing tokens such as ${xyz}
are variable insertions you do not need to change.
Step 4. Provide SSL certificate
The deployments require a valid SSL certificate to function. A self-signed certificate can be used for a Non-Production environment. The repository includes generate-cert.sh script that can be used to generate a self-signed certificate and place it in the ssl
folder under the root directory to be used by the running Gateway container.
If deploying on a local Windows host, you will need Git Bash or WSL to run generate-cert.sh.
Step 5. Run Docker Compose
In this step, you need to choose between deploying a Sandbox, SingleTenant, SingleTenant with ODS Context routes, MultiTenant, or MultiTenant with ODS Context routes environment, as described in Docker Compose Architecture: ConfigurationModes. The source code repository contains a Docker compose orchestration file for each scenario. The sample commands below show the use of the published images from Docker Hub. These commands can be run from any shell terminal that supports Docker commands (e.g., PowerShell in Windows).
Powershell scripts are also provided for each scenario; the up script will set up a new environment, and the -clean script will remove containers and volumes. These scripts should be executed from the repository root and require a .env file at the root level.
Using SQL Server Instead of PostgreSQL
The Docker Compose file does not create SQL Server databases; this means that EdFi_Admin and EdFi_Security databases should already exist within the server defined by SQLSERVER_ADMIN_DATASOURCE
in the .env file. Similarly, the ODS databases for desired school years should already exist with the correct naming convention described for each configuration below.
Sandbox Environment
SingleTenant Environment
SingleTenant with ODS Context Routes Environments
Notice that the compose file provided in the repository is an example that defines ODS for the years 2022 and 2023. You can generate the compose file for the desired school years.
MultiTenant Environments
Notice that the compose file provided in the repository is an example that defines Tenant1 and Tenant2 with one ODS database each. You can generate the compose file for desired tenants.
MultiTenant with ODS Context Routes Environments
Notice that the compose file provided in the repository is an example that defines Tenant1 and Tenant2 with years 2022 and 2023 each. You can generate the compose file for desired tenants and school years.
Step 6. Verify Your Deployments
You can just open your Docker Desktop instance and view running container instances.
The following image shows Sandbox Postgres deployment:
You can also verify deployed applications by browsing to:
- Swagger UI: https://localhost/
- ODS / API: https://localhost/api
- Sandbox Admin: https://localhost/admin
The exact virtual name for each site after "https://localhost/" depends on your .env
file settings.
The following image shows Single Tenant Postgres deployment:
You can also verify deployed applications by browsing to:
- ODS / API: https://localhost/api
- Admin Api : https://localhost/adminapi
The following image shows Single Tenant with Ods Context Postgres deployment:
You can also verify deployed applications by browsing to:
- ODS / API: https://localhost/api
- Admin Api : https://localhost/adminapi
The following image shows Multi Tenant Postgres deployment:
You can also verify deployed applications by browsing to:
- ODS / API: https://localhost/api
The following image shows Multi Tenant with Ods Context Postgres deployment:
You can also verify deployed applications by browsing to:
- ODS / API: https://localhost/api
Step 7. Accessing Application Log Files
The ODS/API, Admin App, and Sandbox Admin write their internal log entries to a mounted folder within their docker containers. The environment file described in Step 3 lets you configure the log location for easy access. For example, you could set the LOGS_FOLDER variable to c:/tmp/logs for Windows hosts or to ~/tmp/logs for Linux and MacOS hosts.
Tear Down
If deployed as a sandbox environment, navigate to the root directory of Docker deployment scripts and run the following command:
If deployed as a single tenant environment, navigate to the root directory of Docker deployment scripts and run the following script:
If deployed as a single tenant with an ods context environment, navigate to the root directory of Docker deployment scripts and run the following script:
If deployed as a multi tenant environment, navigate to the root directory of Docker deployment scripts and run the following script:
If deployed as a multi tenant with an ods context environment, navigate to the root directory of Docker deployment scripts and run the following script:
Additional Docker Tips
- Add the argument
--remove-orphans
if the Docker Compose file has changed and you want to clear out old images that are no longer in use. - If you also wish to remove the local volumes used for persistent storage, add
-v
to thedocker compose ... down
command. - You can use the rmi command to clean up local copies of images if you don't want to use them again and to reclaim disk space.