This commit is contained in:
ilkeral
2025-07-21 13:49:36 +03:00
commit 342f1314c7
57 changed files with 9297 additions and 0 deletions

65
build/Dockerfile Normal file
View File

@ -0,0 +1,65 @@
FROM python:3.11.12-alpine
# Install zip and other necessary packages
RUN apk add --no-cache \
zip \
unzip \
tar \
gzip \
bzip2 \
xz \
p7zip \
sudo \
shadow \
openssh-client \
rsync \
curl \
wget \
bash \
sshpass \
git \
su-exec \
&& which zip && zip --help
# Create app user with specific UID/GID
RUN addgroup -g 1000 appgroup && \
adduser -u 1000 -G appgroup -s /bin/sh -D appuser
# set work directory
WORKDIR /app
# Change ownership of the work directory
RUN chown -R appuser:appgroup /app
# set env variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# install dependencies
COPY requirements.txt .
RUN pip install -r requirements.txt
# copy project
COPY . .
# Copy init script
COPY init.sh /usr/local/bin/init.sh
RUN chmod +x /usr/local/bin/init.sh
# Ensure proper permissions for SQLite database and directories
RUN chown -R appuser:appgroup /app
RUN chmod -R 755 /app
# Specifically set permissions for SQLite database and its directory
RUN if [ -f /app/db.sqlite3 ]; then \
chown appuser:appgroup /app/db.sqlite3 && \
chmod 664 /app/db.sqlite3; \
fi
# Create and set permissions for media and static directories
RUN mkdir -p /app/media /app/static /app/logs /tmp/backups && \
chown -R appuser:appgroup /app/media /app/static /app/logs /tmp/backups && \
chmod -R 755 /app/media /app/static /app/logs /tmp/backups
# Use init script as entrypoint (runs as root, then switches to appuser)
ENTRYPOINT ["/usr/local/bin/init.sh"]

56
build/init.sh Normal file
View File

@ -0,0 +1,56 @@
#!/bin/bash
set -e
echo "=== Container başlatılıyor ==="
# Veritabanı dosyası yolu
DB_FILE="/app/db.sqlite3"
DB_DIR="/app"
echo "Mevcut durumu kontrol ediyorum..."
ls -la /app/ || true
# Veritabanı dosyası kontrolü ve oluşturma
if [ ! -f "$DB_FILE" ]; then
echo "SQLite veritabanı bulunamadı, oluşturuluyor..."
touch "$DB_FILE"
fi
# Tüm /app dizinini 1000:1000 kullanıcısına ata
echo "Dizin sahipliği ayarlanıyor..."
chown -R 1000:1000 /app
# Veritabanı dosyası için özel izinler
echo "Veritabanı izinleri ayarlanıyor..."
chmod 666 "$DB_FILE" # Daha geniş izin
chmod 777 "$DB_DIR" # Dizin için tam izin
# Gerekli dizinleri oluştur
mkdir -p /app/media /app/static /app/logs
mkdir -p /tmp/backups
chown -R 1000:1000 /app/media /app/static /app/logs /tmp/backups
chmod -R 777 /app/media /app/static /app/logs /tmp/backups
# /tmp dizinine de tam izin ver
chmod 777 /tmp
chown 1000:1000 /tmp
echo "Final izin kontrolü:"
ls -la /app/db.sqlite3 || true
ls -ld /app/ || true
echo "=== İzinler ayarlandı, appuser olarak geçiliyor ==="
# Django migrate çalıştır (root olarak)
echo "Django migrate çalıştırılıyor..."
cd /app
python manage.py migrate --noinput || echo "Migrate hatası, devam ediliyor..."
# Veritabanı izinlerini tekrar ayarla
chown 1000:1000 "$DB_FILE"
chmod 666 "$DB_FILE"
echo "=== Uygulama başlatılıyor ==="
# appuser olarak uygulamayı başlat
exec su-exec 1000:1000 "$@"

48
build/requirements.txt Normal file
View File

@ -0,0 +1,48 @@
anyio==1.4.0
asgiref==3.7.2
async-generator==1.10
captcha==0.5.0
certifi==2022.6.15
charset-normalizer==2.1.0
Django==4.2.8
django-admin-interface==0.24.2
django-appconf==1.0.5
django-ckeditor==6.4.1
django-colorfield==0.8.0
django-imagekit==4.1.0
django-js-asset==2.0.0
django-ranged-response==0.2.0
django-recaptcha==4.0.0
django-recaptcha3==0.4.0
django-simple-captcha==0.6.0
django-user-agents==0.4.0
gunicorn==20.1.0
h11==0.12.0
httpcore==0.13.3
httpx==0.20.0
idna==3.3
pilkit==2.0
Pillow==9.5.0
pydash==7.0.6
recaptcha==1.0rc1
requests==2.31.0
rfc3986==1.5.0
sitemaps==0.1.0
six==1.16.0
sniffio==1.2.0
sqlparse==0.4.2
typing_extensions==4.8.0
tzdata==2022.1
ua-parser==0.10.0
urllib3==2.1.0
user-agents==2.2.0
verify==1.1.1
django-resized==1.0.2
django-tinymce==4.1.0
whitenoise==6.9.0
python-slugify==8.0.1
python-dotenv
grappelli
paramiko>=2.12.0
boto3>=1.26.0
botocore>=1.29.0