From 1424fb2f431f8bc0e7e98222f1df488b53782ffa Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Fri, 19 May 2023 16:20:57 +0700 Subject: [PATCH] Docker-compose with the couchdb backend --- .gitignore | 2 ++ Dockerfile | 19 +++++++++++++------ docker-compose.yml | 19 +++++++++++++++++++ 3 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 docker-compose.yml diff --git a/.gitignore b/.gitignore index 572fede..b2389d6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /target venv __pycache__ +/.env +/data/ diff --git a/Dockerfile b/Dockerfile index 224cd12..d7227ac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,18 @@ -FROM python:3.11 +# Use an official Python runtime as a parent image +FROM python:3 -WORKDIR /code +# Set the working directory in the container +WORKDIR /app -COPY ./requirements.txt /code/requirements.txt +# Install any needed packages specified in requirements.txt +COPY requirements.txt /app/ +RUN pip install --no-cache-dir -r requirements.txt -RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt +# Copy the current directory contents into the container at /app +COPY . /app/ -COPY ./app /code/app +# Make port 8000 available to the world outside this container +EXPOSE 8000 -CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80"] +# Run api.py when the container launches +CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "8000"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..be96b13 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,19 @@ +version: '3' +services: + couchdb: + image: couchdb:latest + network_mode: host + volumes: + - ./data:/opt/couchdb/data:Z + env_file: + - .env + + fastapi_app: + build: + context: . + dockerfile: Dockerfile + network_mode: host + depends_on: + - couchdb + env_file: + - .env