Commit 7ba8a99b authored by 22stmo1bif's avatar 22stmo1bif
Browse files

Refactor Dockerfile and add entrypoint script for improved container initialization

parent 398db1f0
......@@ -18,18 +18,11 @@ RUN uv venv .venv && \
# Installiere die Abhängigkeiten aus pyproject.toml
RUN uv sync
# für Admin oberfläche
#RUN python manage.py createsuperuser
#COPY . .
RUN .venv/bin/python manage.py migrate
# Kopiere den Rest des Projekts in den Container
# Make entrypoint script executable
RUN chmod +x entrypoint.sh
# Exponiere Port 8000 (für Django)
EXPOSE 8000
# Startbefehl (z. B. für Django-Projekt)
CMD ["uv", "run", "python", "manage.py", "runserver", "0.0.0.0:8000"]
# Use entrypoint script
CMD ["./entrypoint.sh"]
#!/bin/bash
# Wait for database to be ready (if needed)
echo "Starting Django application..."
# Run migrations
echo "Running database migrations..."
.venv/bin/python manage.py makemigrations
.venv/bin/python manage.py migrate
# Create superuser if it doesn't exist (optional)
echo "Checking for superuser..."
.venv/bin/python manage.py shell -c "
from django.contrib.auth import get_user_model
User = get_user_model()
if not User.objects.filter(username='admin').exists():
User.objects.create_superuser('admin', 'admin@example.com', 'admin123')
print('Superuser created')
else:
print('Superuser already exists')
"
# Start the Django development server
echo "Starting Django server..."
exec uv run python manage.py runserver 0.0.0.0:8000
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment