Skip to content

Commit 6a809e2

Browse files
committed
started on docker implimentation
1 parent b53e848 commit 6a809e2

File tree

6 files changed

+193
-0
lines changed

6 files changed

+193
-0
lines changed

.dockerignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
__pycache__
2+
*.pyc
3+
*.pyo
4+
*.pyd
5+
.Python
6+
*.so
7+
*.egg
8+
*.egg-info
9+
dist
10+
build
11+
.git
12+
.gitignore
13+
.vscode
14+
.idea
15+
*.swp
16+
*.swo
17+
*~
18+
.DS_Store
19+
db.sqlite3
20+
*.sqlite3
21+
.env
22+
venv
23+
env
24+
ENV
25+
.venv
26+
staticfiles
27+
media
28+
*.log
29+
.coverage
30+
htmlcov
31+
.pytest_cache
32+
.mypy_cache
33+
node_modules
34+
postgres_data

DOCKER_README.md

Whitespace-only changes.

Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM python:3.11-slim
2+
3+
ENV PYTHONUNBUFFERED=1
4+
5+
WORKDIR /app
6+
7+
RUN apt-get update && apt-get install -y \
8+
postgresql-client \
9+
libpq-dev \
10+
gcc \
11+
libxml2-dev \
12+
libxslt1-dev \
13+
zlib1g-dev \
14+
git \
15+
netcat-openbsd \
16+
&& rm -rf /var/lib/apt/lists/*
17+
18+
COPY requirements.txt .
19+
RUN pip install --no-cache-dir -r requirements.txt
20+
RUN pip install --no-cache-dir psycopg2-binary
21+
22+
COPY . .
23+
24+
RUN mkdir -p /app/static
25+
26+
EXPOSE 8000
27+
28+
COPY docker-entrypoint.sh /docker-entrypoint.sh
29+
RUN chmod +x /docker-entrypoint.sh
30+
31+
ENTRYPOINT ["/docker-entrypoint.sh"]
32+
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]

docker-compose.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
version: '3.8'
2+
3+
services:
4+
db:
5+
image: postgres:15
6+
environment:
7+
POSTGRES_DB: editgroups
8+
POSTGRES_USER: postgres
9+
POSTGRES_PASSWORD: postgres
10+
volumes:
11+
- postgres_data:/var/lib/postgresql/data
12+
ports:
13+
- "5432:5432"
14+
healthcheck:
15+
test: ["CMD-SHELL", "pg_isready -U postgres"]
16+
interval: 5s
17+
timeout: 5s
18+
retries: 5
19+
20+
redis:
21+
image: redis:7-alpine
22+
ports:
23+
- "6379:6379"
24+
healthcheck:
25+
test: ["CMD", "redis-cli", "ping"]
26+
interval: 5s
27+
timeout: 3s
28+
retries: 5
29+
30+
web:
31+
build: .
32+
command: python manage.py runserver 0.0.0.0:8000
33+
volumes:
34+
- .:/app
35+
ports:
36+
- "8000:8000"
37+
environment:
38+
- DJANGO_SETTINGS_MODULE=editgroups.settings.docker
39+
depends_on:
40+
db:
41+
condition: service_healthy
42+
redis:
43+
condition: service_healthy
44+
45+
celery:
46+
build: .
47+
command: celery -A editgroups worker -l info
48+
volumes:
49+
- .:/app
50+
environment:
51+
- DJANGO_SETTINGS_MODULE=editgroups.settings.docker
52+
depends_on:
53+
- db
54+
- redis
55+
- web
56+
57+
celery-beat:
58+
build: .
59+
command: celery -A editgroups beat -l info
60+
volumes:
61+
- .:/app
62+
environment:
63+
- DJANGO_SETTINGS_MODULE=editgroups.settings.docker
64+
depends_on:
65+
- db
66+
- redis
67+
- web
68+
69+
volumes:
70+
postgres_data:

docker-entrypoint.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
echo "Waiting for PostgreSQL..."
6+
while ! nc -z db 5432; do
7+
sleep 0.1
8+
done
9+
echo "PostgreSQL started"
10+
11+
echo "Running migrations..."
12+
python manage.py migrate --noinput
13+
14+
echo "Collecting static files..."
15+
python manage.py collectstatic --noinput
16+
17+
echo "Creating superuser if it doesn't exist..."
18+
python manage.py shell -c "
19+
from django.contrib.auth import get_user_model
20+
User = get_user_model()
21+
if not User.objects.filter(username='admin').exists():
22+
User.objects.create_superuser('admin', '[email protected]', 'admin')
23+
print('Superuser created: admin/admin')
24+
else:
25+
print('Superuser already exists')
26+
" || true
27+
28+
exec "$@"

editgroups/settings/docker.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from .common import *
2+
3+
DEBUG = True
4+
ALLOWED_HOSTS = ['*']
5+
6+
SECRET_KEY = '20oj&tj8uaruseitlrise,tries,uirsetur36746209etus7e'
7+
8+
DATABASES = {
9+
'default': {
10+
'ENGINE': 'django.db.backends.postgresql_psycopg2',
11+
'NAME': 'editgroups',
12+
'USER': 'postgres',
13+
'PASSWORD': 'postgres',
14+
'HOST': 'db',
15+
'PORT': '5432',
16+
'DISABLE_SERVER_SIDE_CURSORS': False,
17+
}
18+
}
19+
20+
SOCIAL_AUTH_MEDIAWIKI_KEY = 'your_mediawiki_key'
21+
SOCIAL_AUTH_MEDIAWIKI_SECRET = 'your_mediawiki_secret'
22+
SOCIAL_AUTH_MEDIAWIKI_URL = 'https://www.wikidata.org/w/index.php'
23+
SOCIAL_AUTH_MEDIAWIKI_CALLBACK = 'http://localhost:8000/oauth/complete/mediawiki/'
24+
25+
REDIS_HOST = 'redis'
26+
REDIS_PORT = 6379
27+
REDIS_DB = 0
28+
REDIS_PASSWORD = ''
29+
REDIS_KEY_PREFIX = 'editgroups_'

0 commit comments

Comments
 (0)