-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
66 lines (52 loc) · 1.61 KB
/
Dockerfile
File metadata and controls
66 lines (52 loc) · 1.61 KB
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
# Multi-stage Dockerfile for Agent Integrations Finder
# Stage 1: Build stage
FROM python:3.11-slim AS builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
gcc \
g++ \
make \
zip \
tar \
gzip \
dpkg-dev \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy requirements and install Python dependencies
COPY requirements.txt build_requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt -r build_requirements.txt
# Copy source code
COPY . .
# Build the executable for the target architecture
ARG TARGETARCH
RUN if [ "$TARGETARCH" = "amd64" ]; then \
python build.py linux-x86_64; \
elif [ "$TARGETARCH" = "arm64" ]; then \
python build.py linux-aarch64; \
else \
echo "Unsupported architecture: $TARGETARCH"; \
exit 1; \
fi
# Stage 2: Runtime stage
FROM python:3.11-slim AS runtime
# Install minimal runtime dependencies
RUN apt-get update && apt-get install -y \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN useradd --create-home --shell /bin/bash app
# Set working directory
WORKDIR /app
# Copy Python dependencies from builder stage
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages/
# Copy the application source
COPY --from=builder /app/integrations_finder.py /app/
# Switch to non-root user
USER app
# Set environment variables
ENV PYTHONPATH=/usr/local/lib/python3.11/site-packages
ENV PATH=/usr/local/bin:$PATH
# Default command
ENTRYPOINT ["python", "/app/integrations_finder.py"]
CMD ["--help"]