-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
54 lines (42 loc) · 1.56 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
# Stage 1: Builder
FROM python:3.11-slim-buster as builder
# Update and install necessary build dependencies
RUN apt-get update && apt-get upgrade -y \
&& apt-get install -y --no-install-recommends \
build-essential \
python3-dev \
&& pip install --upgrade pip \
&& pip install poetry \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install dependencies using Poetry
COPY pyproject.toml poetry.lock poetry.toml ./
RUN poetry install --no-interaction --no-ansi --no-cache --no-root --with=main --extras=examples
# Copy the rest of the application
COPY . .
RUN poetry install --no-interaction --no-ansi --no-cache --with=main --extras=examples
RUN poetry run codegen
# Stage 2: Final image
FROM python:3.11-slim-buster as server
# Update and upgrade system packages, including specific security fixes
RUN apt-get update && apt-get upgrade -y \
&& apt-get install -y --no-install-recommends \
build-essential \
python3-dev \
&& pip install --upgrade pip \
&& pip install poetry \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy the application code and installed dependencies from the builder stage
RUN useradd -m -u 1001 appuser
COPY --chown=appuser --from=builder /app .
# Add and make the entrypoint script executable
COPY ./scripts/docker_entrypoint.sh /docker_entrypoint.sh
RUN chmod +x /docker_entrypoint.sh
# Expose port 5000 and set user
EXPOSE 5000
USER appuser
ENTRYPOINT ["/docker_entrypoint.sh"]
CMD uvicorn aidial_interceptors_sdk.examples.app:app --host 0.0.0.0 --port 5000