Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Docker Setup and containerize database for easier local development #2926

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ LANGCHAIN_TRACING_V2=true
LANGCHAIN_PROJECT=default
LANGCHAIN_ENDPOINT="https://api.smith.langchain.com"

#DATABASE creds
DB_USER=user
DB_PASS=password
DB_NAME=blt-test
#Database URL
DATABASE_URL=postgres://user:password@localhost:5432/dbname

#Sentry DSN
SENTRY_DSN=https://[email protected]/0
11 changes: 6 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ RUN apt-get update && apt-get install -y \
libmemcached-dev \
libz-dev


RUN pip install poetry
RUN poetry config virtualenvs.create false
RUN poetry lock
RUN poetry install
RUN pip install opentelemetry-api opentelemetry-instrumentation

RUN python manage.py migrate
RUN python manage.py loaddata website/fixtures/initial_data.json
# RUN python manage.py collectstatic
RUN python manage.py initsuperuser

RUN python manage.py collectstatic --noinput
CMD python manage.py migrate && \
python manage.py create_superuser && \
python manage.py loaddata website/fixtures/initial_data.json
51 changes: 47 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,53 @@
version: "3"

version: "3.8"
services:
db:
image: postgres
container_name: postgres-db
restart: always
healthcheck:
test: ["CMD", "pg_isready", "-U", "user" , "-d" , "blt-test"]
interval: 10s
timeout: 5s
retries: 5

environment:
- POSTGRES_PASSWORD=${DB_PASS}
- POSTGRES_USER=${DB_USER}
- POSTGRES_DB=${DB_NAME}
ports:
- "5432:5432"
volumes:
- postgres_db:/var/lib/postgresql/data
networks:
app:
ipv4_address: 192.168.92.10

app:
command: "poetry run python manage.py runserver 0.0.0.0:8000"
build: .
container_name: app
restart: on-failure
env_file:
- .env
command: poetry run python manage.py runserver 0.0.0.0:8080
depends_on:
db:
condition: service_healthy
networks:
app:
ipv4_address: 192.168.92.22
volumes:
- .:/blt
ports:
- "8000:8000"
- "8080:8080"
environment:
DB_HOST: 192.168.92.10

volumes:
postgres_db:

networks:
app:
driver: bridge
ipam:
config:
- subnet: "192.168.92.0/24"