Last active
March 3, 2023 01:04
-
-
Save UlugbekMuslitdinov/1d31a6b2076b07a74bb3cc51c9324a96 to your computer and use it in GitHub Desktop.
Django, Docker-compose and PostgreSQL
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
version: '3.8' | |
services: | |
web: | |
build: . | |
# command: python /code/manage.py runserver 0.0.0.0:8000 | |
command: gunicorn config.wsgi -b 0.0.0.0:8000 | |
environment: | |
- ENVIRONMENT=production | |
- SECRET_KEY=YOUR-DJANGO-SECRET-KEY | |
volumes: | |
- .:/code | |
ports: | |
- 8000:8000 | |
depends_on: | |
- db | |
db: | |
image: postgres:11 | |
volumes: | |
- postgres_data:/var/lib/postgresql/data/ | |
environment: | |
- "POSTGRES_HOST_AUTH_METHOD=trust" | |
volumes: | |
postgres_data: |
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
version: '3.8' | |
services: | |
web: | |
build: . | |
# command: python /code/manage.py runserver 0.0.0.0:8000 | |
command: gunicorn config.wsgi -b 0.0.0.0:8000 | |
environment: | |
- ENVIRONMENT=development | |
- SECRET_KEY=YOUR-DJANGO-SECRET-KEY | |
- DEBUG=1 | |
volumes: | |
- .:/code | |
ports: | |
- 8000:8000 | |
depends_on: | |
- db | |
db: | |
image: postgres:11 | |
volumes: | |
- postgres_data:/var/lib/postgresql/data/ | |
environment: | |
- "POSTGRES_HOST_AUTH_METHOD=trust" | |
volumes: | |
postgres_data: |
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
# Pull base image | |
FROM python:3.8 | |
# Set environment variables | |
ENV PYTHONDONTWRITEBYTECODE 1 | |
ENV PYTHONUNBUFFERED 1 | |
# Set work directory | |
WORKDIR /code | |
# Install dependencies | |
COPY Pipfile Pipfile.lock /code/ | |
RUN pip install pipenv && pipenv install --system | |
# Copy project | |
COPY . /code/ |
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
# Database | |
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases | |
DATABASES = { | |
'default': { | |
'ENGINE': 'django.db.backends.postgresql', | |
'NAME': 'postgres', | |
'USER': 'postgres', | |
'PASSWORD': 'postgres', | |
'HOST': 'db', | |
'PORT': 5432 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment