diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..53ff5d5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +# create image to export requirements +FROM python:3.11-slim AS poetry + +# build dependencies +RUN apt-get update \ + && apt-get install --no-install-recommends -y \ + build-essential \ + gcc \ + && apt-get autoremove -y \ + && apt-get clean -y \ + && rm -rf /var/lib/apt/lists/* + +# install poetry +RUN python -m pip install --no-cache-dir --upgrade poetry==1.8.2 + +# copy dependencies +COPY poetry.lock pyproject.toml ./ + +# create a requirements file +RUN poetry export -f requirements.txt --without-hashes -o /tmp/requirements.txt + + +# create batch search image +FROM python:3.11-slim as batch-search + +ENV \ + PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 \ + HOME="/srv/rfam-batch-search" + +# create folders and set work directory +RUN mkdir -p $HOME && mkdir /var/log/gunicorn +WORKDIR $HOME + +# install requirements +COPY --from=poetry /tmp/requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +# copy project +COPY . . + +EXPOSE 8000 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a55b8f4 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,27 @@ +version: '3' + +services: + # FastAPI + web: + build: . + command: gunicorn -c gunicorn/gunicorn_conf.py -b 0.0.0.0:8000 main:app + ports: + - "8000:8000" + networks: + - nginx-network + + # Nginx server + nginx: + image: nginx:1.26.0-alpine + ports: + - 80:80 + volumes: + - ./nginx/conf.d:/etc/nginx/conf.d + depends_on: + - web + networks: + - nginx-network + +networks: + nginx-network: + driver: bridge