-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile
58 lines (42 loc) · 1.2 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
53
54
55
56
57
58
FROM python:3.11-alpine AS base
ENV LIBRDKAFKA_VERSION=1.9.2
# Install system dependencies and libraries
RUN apk add --no-cache \
gcc \
musl-dev \
librdkafka-dev \
build-base \
bash \
oniguruma-dev \
make \
autoconf \
automake \
libtool \
curl \
libffi-dev # Added libffi-dev for compatibility with some packages
# Install Poetry
RUN curl -sSL https://install.python-poetry.org | python3 -
# Ensure Poetry's bin directory is in PATH
ENV PATH="/root/.local/bin:$PATH"
WORKDIR /app
# Copy pyproject.toml and poetry.lock to the container
COPY pyproject.toml poetry.lock ./
RUN poetry config virtualenvs.in-project true
# Install Python dependencies using Poetry
RUN poetry install --without dev --no-ansi
FROM python:3.11-alpine AS prod
ENV LIBRDKAFKA_VERSION=1.9.2
# Install only runtime dependencies
RUN apk add --no-cache \
librdkafka-dev \
bash \
oniguruma-dev
WORKDIR /app
# Copy dependencies from the build stage
COPY --from=base /app /app
# Copy the application code
COPY ./app/. .
# Clean up old setuptools
RUN pip uninstall -y setuptools || true
# Run the application
CMD ["sh", "-c", "update-ca-certificates && /app/.venv/bin/python main.py"]