File size: 1,763 Bytes
7a88b43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
abe9dd4
 
 
 
 
 
 
7a88b43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#
# Dependencies stage
#
FROM python:3.12-slim-bullseye AS deps

ENV POETRY_VERSION  1.5.1

RUN apt-get update && apt-get install --no-install-recommends -y \
  gcc \
  libc-dev \
  libpq-dev \
  libpq5 \
  && rm -rf /var/lib/apt/lists/*

WORKDIR /tmp
COPY ./pyproject.toml /tmp

RUN pip install --no-cache-dir email-validator==2.1.0
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install -q --no-cache-dir poetry==$POETRY_VERSION \
  && poetry lock -q -n \
  && poetry export -f requirements.txt -o /tmp/requirements.txt --without-hashes \
  && pip uninstall -y poetry \
  && pip install --no-cache-dir -q -r /tmp/requirements.txt

#
# Base stage
#
FROM python:3.12-slim-bullseye AS base

ENV APP_NAME    MailPilot_ai_agents
ENV PREFIX      /opt/MailPilot
ENV PREFIX_APP  ${PREFIX}/${APP_NAME}

ENV PYTHONUNBUFFERED 1

RUN groupadd -g 20001 MailPilot \
  && useradd -l -M -u 10001 -g MailPilot MailPilot

WORKDIR /opt/MailPilot/MailPilot_ai_agents

# Copy the entire app directory
COPY ./app ./app

# Ensure proper permissions
RUN chmod -R 755 /opt/MailPilot/MailPilot_ai_agents

COPY ./docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh

RUN apt-get update && apt-get install --no-install-recommends -y libpq5 postgresql-client \
  && rm -rf /var/lib/apt/lists/*

COPY --from=deps /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY --from=deps /usr/local/bin /usr/local/bin
COPY . ${PREFIX_APP}

RUN chown -R MailPilot:MailPilot ${PREFIX_APP}

# Hugging Face specific configuration
EXPOSE 7860
ENV UVICORN_PORT=7860
ENV UVICORN_HOST=0.0.0.0

USER MailPilot

CMD ["uvicorn", "app.main:fastapi_app", "--host", "0.0.0.0", "--port", "7860"]