Currently in the initial development phase.
- Docker
- Docker Compose
-
(Optional): Modify .env.dev
-
Start the development environment:
docker compose --env-file .env.dev -f docker-compose.dev.yml --profile default up --build
- Note: if you don't want to launch the UI (just DB+API), then use:
docker compose --env-file .env.dev -f docker-compose.dev.yml --profile backend up --build
-
Access the API:
- API: http://127.0.0.1:8000
- Interactive Docs (Swagger): http://127.0.0.1:8000/docs
-
Stop the environment:
docker compose -f docker-compose.dev.yml down
-
(Optional - only if you want a completely clean slate) stop and remove volumes:
docker compose -f docker-compose.dev.yml down -v
Environment variables are configured in .env:
DB_NAME,DB_USER,DB_PASSWORD,DB_PORT- Database configurationPOSTGRES_PASSWORD- PostgreSQL superuser passwordAPP_PORT- API port (default: 8000)
If one finds they need to update dependencies (requirements.txt), the following steps can be followed:
- If a new package is required, add it to requirements.in
- Setup and activate a Python (v3.14) virtual environment. For example, with conda use:
conda create -n tictac-api python=3.14 && conda activate tictac-api - Install pip-tools:
pip install pip-tools - Compile new requirements:
pip-compile --upgrade - (Optional) Test the update locally in your environment:
pip-sync
Note: If you need to update the Python version, make sure to adjust the steps above accordingly and to update the Python image in the Dockerfile.
This project uses pre-commit hooks to automatically format Python code with Black before each commit. This ensures consistent code style across the project.
Setup (one-time):
-
Setup and activate a Python (v3.14) virtual environment if you haven't already:
conda create -n tictac-api python=3.14 && conda activate tictac-api -
Install dependencies:
pip install -r requirements.txt
-
Install the pre-commit hooks:
pre-commit install
Usage:
Once installed, the hooks will run automatically on git commit. If Black reformats any files, the commit will be aborted and you'll need to:
- Review the changes Black made
- Stage the reformatted files:
git add <files> - Commit again:
git commit
Manual formatting:
You can also run Black manually on all files:
black .Or run all pre-commit hooks manually without committing:
pre-commit run --all-filesConfiguration:
- Pre-commit hooks are configured in .pre-commit-config.yaml
- Pull latest changes (for compose file mainly):
git pull- Copy .env.prod.example to
.env:
cp .env.prod.example .env-
Modify
.env -
(If services previously up):
docker compose -f docker-compose.prod.yml down
-
Pull latest images and run:
docker compose -f docker-compose.prod.yml pull docker compose -f docker-compose.prod.yml up -d --remove-orphans
-
Verify deployment:
docker compose -f docker-compose.prod.yml ps docker compose -f docker-compose.prod.yml logs api
-
(One-time setup) If not done so already, modify your
/etc/apache2/sites-available/files to include the following lines:
# TICTAC API (proxy rules BEFORE the Alias so they take priority)
ProxyPass /tictac/apidocs http://localhost:<APP_PORT>/docs
ProxyPassReverse /tictac/apidocs http://localhost:<APP_PORT>/docs
ProxyPass /tictac/openapi.json http://localhost:<APP_PORT>/openapi.json
ProxyPassReverse /tictac/openapi.json http://localhost:<APP_PORT>/openapi.json
ProxyPass /tictac/api/ http://localhost:<APP_PORT>/api/
ProxyPassReverse /tictac/api/ http://localhost:<APP_PORT>/api/
# TICTAC UI - serve static files from the container volume
Alias /tictac /var/www/tictac-ui/
<Directory /var/www/tictac-ui>
Options -Indexes +FollowSymLinks
AllowOverride None
Require all granted
# SPA fallback: if the file/dir doesn't exist, serve index.html
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.html [L]
</Directory>
Then reload apache:
sudo apache2ctl configtest # make sure syntax ok
sudo systemctl reload apache2
curl -I https://habanero.health.unm.edu/tictac/apidocs # should give HTTP/1.1 200The API docs should now be accessible at:
https://habanero.health.unm.edu/tictac/apidocs
And UI should be accessible from: https://habanero.health.unm.edu/tictac
-
Build image:
docker build -t unmtransinfo/tictac_api:latest . -
Add tags to image:
docker tag unmtransinfo/tictac_api:latest unmtransinfo/tictac_api:v1 # modify v1 to whatever version you want to use -
Login:
docker login -
Push:
docker push unmtransinfo/tictac_api:latest && docker push unmtransinfo/tictac_api:v1