-
Notifications
You must be signed in to change notification settings - Fork 947
solution #1018
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?
solution #1018
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,7 @@ | ||
| .venv | ||
| __pycache__ | ||
| *.pyc | ||
| .git | ||
| .idea | ||
| db.sqlite3 | ||
| docker-compose.yaml | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| FROM python:3.13-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. The service is named 'cinema' but the task requirements explicitly state 'Two services must be running: |
||
| LABEL maintainer="ilchuk.cergey@gmail.com" | ||
|
|
||
| ENV PYTHONUNBUFFERED=1 | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| COPY requirements.txt requirements.txt | ||
| RUN pip install -r requirements.txt | ||
|
|
||
| COPY . . | ||
|
|
||
| RUN mkdir -p /upload/media | ||
| RUN mkdir -p /upload/static | ||
|
|
||
| RUN adduser \ | ||
| --disabled-password \ | ||
| --no-create-home \ | ||
| django_user | ||
|
|
||
| RUN chown -R django_user /upload/media | ||
| RUN chmod -R 755 /upload/media | ||
| RUN chown -R django_user /upload/static | ||
| RUN chmod -R 755 /upload/static | ||
|
|
||
| USER django_user | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import time | ||
|
|
||
| from django.core.management import BaseCommand | ||
| from django.db import connections | ||
|
|
||
| from django.db.utils import OperationalError | ||
|
|
||
|
|
||
| class Command(BaseCommand): | ||
| def handle(self, *args, **options): | ||
| db_conn = None | ||
|
Comment on lines
+6
to
+11
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 WORKDIR is set to |
||
|
|
||
| while not db_conn: | ||
| try: | ||
| db_conn = connections["default"] | ||
| db_conn.cursor() | ||
| break | ||
| except OperationalError: | ||
| time.sleep(1) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| services: | ||
| app: | ||
| build: | ||
| context: . | ||
| env_file: | ||
| - .env | ||
| ports: | ||
|
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 |
||
| - "8000:8000" | ||
| volumes: | ||
| - ./:/app | ||
|
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 mount |
||
| - cinema_media:/upload/media | ||
| - cinema_static:/upload/static | ||
| command: > | ||
| sh -c "python manage.py wait_for_db && | ||
| python manage.py migrate && | ||
| python manage.py collectstatic --noinput && | ||
| python manage.py runserver 0.0.0.0:8000" | ||
|
Comment on lines
+13
to
+17
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 sequence is missing 'python manage.py collectstatic --noinput'. Static files defined in settings.py (STATIC_ROOT = '/upload/static') won't be properly collected into the volume. |
||
| depends_on: | ||
| - db | ||
|
|
||
|
|
||
| db: | ||
| image: postgres:18-alpine | ||
| restart: always | ||
| env_file: | ||
| - .env | ||
| ports: | ||
| - "5433:5432" | ||
| volumes: | ||
| - cinema_db:$PGDATA | ||
|
|
||
| volumes: | ||
| cinema_db: | ||
| cinema_media: | ||
| cinema_static: | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,3 +8,4 @@ djangorestframework | |
| djangorestframework-simplejwt | ||
| drf-spectacular | ||
| Pillow | ||
| psycopg2-binary | ||
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.
The
docker-compose.yamlis listed in .dockerignore (line 7). While docker-compose reads its own yaml file (so this may not cause build failures), it could cause issues if the build context needs access to the compose file. Consider removing this entry unless there's a specific reason to exclude it from images.