-
Notifications
You must be signed in to change notification settings - Fork 945
dockerized cinema app #1024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
dockerized cinema app #1024
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| .idea/ | ||
| .vscode/ | ||
| *.iml | ||
| .env | ||
| .DS_Store | ||
| venv/ | ||
| .pytest_cache/ | ||
| **__pycache__/ | ||
| **db.sqlite3 | ||
| media | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| FROM python:3.10-slim | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CRITICAL: Django 6.0.5 requires Python >= 3.12, but this image uses python:3.10-slim. Change to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CRITICAL BLOCKER: Python version mismatch. Django 6.0.5 (from migration file) requires Python >= 3.12, but this Dockerfile uses Python 3.10. This will cause |
||
|
|
||
| ENV PYTHONUNBUFFERED=1 | ||
| WORKDIR /app | ||
|
|
||
| COPY requirements.txt requirements.txt | ||
| RUN pip install -r requirements.txt | ||
|
|
||
| COPY . . | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The volume |
||
| RUN mkdir -p /app/media | ||
| RUN adduser \ | ||
| --disabled-password \ | ||
| --no-create-home \ | ||
| my_user | ||
| RUN chown -R my_user /app/media | ||
| RUN chmod -R 755 /media | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CRITICAL: Path mismatch. Line 10 creates directory at |
||
|
|
||
|
|
||
| USER my_user | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import time | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: Python/Django version mismatch - Django 6.0.5 (mentioned in migration line 1) requires Python >= 3.12, but the Dockerfile uses Python 3.10-slim. Either downgrade Django to 4.x/5.x compatible with Python 3.10, or use Python 3.12+ image. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Dockerfile uses |
||
| from django.core.management.base import BaseCommand | ||
| from django.db import connections | ||
| from django.db.utils import OperationalError | ||
|
Comment on lines
+1
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Comment on lines
+1
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
|
||
|
|
||
| class Command(BaseCommand): | ||
|
Comment on lines
+1
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| """Wait for db connection""" | ||
|
|
||
| def handle(self, *args, **options): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dockerfile line 10 uses |
||
| self.stdout.write("Checking database connection...") | ||
|
|
||
| db_conn = None | ||
| attempts = 0 | ||
| while not db_conn and attempts < 15: | ||
| try: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line chmods |
||
| db_conn = connections["default"] | ||
| db_conn.cursor() | ||
| except OperationalError: | ||
| attempts += 1 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Dockerfile switches to non-root user |
||
| self.stdout.write( | ||
| f"DB is not ready(attempt {attempts}/15)... " | ||
| f"Wait for 2 seconds." | ||
| ) | ||
| time.sleep(2) | ||
| else: | ||
| self.stdout.write( | ||
| self.style.SUCCESS("DB is ready, continue...") | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # Generated by Django 6.0.5 on 2026-05-24 18:40 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Django 6.0.5 requires Python >= 3.12, but this Dockerfile uses python:3.10-slim. This will cause pip to fail when installing Django 6.0.5. Change to |
||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The service name 'cinema_service' doesn't match the task requirement which specifies the service should be named 'app'. Update the service name to match the task requirements. |
||
| import django.db.models.deletion | ||
| from django.conf import settings | ||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing static files handling. Add 'RUN python manage.py collectstatic --noinput' to properly handle static files in Docker. |
||
| ('cinema', '0001_initial'), | ||
| migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AlterField( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The chmod command is targeting the wrong path. This sets permissions on |
||
| model_name='movie', | ||
| name='actors', | ||
| field=models.ManyToManyField(blank=True, related_name='movies', to='cinema.actor'), | ||
| ), | ||
| migrations.AlterField( | ||
| model_name='movie', | ||
| name='genres', | ||
| field=models.ManyToManyField(blank=True, related_name='movies', to='cinema.genre'), | ||
| ), | ||
| migrations.AlterField( | ||
| model_name='moviesession', | ||
| name='cinema_hall', | ||
| field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='movie_sessions', to='cinema.cinemahall'), | ||
| ), | ||
| migrations.AlterField( | ||
| model_name='moviesession', | ||
| name='movie', | ||
| field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='movie_sessions', to='cinema.movie'), | ||
| ), | ||
| migrations.AlterField( | ||
| model_name='order', | ||
| name='user', | ||
| field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='orders', to=settings.AUTH_USER_MODEL), | ||
| ), | ||
| ] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| For the full list of settings and their values, see | ||
| https://docs.djangoproject.com/en/4.0/ref/settings/ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical path mismatch: The Dockerfile creates directory |
||
| """ | ||
| import os | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The docker-compose command doesn't run |
||
| from datetime import timedelta | ||
| from pathlib import Path | ||
|
|
||
|
|
@@ -27,8 +28,8 @@ | |
| # SECURITY WARNING: don't run with debug turned on in production! | ||
| DEBUG = True | ||
|
|
||
| ALLOWED_HOSTS = [] | ||
|
|
||
| ALLOWED_HOSTS = ["127.0.0.1"] | ||
| STATIC_ROOT = BASE_DIR / "staticfiles" | ||
| INTERNAL_IPS = [ | ||
| "127.0.0.1", | ||
| ] | ||
|
|
@@ -86,8 +87,12 @@ | |
|
|
||
| DATABASES = { | ||
| "default": { | ||
| "ENGINE": "django.db.backends.sqlite3", | ||
| "NAME": BASE_DIR / "db.sqlite3", | ||
| "ENGINE": "django.db.backends.postgresql", | ||
| "NAME": os.environ["POSTGRES_DB"], | ||
| "USER": os.environ["POSTGRES_USER"], | ||
| "PASSWORD": os.environ["POSTGRES_PASSWORD"], | ||
| "HOST": os.environ["POSTGRES_HOST"], | ||
| "PORT": os.environ["POSTGRES_PORT"], | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| services: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Django 6.0.5 (from migration file) requires Python >= 3.12. Change to |
||
| app: | ||
| build: | ||
| context: . | ||
| env_file: | ||
| - .env | ||
| ports: | ||
| - "8000:8000" | ||
| volumes: | ||
| - my_media:/app/media | ||
| command: | ||
| sh -c "python manage.py wait_for_db && python manage.py makemigrations && python manage.py migrate && python manage.py runserver 0.0.0.0:8000" | ||
| depends_on: | ||
| - db | ||
|
|
||
| db: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Path mismatch - chmod targets |
||
| image: postgres:16.0-alpine3.17 | ||
| restart: always | ||
| env_file: | ||
| - .env | ||
| ports: | ||
| - "5432:5432" | ||
| volumes: | ||
| - my_db:$PGDATA | ||
| volumes: | ||
| my_db: | ||
| my_media: | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,28 @@ | ||
| django | ||
| flake8 | ||
| flake8-quotes | ||
| flake8-variables-names | ||
| pep8-naming | ||
| django-debug-toolbar | ||
| djangorestframework | ||
| djangorestframework-simplejwt | ||
| drf-spectacular | ||
| Pillow | ||
| asgiref==3.11.1 | ||
| attrs==26.1.0 | ||
| Django==4.2.15 | ||
| django-debug-toolbar==6.3.0 | ||
| djangorestframework==3.17.1 | ||
| djangorestframework_simplejwt==5.5.1 | ||
| drf-spectacular==0.29.0 | ||
| flake8==7.3.0 | ||
| flake8-quotes==3.4.0 | ||
| flake8-variables-names==0.0.6 | ||
| inflection==0.5.1 | ||
| jsonschema==4.26.0 | ||
| jsonschema-specifications==2025.9.1 | ||
| mccabe==0.7.0 | ||
| pep8-naming==0.15.1 | ||
| pillow==12.2.0 | ||
| psycopg==3.3.4 | ||
| psycopg-binary==3.3.4 | ||
| pycodestyle==2.14.0 | ||
| pyflakes==3.4.0 | ||
| PyJWT==2.13.0 | ||
| PyYAML==6.0.3 | ||
| referencing==0.37.0 | ||
| rpds-py==0.30.0 | ||
| setuptools==82.0.1 | ||
| sqlparse==0.5.5 | ||
| tzdata==2026.2 | ||
| uritemplate==4.2.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical Blocker: Django 6.0.5 (shown in migration file) requires Python >= 3.12, but this Dockerfile uses Python 3.10. Change to
python:3.12-slimto match the Django version.