Browse Source

Subindo do jeito que ta o docker

Co-authored-by: Davi Galati<davigalati@gmail.com>
Dockerlg
Lude Ribeiro 3 years ago
parent
commit
f464ba6636
  1. 24
      Dockerfile
  2. 32
      docker-compose.yml
  3. 14
      settings.py
  4. 2
      sigi/settings/development.py

24
Dockerfile

@ -1,6 +1,24 @@
#FROM ubuntu
#FROM python:3
#ENV PYTHONDONTWRITEBYTECODE=1
#ENV PYTHONUNBUFFERED=1
#CMD apt install update
#CMD apt install upgrade -y
#CMD apt install build-essential python3-dev graphviz libgraphviz-dev pkg-config libpq-dev -y
#RUN pip install --upgrade pip
#COPY . /dck/
#RUN pip install -r dck/requirements/dev-requirements.txt
#CMD python ./manage.py runserver
FROM python:3
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
COPY requirements/dev-requirements.txt /
RUN pip install -r requirements/dev-requirements.txt
CMD python ./manage.py runserver
RUN apt update
RUN apt upgrade -y
RUN apt install build-essential python3-dev graphviz libgraphviz-dev pkg-config libpq-dev -y
RUN pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
RUN pip install --upgrade pip
WORKDIR /code
COPY . /code/
RUN pip install -r /code/requirements/dev-requirements.txt
RUN service pstgresql start

32
docker-compose.yml

@ -0,0 +1,32 @@
version: "3"
services:
db:
image: postgres
volumes:
- ./data/db:/usr/local/var/postgresql/sigi
environment:
- POSTGRES_NAME=postgres
- POSTGRES_USER=sigi
- POSTGRES_PASSWORD=sigi
web:
build: .
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8001:8000"
environment:
- POSTGRES_NAME=sigi
- POSTGRES_USER=sigi
- POSTGRES_PASSWORD=sigi
depends_on:
- postgres
postgres:
image: postgres:12.9
ports:
- "5433:5432"
environment:
- POSTGRES_NAME=postgres
- POSTGRES_USER=sigi
- POSTGRES_PASSWORD=sigi

14
settings.py

@ -0,0 +1,14 @@
import os
[...]
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ.get('POSTGRES_NAME'),
'USER': os.environ.get('POSTGRES_USER'),
'PASSWORD': os.environ.get('POSTGRES_PASSWORD'),
'HOST': 'db',
'PORT': 5432,
}
}

2
sigi/settings/development.py

@ -27,7 +27,7 @@ DATABASES = {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'sigi',
'USER': 'sigi',
'PASSWORD': '123456',
'PASSWORD': 'sigi',
'HOST': 'localhost',
}
}

Loading…
Cancel
Save