Skip to content

Commit 79340bd

Browse files
Docker setup completed
1 parent ef8850a commit 79340bd

9 files changed

Lines changed: 182 additions & 9 deletions

File tree

.env.example

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
HOST=0.0.0.0
2+
PORT=8000
3+
4+
# PostgreSQL Configuration (PostgreSQL 16)
5+
POSTGRES_USER=elephant_admin
6+
POSTGRES_PASSWORD=SuperSecureAndComplexPassword2026!
7+
POSTGRES_DB=elephant_messenger
8+
POSTGRES_PORT=42359
9+
POSTGRES_HOST=127.0.0.1
10+
11+
# JWT
12+
JWT_SECRET=my_super_long_and_secure_secret_key
13+
14+
# OAuth2 Authentication Providers
15+
# Google Developer Console Credentials
16+
GOOGLE_CLIENT_ID=your_google_client_id.apps.googleusercontent.com
17+
GOOGLE_CLIENT_SECRET=GOCSPX-your_google_client_secret
18+
GOOGLE_REDIRECT_URL=http://localhost:8000/api/auth/google/callback
19+
20+
# GitHub Developer Settings Credentials
21+
GITHUB_CLIENT_ID=ov-your_github_client_id
22+
GITHUB_CLIENT_SECRET=your_github_client_secret
23+
GITHUB_REDIRECT_URL=http://localhost:8000/api/auth/github/callback

backend/.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.venv
2+
__pycache__
3+
*.pyc
4+
.git
5+
.env

backend/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM python:3.12-slim
2+
3+
ENV PYTHONDONTWRITEBYTECODE=1
4+
ENV PYTHONUNBUFFERED=1
5+
6+
WORKDIR /app
7+
8+
RUN pip install --no-cache-dir uv
9+
10+
COPY pyproject.toml uv.lock ./
11+
12+
RUN uv sync --frozen
13+
14+
COPY . .
15+
16+
EXPOSE 8000
17+
18+
CMD ["uv", "run", "python", "manage.py", "runserver", "${HOST}:${PORT}"]

backend/config/settings.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"""
1212

1313
from pathlib import Path
14+
from os import os
1415

1516
# Build paths inside the project like this: BASE_DIR / 'subdir'.
1617
BASE_DIR = Path(__file__).resolve().parent.parent
@@ -80,9 +81,13 @@
8081
# https://docs.djangoproject.com/en/6.1/ref/settings/#databases
8182

8283
DATABASES = {
83-
'default': {
84-
'ENGINE': 'django.db.backends.sqlite3',
85-
'NAME': BASE_DIR / 'db.sqlite3',
84+
"default": {
85+
"ENGINE": "django.db.backends.postgresql",
86+
"NAME": os.getenv("POSTGRES_DB", "fasio"),
87+
"USER": os.getenv("POSTGRES_USER", "fasio"),
88+
"PASSWORD": os.getenv("POSTGRES_PASSWORD", "fasio"),
89+
"HOST": os.getenv("POSTGRES_HOST", "db"),
90+
"PORT": os.getenv("POSTGRES_PORT", "5432"),
8691
}
8792
}
8893

backend/pyproject.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
[project]
22
name = "backend"
33
version = "0.1.0"
4-
description = "Add your description here"
4+
description = ""
55
readme = "README.md"
66
authors = [
7-
{ name = "Golden_Eagle07", email = "challamanideepreddy@gmail.com" }
7+
{ name = "CommandlineCoding", email = "info@commandlinecoding.in" }
88
]
99
requires-python = ">=3.12"
1010
dependencies = [
1111
"django>=6.1",
12+
"psycopg[binary]>=3.3.4",
1213
]
1314

1415
[project.scripts]
@@ -17,3 +18,6 @@ backend = "backend:main"
1718
[build-system]
1819
requires = ["uv_build>=0.12.3,<0.13.0"]
1920
build-backend = "uv_build"
21+
22+
[tool.uv]
23+
package = false

backend/src/backend/__init__.py

Lines changed: 0 additions & 2 deletions
This file was deleted.

backend/uv.lock

Lines changed: 73 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compose.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
services:
2+
db:
3+
image: postgres:16-alpine
4+
container_name: fashio
5+
environment:
6+
POSTGRES_DB: ${POSTGRES_DB}
7+
POSTGRES_USER: ${POSTGRES_USER}
8+
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
9+
ports:
10+
- "${POSTGRES_PORT}:5432"
11+
volumes:
12+
- pgdata:/var/lib/postgresql/data
13+
healthcheck:
14+
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
15+
interval: 5s
16+
timeout: 5s
17+
retries: 5
18+
19+
backend:
20+
build:
21+
context: ./backend
22+
dockerfile: Dockerfile
23+
container_name: fashio-backend
24+
restart: unless-stopped
25+
command: uv run python manage.py runserver ${HOST}:${PORT}
26+
volumes:
27+
- ./backend:/app
28+
ports:
29+
- "${PORT}:${PORT}"
30+
environment:
31+
DJANGO_SETTINGS_MODULE: config.settings.local
32+
POSTGRES_DB: ${POSTGRES_DB}
33+
POSTGRES_USER: ${POSTGRES_USER}
34+
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
35+
POSTGRES_HOST: ${POSTGRES_HOST}
36+
POSTGRES_PORT: ${POSTGRES_PORT}
37+
JWT_SECRETS: ${JWT_SECRET}
38+
GOOGLE_CLIENT_ID: ${GOOGLE_CLIENT_ID}
39+
GOOGLE_CLIENT_SECERTS: ${GOOGLE_CLIENT_SECRET}
40+
GOOGLE_REDIRECT_URL: ${GOOGLE_REDIRECT_URL}
41+
GITHUB_CLIENT_ID: ${GITHUB_CLIENT_ID}
42+
GITHUB_CLIENT_SECRETS: ${GITHUB_CLIENT_SECRET}
43+
GITHUB_CLIENT_URL: ${GITHUB_REDIRECT_URL}
44+
depends_on:
45+
db:
46+
condition: service_healthy
47+
48+
volumes:
49+
pgdata:

compose.yml

Whitespace-only changes.

0 commit comments

Comments
 (0)