Exchange rate API with daily caching and currency conversion support.
228
The optiwariindia/exrate image contains a lightweight, production-ready application that serves currency exchange rate data. It exposes a simple REST API to fetch current rates and perform currency conversions.
The application is designed to be efficient by caching the exchange rate data daily. On its first run of the day, it will fetch data from an external API and save it to a local file. Subsequent requests on the same day will use the cached data, reducing latency and external API calls.
You can configure the container using environment variables, port mappings, and volume mounts.
Ports
The application inside the container listens on port 8080. You must map a port from your host machine to the container's port 8080 to access the API.
8080Volumes
The application uses a directory to cache the daily exchange rate data. To ensure this data persists across container restarts, you should mount a volume to the cache directory inside the container.
/app/exrateEnvironment Variables
EXRATE_API_URL: (Required) This variable specifies the URL of the external exchange rate API to fetch data from. The application is compatible with APIs that return data in a similar format to openexchangerates.org or frankfurter.dev.
https://api.frankfurter.dev/v1/latest?base=USDhttps://openexchangerates.org/api/latest.json?app_id=YOUR_APP_IDUsing docker-compose is the recommended way to run this image, as it simplifies the management of ports, volumes, and environment variables. Your existing docker-compose.yml already has a perfect example in the exrate-prod service.
Here is a breakdown of that service definition for clarity:
docker-compose.yml service definition:
services:
exrate:
# Specifies the image to pull from Docker Hub.
image: optiwariindia/exrate:1.0.0
# Maps port 80 on the host to port 8080 in the container.
# You can access the API at http://localhost
ports:
- 80:8080
# Mounts the local './exrate' directory into the container at '/app/exrate'.
# This is crucial for persisting the daily cache on your host machine.
volumes:
- ./exrate:/app/exrate
# Sets the external API URL for fetching exchange rates.
environment:
- EXRATE_API_URL=${EXRATE_API_URL}
docker-compose.yml file with the content above.mkdir -p exrate
# This command will start the service in the foreground.
docker-compose up exrate-prod
docker-compose up -d exrate-prod
You can now access the API at http://localhost/api/v1/exchangerate.
Content type
Image
Digest
sha256:3dc17565a…
Size
2.7 MB
Last updated
3 months ago
docker pull optiwariindia/exrate:go-1.0.0