Skip to content

Commit

Permalink
Create docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosribas committed May 7, 2024
1 parent 80d2017 commit 5f14a9b
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
42 changes: 42 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 5f14a9b

Please sign in to comment.