File size: 1,397 Bytes
bd6cd03
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2252732
 
 
bd6cd03
2252732
 
bd6cd03
 
 
 
2252732
bd6cd03
 
 
 
 
2252732
 
 
 
 
 
bd6cd03
 
 
2252732
 
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
FROM ubuntu:22.04

# Prevent interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive

# Update package list and install essential tools
RUN apt-get update && apt-get install -y \
    curl \
    wget \
    git \
    vim \
    nano \
    htop \
    tree \
    unzip \
    build-essential \
    python3 \
    python3-pip \
    nodejs \
    npm \
    && rm -rf /var/lib/apt/lists/*

# Create a non-root user for security
RUN useradd -m -s /bin/bash sandbox && \
    usermod -aG sudo sandbox && \
    echo "sandbox ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

# Set working directory
WORKDIR /home/sandbox

# Copy configuration files
COPY sandbox.yml /home/sandbox/
COPY tools.json /home/sandbox/
COPY init.sh /home/sandbox/
COPY startup.py /home/sandbox/
COPY requirements.txt /home/sandbox/

# Install Python packages from requirements.txt
RUN pip3 install --no-cache-dir -r /home/sandbox/requirements.txt

# Create directories for projects and tools
RUN mkdir -p /home/sandbox/projects && \
    mkdir -p /home/sandbox/tools && \
    chmod +x /home/sandbox/init.sh && \
    chown -R sandbox:sandbox /home/sandbox

# Switch to non-root user
USER sandbox

# Set working directory to sandbox home
WORKDIR /home/sandbox

# Run initialization script
RUN /home/sandbox/init.sh

# Expose common ports
EXPOSE 8000 8888 3000

# Start the application server
CMD ["python3", "startup.py"]