-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathDockerfile
52 lines (41 loc) · 1.14 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
# Use Python 3.9 slim image as base
FROM python:3.9-slim
# Set working directory
WORKDIR /app
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
POETRY_VERSION=1.4.2 \
POETRY_HOME="/opt/poetry" \
POETRY_VIRTUALENVS_CREATE=false
# Add Poetry to PATH
ENV PATH="$POETRY_HOME/bin:$PATH"
# Install system dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
curl \
build-essential \
libpq-dev \
git \
&& rm -rf /var/lib/apt/lists/* \
# Install Poetry
&& curl -sSL https://install.python-poetry.org | python3 -
# Copy project files
COPY pyproject.toml poetry.lock README.md ./
COPY teleAgent ./teleAgent
COPY tests ./tests
COPY alembic.ini ./
COPY main.py ./
# Install dependencies
RUN poetry install --no-dev --no-interaction
# Create required directories
RUN mkdir -p logs
# Create a non-root user
RUN useradd -m -u 1000 teleAgent && \
chown -R teleAgent:teleAgent /app
# Switch to non-root user
USER teleAgent
# Expose port
EXPOSE 8000
# Set entrypoint
CMD ["poetry", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]