File size: 2,829 Bytes
06ff972
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=UTC

# Install all necessary dependencies
RUN apt-get update && apt-get install -y \
    # Base
    wget curl git unzip zip \
    openjdk-17-jdk \
    # X11 and GUI
    xvfb x11vnc fluxbox \
    libxrender1 libxtst6 libxi6 libfontconfig1 \
    libgtk-3-0 libnss3 libxss1 libasound2 libgbm1 \
    # Web server
    nginx \
    # Process manager
    supervisor \
    # Terminal
    tini \
    # Node.js for web IDE server
    nodejs npm \
    # Additional useful tools
    nano vim htop \
    && rm -rf /var/lib/apt/lists/*

# Java setup
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
ENV PATH=$PATH:$JAVA_HOME/bin

# Download Android Studio
RUN wget https://redirector.gvt1.com/edgedl/android/studio/ide-zips/2022.3.1.19/android-studio-2022.3.1.19-linux.tar.gz && \
    tar -xzf android-studio-2022.3.1.19-linux.tar.gz -C /opt/ && \
    rm android-studio-2022.3.1.19-linux.tar.gz

# Android SDK
RUN wget https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip && \
    mkdir -p /opt/android-sdk/cmdline-tools && \
    unzip commandlinetools-linux-9477386_latest.zip -d /opt/android-sdk/cmdline-tools/ && \
    mv /opt/android-sdk/cmdline-tools/cmdline-tools /opt/android-sdk/cmdline-tools/latest && \
    rm commandlinetools-linux-9477386_latest.zip

# Install platform tools
RUN wget https://dl.google.com/android/repository/platform-tools-latest-linux.zip && \
    unzip platform-tools-latest-linux.zip -d /opt/android-sdk/ && \
    rm platform-tools-latest-linux.zip

# Environment variables
ENV ANDROID_HOME=/opt/android-sdk
ENV PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools

# Accept licenses
RUN yes | /opt/android-sdk/cmdline-tools/latest/bin/sdkmanager --licenses || true

# Install essential SDK components
RUN /opt/android-sdk/cmdline-tools/latest/bin/sdkmanager \
    "platform-tools" \
    "platforms;android-33" \
    "build-tools;33.0.0"

# Install noVNC
RUN git clone https://github.com/novnc/noVNC.git /opt/novnc && \
    git clone https://github.com/novnc/websockify.git /opt/novnc/utils/websockify

# Install web-based terminal
RUN wget https://github.com/tsl0922/ttyd/releases/download/1.7.3/ttyd.x86_64 -O /usr/local/bin/ttyd && \
    chmod +x /usr/local/bin/ttyd

# Setup workspace
WORKDIR /app

# Copy application files
COPY package.json server.js ./
COPY public/ ./public/
COPY nginx.conf /etc/nginx/nginx.conf
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY start.sh /start.sh

# Install Node dependencies
RUN npm install

# Create necessary directories
RUN mkdir -p /workspace/projects /workspace/.android

# Set permissions
RUN chmod +x /start.sh && \
    chmod -R 777 /workspace

# HF Spaces port
EXPOSE 7860

ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["/start.sh"]