File size: 1,304 Bytes
cf40512
 
fd09474
ed77ac8
cf40512
b8cfbd9
ed77ac8
cf40512
 
 
edcc92b
 
ed77ac8
 
cf40512
 
edcc92b
cf40512
b0c7410
edcc92b
cf40512
 
 
 
 
 
ed77ac8
cf40512
 
edcc92b
 
ed77ac8
edcc92b
 
ed77ac8
edcc92b
fd09474
cf40512
fd09474
edcc92b
cf40512
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
# Stage 1: Build Piston from source
FROM rust:1.72 as builder

# Install build dependencies
RUN apt-get update && apt-get install -y git pkg-config libssl-dev

# Clone Piston repo
WORKDIR /app
RUN git clone https://github.com/engineer-man/piston.git .

# Move into the correct directory (engine/)
WORKDIR /app/engine

# Build the API binary
RUN cargo build --release

# Stage 2: Runtime image
FROM debian:bullseye-slim

# Install Docker CLI (used by Piston to run sandboxed code)
RUN apt-get update && \
    apt-get install -y curl gnupg lsb-release && \
    curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && \
    echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null && \
    apt-get update && apt-get install -y docker-ce-cli

# Working directory
WORKDIR /app

# Copy compiled binary
COPY --from=builder /app/engine/target/release/piston-api /usr/local/bin/piston

# Copy Runtimes.toml (optional; may not exist in new layout)
COPY --from=builder /app/engine/Runtimes.toml ./Runtimes.toml

# Set Piston's port to 7860
ENV PORT=7860
EXPOSE 7860

# Start the server
CMD ["piston"]