The Currency Exchange API is containerized using Docker, making it easy to deploy and run in any environment.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/SiveriusAlter/CurrencyExchange/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
Before you begin, ensure you have the following installed:- Docker (version 20.x or higher)
- Docker Compose (version 2.x or higher)
Docker Configuration
The API uses a multi-stage Dockerfile based on .NET 8.0 to optimize the image size and build process.Dockerfile Overview
The Dockerfile consists of four stages:- Base Stage: Sets up the runtime environment
- Build Stage: Compiles the application
- Publish Stage: Publishes the release build
- Final Stage: Creates the production image
Building the Docker Image
Build the Docker image
currencyexchangeback.Running with Docker Compose
Thedocker-compose.yaml file defines the services needed to run the application, including the PostgreSQL database.
Docker Compose Configuration
The docker-compose file includes commented-out sections for nginx reverse proxy and frontend services. Uncomment these sections if you need to deploy the full stack.
Starting the Services
Port Mappings
The following ports are exposed by the services:| Service | Container Port | Host Port | Description |
|---|---|---|---|
| API | 8080 | 8080 | HTTP endpoint for the API |
| API | 8081 | 8081 | HTTPS endpoint (optional) |
| PostgreSQL | 5432 | 5432 | Database connection port |
Volumes
Database Volume
The PostgreSQL database uses a named volumecurrencies to persist data:
Initialization Scripts
Database initialization scripts are mounted from the host:../2. Init Database directory, and they will be executed automatically when the database container starts for the first time.
Full Stack Deployment
To deploy the complete stack including the API, frontend, and nginx reverse proxy, uncomment the relevant sections indocker-compose.yaml:
Stopping and Removing Services
Troubleshooting
Viewing Logs
Common Issues
Port already in use
Port already in use
If port 8080 or 5432 is already in use, modify the port mappings in
docker-compose.yaml or the docker run command:Database connection refused
Database connection refused
Ensure the PostgreSQL container is running and healthy:Check that the connection string in
appsettings.json matches the database configuration.Container exits immediately
Container exits immediately
Check the container logs for errors:Common causes include missing environment variables or database connection issues.