From 1d4c4206d6935ce436b25375cf13e56e0ffdaa62 Mon Sep 17 00:00:00 2001 From: Lude Ribeiro Date: Wed, 23 Mar 2022 16:07:51 -0300 Subject: [PATCH] criando o docker tentativa 19837912831293 --- Dockerfile | 17 +++-------------- docker-compose.yml | 28 +++++++++++----------------- settings.py | 14 -------------- sigi/settings/development.py | 2 +- sigi/settings/settings.py | 9 +++++++++ 5 files changed, 24 insertions(+), 46 deletions(-) delete mode 100644 settings.py create mode 100644 sigi/settings/settings.py diff --git a/Dockerfile b/Dockerfile index 479b4f8..ec42dd1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,13 @@ -#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 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 pg_ctl -D /var/lib/postgresql/data -l logfile start +# RUN --mount=type=cache,target=/root/.cache/pip pip install -r /code/requirements/dev-requirements.txt RUN pip install -r /code/requirements/dev-requirements.txt -RUN service pstgresql start \ No newline at end of file +RUN python manage.py migrate \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 677222c..1598e39 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,32 +1,26 @@ -version: "3" +version: "3.3" services: db: - image: postgres + image: postgres:12.9 volumes: - - ./data/db:/usr/local/var/postgresql/sigi + - ./data/db:/var/lib/postgresql/data environment: - POSTGRES_NAME=postgres - POSTGRES_USER=sigi - - POSTGRES_PASSWORD=sigi - web: + - POSTGRES_PASSWORD=123456 + code: 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" + - "8000:8000" environment: + - DB_HOST=db - POSTGRES_NAME=postgres - POSTGRES_USER=sigi - - POSTGRES_PASSWORD=sigi \ No newline at end of file + - POSTGRES_PASSWORD=132456 + depends_on: + - db + diff --git a/settings.py b/settings.py deleted file mode 100644 index f1b3fe5..0000000 --- a/settings.py +++ /dev/null @@ -1,14 +0,0 @@ -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, - } -} \ No newline at end of file diff --git a/sigi/settings/development.py b/sigi/settings/development.py index e55437c..f538605 100644 --- a/sigi/settings/development.py +++ b/sigi/settings/development.py @@ -27,7 +27,7 @@ DATABASES = { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'sigi', 'USER': 'sigi', - 'PASSWORD': 'sigi', + 'PASSWORD': '123456', 'HOST': 'localhost', } } diff --git a/sigi/settings/settings.py b/sigi/settings/settings.py new file mode 100644 index 0000000..531da31 --- /dev/null +++ b/sigi/settings/settings.py @@ -0,0 +1,9 @@ +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'NAME': 'sigi', + 'USER': 'sigi', + 'PASSWORD': '123456', + 'HOST': 'db', + } +} \ No newline at end of file