Docker Deployment
Deploying Oxy using Docker containers
This guide explains how to deploy Oxy using Docker containers, providing an alternative to the traditional server-based deployment approach.
Using Docker simplifies the deployment process and environment setup, making it easier to run Oxy in a consistent environment across different platforms.
Prerequisites
Before you start, ensure you have:
- Docker installed on your host system
- An Oxy workspace with your configuration files, agents, and workflows
- Required API keys and environment variables for your deployment
We recommend your Docker host machine have a minimum of 4GB RAM for optimal performance of Oxy and related services.
Quick Start
The fastest way to get started with Oxy on Docker is to use the pre-built image from GitHub Packages:
Why Use Docker Compose?
Docker Compose lets you define and manage multi-container applications with a single YAML file. For Oxy, Compose makes it easy to:
- Start Oxy and related services (like databases or proxies) with one command
- Configure environment variables, volumes, and ports in one place
- Ensure all containers are networked and started in the right order
- Reproduce your deployment setup easily across machines or teams
In short: Docker Compose simplifies running Oxy in production or development, especially when you need more than one container.
Reference Architecture Diagram
Detailed Deployment Steps
Prepare Your Workspace
Before deploying, ensure you have an Oxy workspace ready with your configuration files. Your workspace directory should typically include:
config.yml
- Main configuration file- Your agent definitions (
.agent.yml
files) - Your workflow definitions (
.workflow.yml
files) - Any other resources your agents and workflows need
Create a Docker Compose File
For easier management, create a docker-compose.yml
file:
Replace your-openai-api-key
with your actual OpenAI API key. For production deployments, consider using Docker secrets or environment files to avoid storing sensitive data in your compose file.
Start the Container
Launch your Oxy container:
By default, the container’s working directory is /app
. If you want to use /workspace
as your working directory (as in the example above), make sure to set working_dir: /workspace
in your Docker Compose file and mount your workspace to /workspace
.
Configure Reverse Proxy (Optional)
For production deployments, you’ll want to add a reverse proxy to handle SSL termination and provide additional security.
Add Caddy to your docker-compose.yml:
Create a Caddyfile
in the same directory:
Note: Replace
your-domain.com
with your actual domain name or uselocalhost
for local testing. Adjust the port if your Oxy instance listens on a different port.
Add Caddy to your docker-compose.yml:
Create a Caddyfile
in the same directory:
Note: Replace
your-domain.com
with your actual domain name or uselocalhost
for local testing. Adjust the port if your Oxy instance listens on a different port.
Set Up Authentication
For securing your Oxy instance, you can add authentication at the reverse proxy level:
Update your Caddyfile to include basic authentication:
Generate a password hash:
Update your Caddyfile to include basic authentication:
Generate a password hash:
Add an OAuth2 Proxy container to your docker-compose.yml:
Then update your Caddyfile:
Example Caddyfile for Oxy Serve
Note: Replace
your-domain.com
with your actual domain name or uselocalhost
for local testing. Adjust the port if your Oxy instance listens on a different port.
Volume Mounting Explained
When running Oxy in Docker, you’ll typically need to mount two types of directories:
-
Workspace Mount: Maps your local Oxy workspace to the container
This allows Oxy to access your configuration, agents, and workflows.
-
Data Mount: Provides persistent storage for Oxy’s state
This ensures your data is preserved even if the container is restarted.
Data Persistence
Oxy uses SQLite for data storage by default, which means proper volume mounting is essential for maintaining your data across container restarts or updates.
Storage Location
- By default, Oxy stores its data in
~/.local/share/oxy/
on the host system - When using Docker, you should explicitly set the
OXY_STATE_DIR
environment variable (typically to/data
) and mount a volume to that location
What Data Is Stored
Oxy stores several types of data that need to be persisted:
- SQLite database files containing state information
- Semantic information from synchronized databases
- Cached query results and intermediate data
- Workflow execution history and checkpoints
Example Docker Setup with Proper Data Persistence
For production deployments, ensure your data volume is backed by reliable storage. In cloud environments, consider using:
- Amazon EBS volumes (AWS)
- Persistent Disks (Google Cloud)
- Azure Disk Storage
- Network-attached storage (NAS) for multi-node setups
When using Docker Compose, your data will persist as long as you don’t remove the volumes. Use docker-compose down -v
with caution as it will delete the volumes.
Environment Variables
Common environment variables to configure in your Oxy container:
Variable | Description | Example |
---|---|---|
OPENAI_API_KEY | Your OpenAI API key | sk-... |
OXY_STATE_DIR | Directory for Oxy state persistence | /data |
DATABASE_URL | Connection URL if using a database | postgres://... |
PORT | Override the default port | 8080 |
Advanced Configuration
Custom Docker Images
If you need to extend the official Oxy image with additional dependencies or configuration, you can create your own Dockerfile:
Health Checks
Add health checks to ensure your container is running properly:
Troubleshooting
For further help or to ask questions, join our community on Discord.
Next Steps
Once your Docker deployment is up and running, you can:
- Set up CI/CD pipelines to automatically update your Oxy instance
- Implement monitoring and logging solutions
- Configure backups for your persistent data
- Scale horizontally for higher availability
For more information on using Oxy, refer to the main documentation.