-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
38 lines (31 loc) · 945 Bytes
/
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
# Dockerfile
# Use the official Python 3.11 slim image
FROM python:3.11-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
POETRY_VERSION=1.7.1 \
POETRY_HOME="/opt/poetry" \
POETRY_VIRTUALENVS_CREATE=false \
PATH="/opt/poetry/bin:$PATH"
# Install system dependencies and Poetry in a single layer
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
libpq-dev \
build-essential \
curl \
&& curl -sSL https://install.python-poetry.org | python3 - \
&& apt-get remove -y curl \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Set work directory
WORKDIR /app
# Copy dependency files
COPY pyproject.toml poetry.lock ./
# Install dependencies
RUN poetry install --no-root --no-dev --no-interaction
# Copy application code
COPY . .
# Command to run application
CMD ["poetry", "run", "python", "main.py"]