From b93d51c4942387790cec7df006c15af29d8799d9 Mon Sep 17 00:00:00 2001 From: Shihaam Abdul Rahman Date: Sat, 15 Mar 2025 00:21:05 +0500 Subject: [PATCH] docker deployment docs --- README.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/README.md b/README.md index 7eb2304..ce59a03 100644 --- a/README.md +++ b/README.md @@ -10,3 +10,40 @@ API for SARLink portal in Django Rest Framework. 4. Copy .env.example to .env and fill in the configs `cp .env.example .env` 5. generate static `python manage.py collectstatic` 6. Run Migrations `python manage.py migrate` + + +## deployement with Docker +1. Create `compose.yml` +```yaml +services: + portal-api: + hostname: portal-api + image: git.shihaam.dev/sarlink/sarlink-portal-api/api + env_file: .env.api + nginx: + hostname: portal-api-nginx + image: git.shihaam.dev/sarlink/sarlink-portal-api/nginx + volumes_from: + - portal-api + ports: + - 4000:80 + depends_on: + - portal-api + portal-db: + image: postgres:14 + restart: always + hostname: portal-db + volumes: + - ./database:/var/lib/postgresql/data + env_file: .env.db +``` +2. Start services: `docker compose up -d` +3. Run Migrations: `docker compose exec portal-api python manage.py migrate` +4. Test api with curl: +```bash +curl -X POST http://localhost:4000/api/auth/login/ \ +-H "Content-Type: application/json" \ +-d '{"username":"admin", "password":"soemthign"}' +``` +expected response: `{"message":"Unable to log in with provided credentials."}` +