Docker
This guide provides a comprehensive walkthrough for deploying SolidX applications using Docker for production.
Mental Model
Docker is the packaging boundary for a SolidX application.
- Choose Docker when reproducibility matters across local, staging, and production.
- Treat images as portable runtime snapshots.
- Use Compose when you want to run the backend, frontend, and supporting services as a coordinated stack.
Docker reduces environment drift by making the runtime explicit and portable.
This guide walks through deploying a SolidX application with Docker for a consistent and reproducible production setup.
Prerequisite
Before you begin, make sure Docker and Docker Compose are installed on the machine where you will build or run the containers.
1. Dockerizing Your Application
The create-solid-app template already provides multi-stage Dockerfiles for both the backend (solid-api/Dockerfile) and frontend (solid-ui/Dockerfile) to create lean and secure production images.
2. Using Docker Compose for Production
The create-solid-app template includes a docker-compose.yml file to define and manage your multi-container application, including a database. You can find this file in the root of your generated project.
Configure Environment Variables
While the Dockerfile defines the runtime inside the image, the docker-compose.yml file and the root .env file configure services from outside the container.
This keeps environment-specific values such as database credentials and API endpoints out of the image itself.
Create a .env file in the root of your project to store your database credentials:
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_NAME=your_db_nameDocker Compose automatically loads the root .env file and injects these values into the containers at runtime.
Security
Do not commit real .env files to version control. Keep secrets out of the image and out of the repository.
3. Building and Running the Containers
Now you can build and run your entire application stack with a single command.
Build and Run
docker-compose up --build -dThis command builds the images and starts the containers in detached mode.
View Logs
To view the logs from your running containers:
docker-compose logs -f4. Verifying the Deployment
The backend API should be accessible at http://localhost:3000, and the Swagger documentation should be available at http://localhost:3000/docs.
The frontend should be running at http://localhost:3001.
5. Post-Deployment
Pushing Images to a Container Registry
To deploy the application to a cloud provider, push your images to a container registry such as Docker Hub or AWS ECR.
Log in to your container registry:
docker login your_registry_urlBuild and push the images:
docker-compose build
docker-compose pushYou can also manually tag and push images:
docker tag <local_image_name>:<tag> <registry_url>/<image_name>:<tag>
docker push <registry_url>/<image_name>:<tag>6. Operational Notes
- Use Docker when you want the same runtime contract across environments.
- Use Compose when you want a single command to orchestrate the full stack.
- Verify ports, environment variables, and persistent storage before treating the deployment as production-ready.
The application is now containerized in a way that can move cleanly into staging or production infrastructure.

