From 0ea165fcff7213c184d3f8bed09b4c6883b152d5 Mon Sep 17 00:00:00 2001 From: Dana Lambert Date: Wed, 6 Oct 2021 14:06:55 +1300 Subject: [PATCH] Add docker-compose file to run applications and postgres locally --- backend/Dockerfile | 9 ++++++++ backend/requirements.txt | 1 + docker-compose.yaml | 47 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 backend/Dockerfile create mode 100644 backend/requirements.txt create mode 100644 docker-compose.yaml diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..e9af939 --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,9 @@ +FROM python:3.8-slim-bullseye + +WORKDIR /app + +COPY ./requirements.txt /app/requirements.txt + +RUN pip install -U --no-cache-dir -r requirements.txt + +COPY . /app diff --git a/backend/requirements.txt b/backend/requirements.txt new file mode 100644 index 0000000..b071abf --- /dev/null +++ b/backend/requirements.txt @@ -0,0 +1 @@ +Django==3.2.8 \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..ecf4239 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,47 @@ +version: "3.8" + +volumes: + local-postgres-data: + name: local-postgres-data + +services: + django-backend: + restart: unless-stopped + build: + context: backend + dockerfile: Dockerfile + container_name: righttree-backend + depends_on: + - postgres + volumes: + - ./backend:/app + ports: + - "8000:8000" + command: bash -c "./manage.py makemigrations; + ./manage.py migrate; + ./manage.py runserver 0.0.0.0:8000" + + react-frontend: + image: node:16-alpine3.11 + restart: unless-stopped + container_name: righttree-frontend + ports: + - "3000:3000" + volumes: + - ./frontend:/app + working_dir: /app + command: sh -c "npm install; npm start" + + postgres: + image: postgis/postgis:13-3.0 + restart: unless-stopped + container_name: postgres + volumes: + - local-postgres-data:/var/lib/postgresql/data + ports: + - "5432:5432" + environment: + - POSTGRES_DB=postgres + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=postgres + \ No newline at end of file