Last active
March 16, 2020 16:10
-
-
Save asadlive84/5d6c9199c46003555eb07effc0681760 to your computer and use it in GitHub Desktop.
This file contains 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
sudo docker build . | |
sudo docker-compose up | |
sudo docker-compose down | |
sudo docker-compose -d --build | |
sudo docker-compose exec web python manage.py migrate | |
sudo docker exec web [cmd] | |
FROM python:3.7-slim | |
ENV PYTHONDONTWRITEBYTECODE 1 | |
ENV PYTHONUNBUFFERED 1 | |
COPY requirements.txt /code/requirements.txt | |
WORKDIR /code | |
RUN pip install psycopg2-binary | |
RUN pip install -r requirements.txt | |
COPY . /code/ | |
docker compose | |
version: '3.3' | |
services: | |
web: | |
build: . | |
command: python /code/manage.py runserver 0.0.0.0:8000 | |
volumes: | |
- .:/code | |
ports: | |
- 8000:8000 | |
depends_on: | |
- db | |
db: | |
image: postgres:11 | |
restart: always | |
environment: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: postgres | |
volumes: | |
- postgres_data:/var/lib/postgresql/data/ | |
volumes: | |
postgres_data: | |
DATABASES = { | |
'default': { | |
'ENGINE': 'django.db.backends.postgresql_psycopg2', | |
'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