-
Notifications
You must be signed in to change notification settings - Fork 42
fix(#259): docker-compose error on building sample project. #260
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
NaGaii1994
wants to merge
2
commits into
Radi85:develop
Choose a base branch
from
NaGaii1994:fix/docker-build-error
base: develop
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
Changes from all commits
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 |
|---|---|---|
| @@ -1,21 +1,20 @@ | ||
| FROM python:3.8-alpine | ||
| FROM python:3.10-slim-bullseye | ||
|
|
||
| RUN apk update \ | ||
| && apk add --virtual build-deps gcc python3-dev musl-dev \ | ||
| && apk add bash \ | ||
| && apk add postgresql \ | ||
| && apk add postgresql-dev \ | ||
| && pip install psycopg2 \ | ||
| && apk add jpeg-dev zlib-dev libjpeg \ | ||
| && pip install Pillow \ | ||
| && apk del build-deps | ||
| # Install apt packages | ||
| RUN apt-get update && apt-get install --no-install-recommends -y \ | ||
| # dependencies for building Python packages | ||
| build-essential \ | ||
| # psycopg2 dependencies | ||
| libpq-dev \ | ||
| # Translations dependencies | ||
| gettext \ | ||
| # cleaning up unused files | ||
| && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| WORKDIR /code/ | ||
| COPY . /code/ | ||
| WORKDIR /code/ | ||
|
|
||
| RUN pip install -r /code/test/example/requirements.txt | ||
|
|
||
| RUN apk add --no-cache postgresql-libs | ||
|
|
||
| ENTRYPOINT ["/code/docker-entrypoint.sh"] | ||
| RUN pip install -r /code/test/example/requirements.txt \ | ||
| && pip install psycopg2 \ | ||
| && python -m pip install django-comments-dab[markdown] | ||
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 |
|---|---|---|
|
|
@@ -9,4 +9,4 @@ beautifulsoup4 | |
| cssselect | ||
| coverage | ||
| flake8 | ||
| tox | ||
| tox | ||
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,36 @@ | ||
| import os | ||
| import logging | ||
| from time import time, sleep | ||
| import psycopg2 | ||
| check_timeout = os.getenv("POSTGRES_CHECK_TIMEOUT", 30) | ||
| check_interval = os.getenv("POSTGRES_CHECK_INTERVAL", 1) | ||
| interval_unit = "second" if check_interval == 1 else "seconds" | ||
| config = { | ||
| "dbname": os.getenv("DB_NAME", "postgres"), | ||
| "user": os.getenv("DB_USER", "postgres"), | ||
| "password": os.getenv("DB_PASSWORD", "django-comments-dab"), | ||
| "host": os.getenv("DB_HOST", "db") | ||
| } | ||
|
|
||
| start_time = time() | ||
| logger = logging.getLogger() | ||
| logger.setLevel(logging.INFO) | ||
| logger.addHandler(logging.StreamHandler()) | ||
|
|
||
|
|
||
| def pg_isready(host, user, password, dbname): | ||
| while time() - start_time < check_timeout: | ||
| try: | ||
| conn = psycopg2.connect(**vars()) | ||
| logger.info("Postgres is ready! ✨ 💅") | ||
| conn.close() | ||
| return True | ||
| except psycopg2.OperationalError: | ||
| logger.info(f"Postgres isn't ready. Waiting for {check_interval} {interval_unit}...") | ||
| sleep(check_interval) | ||
|
|
||
| logger.error(f"We could not connect to Postgres within {check_timeout} seconds.") | ||
| return False | ||
|
|
||
|
|
||
| pg_isready(**config) |
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.
Uh oh!
There was an error while loading. Please reload this page.