-
Notifications
You must be signed in to change notification settings - Fork 1
How‐to: Local DEV deployment using docker
This quick-start guide details how to establish a local development (DEV) environment for the whereis-api-v0 project using Docker containers. Designed for developers using Mac and Linux with Docker already installed, this guide focuses on a fresh deployment, requiring minimal initial setup. It just works.
- Start the PostgreSQL container on port 5432.
- Create the whereis database and grant access to
whereis_user. - Start the Whereis API container on port 8037.
- Preload the database with two built‑in sample tracking numbers:
eg1-012301230123eg1-123412341234
You'll have two healthy containers:
IMAGE STATUS PORTS NAMES
local/whereis-api-v0 Up ... (healthy) 0.0.0.0:8037->8037/tcp whereis-api-v0
postgres Up ... (healthy) 0.0.0.0:5432->5432/tcp pg-whereis
git clone https://github.com/eagle1-sys/whereis-api-v0
cd whereis-api-v0make whereisOptional
make helpVerify application health and database connection. Expect a 200 OK status.
curl -I http://localhost:8037/app-healthTest the status API with a built-in sample tracking ID.
curl http://localhost:8037/v0/status/eg1-012301230123Test the Whereis API with an authorization header. Use test key eagle1 to ensure authenticated requests are handled.
curl http://localhost:8037/v0/whereis/eg1-012301230123 --header 'Authorization: Bearer eagle1'Benchmark API performance using ApacheBench:
ab -n1000 -c200 localhost:8037/v0/status/eg1-012301230123Example output on a Apple Macbook Air M5 (2 Core, 2GB for docker):
Requests per second: 4466.52 [#/sec] (mean)
Time per request: 44.778 [ms] (mean)
Time per request: 0.224 [ms] (mean, across all concurrent requests)
Transfer rate: 1613.88 [Kbytes/sec] received
By default, we use SQLite as the local database. Very easy.
docker-compose.yaml (needs modification)
- APP_PORT
- APP_ENV
- WHEREIS_API_KEY
source-api-keys.env (needs modification)
- Logistics source API keys
Dockerfile (rarely modified)
- APP_PORT
config.ts (do not modify)
- Application default configuration
Change the default database passwords (_CHANGEME_) for enhanced security.
-
Change database passwords
Change whereis_user password, replacing the placeholder with your chosen password:
docker exec -it whereis-postgres psql -U postgres -c "ALTER USER whereis_user WITH PASSWORD 'YOUR_DB_PASSWORD';"
Change postgres superuser password, replacing the placeholder with your chosen password:
docker exec -it whereis-postgres psql -U postgres -c "ALTER USER postgres WITH PASSWORD 'YOUR_POSTGRES_PASSWORD';"
-
Update config files
Modify
docker-compose.yamlto reflect these newPOSTGRES_PASSWORDandDB_PASSWORDvalues. -
Redeploy both containers
make update
There are two types of API keys:
-
SOURCE_API_KEY: Required to access the logistics sources, such as FedEx. You must obtain these keys directly from the sources. Edit the
source-api-keys.envfile to set e.g.FDXandSFEXAPI keys. -
WHEREIS_API_KEY: These keys are used to access the your own Whereis API serivce. You can create any unique keys to use. By default,
eagle1is the demo key for accessing the two preloaded sample tracking numbers.To create a new whereis_api_key to retrieve real tracking numbers, replace the placeholder
sk-WHEREISKEY.# System to generate a random key for you make api-key # Set a specific key make api-key ARGS="--user=new --key=sk-WHEREISKEY"
Modify docker-compose.yaml
WHEREIS_API_KEY: sk-WHEREISKEY
After modification, redeploy the API:
make updateBuilt-in unit tests
make testcurl http://localhost:8037/v0/whereis/fdx-123412341234 \
--header 'Authorization: Bearer sk-MYSECRETEKEY'That is it. Enjoy!
(C) 2025 Eagle1