-
Notifications
You must be signed in to change notification settings - Fork 946
solution #1002
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
Open
Depaton
wants to merge
2
commits into
mate-academy:master
Choose a base branch
from
Depaton:develop
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
solution #1002
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| venv/ | ||
| venv | ||
| .venv | ||
| __pycache__ | ||
| __pycache__/ | ||
| *.pyc | ||
| .git | ||
| .git/ | ||
| .env | ||
| db.sqlite3 | ||
| .db.sqlite3 | ||
| .flake8 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| FROM python:3.10-alpine | ||
|
|
||
| ENV PYTHONDONTWRITEBYTECODE=1 | ||
| ENV PYTHONUNBUFFERED=1 | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| RUN apk add --update --no-cache postgresql-client jpeg-dev \ | ||
| && apk add --update --no-cache --virtual .tmp-build-deps \ | ||
| build-base postgresql-dev musl-dev zlib zlib-dev | ||
|
|
||
| COPY requirements.txt /app/ | ||
|
|
||
| RUN pip install --no-cache-dir -r requirements.txt \ | ||
| && apk del .tmp-build-deps | ||
|
|
||
| COPY . /app/ | ||
|
|
||
| RUN mkdir -p /vol/web/media \ | ||
| && mkdir -p /vol/web/static \ | ||
| && adduser -D django-user \ | ||
| && chown -R django-user:django-user /vol/ \ | ||
| && chown -R django-user:django-user /app/ \ | ||
| && chmod -R 755 /vol | ||
|
|
||
| USER django-user |
Empty file.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import time | ||
| from psycopg2 import OperationalError as Psycopg2OpError | ||
|
|
||
| from django.db.utils import OperationalError | ||
| from django.core.management.base import BaseCommand | ||
|
|
||
|
|
||
| class Command(BaseCommand): | ||
| """Django command to pause execution until database is available""" | ||
|
|
||
| def handle(self, *args, **options): | ||
| self.stdout.write('Waiting for database...') | ||
| db_up = False | ||
| while not db_up: | ||
| try: | ||
| self.check(databases=['default']) | ||
| db_up = True | ||
| except (OperationalError, Psycopg2OpError): | ||
| self.stdout.write('Database unavailable, waiting 1 second...') | ||
| time.sleep(1) | ||
|
|
||
| self.stdout.write(self.style.SUCCESS('Database available!')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| time="2026-03-20T15:38:47+02:00" level=warning msg="D:\\pythonProject\\py-dockerize-cinema\\docker-compose.yml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion" | ||
| Image py-dockerize-cinema-app Building | ||
| failed to connect to the docker API at npipe:////./pipe/dockerDesktopLinuxEngine; check if the path is correct and if the daemon is running: open //./pipe/dockerDesktopLinuxEngine: The system cannot find the file specified. | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| version: "3.9" | ||
|
|
||
| services: | ||
| app: | ||
| build: | ||
| context: . | ||
| ports: | ||
| - "8000:8000" | ||
| volumes: | ||
| - .:/app | ||
| - media_data:/vol/web/media | ||
| - static_data:/vol/web/static | ||
| command: > | ||
| sh -c "python manage.py wait_for_db && | ||
| python manage.py migrate && | ||
| python manage.py runserver 0.0.0.0:8000" | ||
| environment: | ||
| - POSTGRES_DB=cinema | ||
| - POSTGRES_USER=postgres | ||
| - POSTGRES_PASSWORD=postgres | ||
| - POSTGRES_HOST=db | ||
| - POSTGRES_PORT=5432 | ||
| - MEDIA_ROOT=/vol/web/media | ||
| - STATIC_ROOT=/vol/web/static | ||
| depends_on: | ||
| - db | ||
|
|
||
| db: | ||
| image: postgres:14-alpine | ||
| environment: | ||
| - POSTGRES_DB=cinema | ||
| - POSTGRES_USER=postgres | ||
| - POSTGRES_PASSWORD=postgres | ||
| volumes: | ||
| - pgdata:/var/lib/postgresql/data | ||
|
|
||
| volumes: | ||
| pgdata: | ||
| media_data: | ||
| static_data: |
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,3 +8,4 @@ djangorestframework | |
| djangorestframework-simplejwt | ||
| drf-spectacular | ||
| Pillow | ||
| psycopg2-binary>=2.9 | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Configuration files like
.flake8should typically be included in the Docker image. This ensures that anyone using the image has the correct configuration for tools like linters, even if they don't mount the local source code. While the current setup works fordocker-compose runbecause of the volume mount, it's a good practice to make the image as self-contained as possible.