-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (51 loc) · 1.45 KB
/
Dockerfile
File metadata and controls
64 lines (51 loc) · 1.45 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
# --- Stage 1: Build nsjail ---
FROM ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install dependencies for building nsjail
RUN apt-get update && apt-get install -y \
autoconf \
bison \
flex \
gcc \
g++ \
git \
libprotobuf-dev \
libnl-route-3-dev \
libtool \
make \
pkg-config \
protobuf-compiler \
&& rm -rf /var/lib/apt/lists/*
# Clone and build nsjail
WORKDIR /src
RUN git clone https://github.com/google/nsjail.git
WORKDIR /src/nsjail
RUN make && mv nsjail /usr/bin/nsjail
# --- Stage 2: Final Runtime Image ---
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
# Install Python 3, pip, and the Runtime libraries for nsjail
RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
libprotobuf-dev \
libnl-route-3-200 \
&& rm -rf /var/lib/apt/lists/*
# Set work directory
WORKDIR /app
# Install Python dependencies
COPY requirements.txt .
# FIXED: Removed "--break-system-packages" which is not supported/needed on Ubuntu 22.04
RUN pip3 install --no-cache-dir -r requirements.txt
# Copy nsjail binary from builder
COPY --from=builder /usr/bin/nsjail /usr/bin/nsjail
# Copy application code
COPY app.py .
COPY runner.py .
# Create a non-root user (used by nsjail)
RUN groupadd -g 99999 sanduser && \
useradd -r -u 99999 -g sanduser sanduser
# Expose the required port
EXPOSE 8080
# Start command using Gunicorn
CMD ["gunicorn", "--bind", "0.0.0.0:8080", "app:app"]