-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
52 lines (38 loc) · 1.3 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# create image to export requirements
FROM python:3.11-slim-bullseye 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-bullseye as batch-search
ENV \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
HOME="/srv/rfam-batch-search"
# create folder and log file
RUN mkdir -p $HOME && touch /var/log/gunicorn.log
# create user
RUN useradd -m -d $HOME -s /bin/bash rfam
# set work directory
WORKDIR $HOME
# install requirements
COPY --from=poetry /tmp/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# copy project
COPY . .
RUN chown -R rfam:rfam /srv && chown rfam:rfam /var/log/gunicorn.log
# set user
USER rfam
# run the FastAPI app
CMD [ "gunicorn", "-k", "uvicorn.workers.UvicornWorker", "-w", "4", "-b", "0.0.0.0:8000", "--capture-output", "--access-logfile", "-", "--error-logfile", "-", "main:app"]