Skip to content

Instantly share code, notes, and snippets.

@asadlive84
Last active March 16, 2020 16:10
Show Gist options
  • Save asadlive84/5d6c9199c46003555eb07effc0681760 to your computer and use it in GitHub Desktop.
Save asadlive84/5d6c9199c46003555eb07effc0681760 to your computer and use it in GitHub Desktop.

Revisions

  1. asadlive84 revised this gist Mar 16, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions Dockerfile_for_django.txt
    Original file line number Diff line number Diff line change
    @@ -15,6 +15,7 @@ ENV PYTHONUNBUFFERED 1
    COPY requirements.txt /code/requirements.txt

    WORKDIR /code
    RUN pip install psycopg2-binary

    RUN pip install -r requirements.txt

  2. asadlive84 revised this gist Mar 16, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Dockerfile_for_django.txt
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ sudo docker build .
    sudo docker-compose up
    sudo docker-compose down
    sudo docker-compose -d --build
    sudo docker exec web python manage.py migrate
    sudo docker-compose exec web python manage.py migrate
    sudo docker exec web [cmd]


  3. asadlive84 revised this gist Mar 16, 2020. 1 changed file with 19 additions and 0 deletions.
    19 changes: 19 additions & 0 deletions Dockerfile_for_django.txt
    Original file line number Diff line number Diff line change
    @@ -51,3 +51,22 @@ services:

    volumes:
    postgres_data:








    DATABASES = {
    'default': {
    'ENGINE': 'django.db.backends.postgresql_psycopg2',
    'NAME': 'postgres',
    'USER': 'postgres',
    'PASSWORD': 'postgres',
    'HOST': 'db',
    'PORT': '5432',

    }
    }
  4. asadlive84 created this gist Mar 12, 2020.
    53 changes: 53 additions & 0 deletions Dockerfile_for_django.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,53 @@
    sudo docker build .
    sudo docker-compose up
    sudo docker-compose down
    sudo docker-compose -d --build
    sudo docker 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 -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: