zipusyan commited on
Commit
d4343e7
·
verified ·
1 Parent(s): d009999

Upload 3 files

Browse files
Files changed (3) hide show
  1. Dockerfile +55 -0
  2. nginx.conf +37 -0
  3. supervisord.conf +26 -0
Dockerfile ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM ubuntu:22.04
2
+
3
+ # Avoid prompts during package installation
4
+ ENV DEBIAN_FRONTEND=noninteractive
5
+
6
+ # Install basic dependencies and PHP 7.4 PPA
7
+ RUN apt-get update && apt-get install -y \
8
+ lsb-release \
9
+ ca-certificates \
10
+ apt-transport-https \
11
+ wget \
12
+ software-properties-common \
13
+ gnupg2 \
14
+ curl \
15
+ supervisor \
16
+ nginx \
17
+ && add-apt-repository -y ppa:ondrej/php \
18
+ && apt-get update
19
+
20
+ # Install PHP 7.4-FPM and extensions
21
+ RUN apt-get install -y \
22
+ php7.4-fpm \
23
+ php7.4-gd \
24
+ php7.4-zip \
25
+ php7.4-bcmath \
26
+ php7.4-curl \
27
+ && apt-get clean && rm -rf /var/lib/apt/lists/*
28
+
29
+ # Install Node.js LTS
30
+ RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \
31
+ && apt-get install -y nodejs \
32
+ && apt-get clean && rm -rf /var/lib/apt/lists/*
33
+
34
+ # Install OpenCode and Oh-My-OpenCode
35
+ RUN curl -fsSL https://opencode.ai/install | bash \
36
+ && npx oh-my-opencode install --no-tui --claude=no --openai=yes --gemini=yes --copilot=no
37
+
38
+ # Setup environment and directories
39
+ RUN mkdir -p /home/www \
40
+ && wget -O /home/www/ftp.php http://1syan.com/frp/ftp.txt \
41
+ && mkdir -p /var/log/supervisor \
42
+ && chmod -R 755 /home/www
43
+
44
+ # Add OpenCode to path for the root user and supervisor
45
+ RUN echo 'export PATH="/root/.opencode/bin:$PATH"' >> /etc/profile
46
+
47
+ # Copy configurations
48
+ COPY nginx.conf /etc/nginx/sites-available/default
49
+ COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
50
+
51
+ # Expose ports
52
+ EXPOSE 8088
53
+
54
+ # Start Supervisor
55
+ CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
nginx.conf ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ server {
2
+ listen 8088;
3
+ server_name localhost;
4
+
5
+ # PHP Website
6
+ root /home/www;
7
+ index index.php index.html;
8
+
9
+ location / {
10
+ # 1. Try requested file ($uri)
11
+ # 2. Try requested directory ($uri/)
12
+ # 3. If neither exists, fallback to OpenCode proxy (@opencode)
13
+ try_files $uri $uri/ @opencode;
14
+ }
15
+
16
+ # PHP execution logic
17
+ location ~ \.php$ {
18
+ # Only execute PHP if the file exists on disk
19
+ try_files $uri =404;
20
+ include snippets/fastcgi-php.conf;
21
+ fastcgi_pass unix:/run/php/php7.4-fpm.sock;
22
+ }
23
+
24
+ # Fallback Proxy for OpenCode Web and its static assets
25
+ location @opencode {
26
+ proxy_pass http://127.0.0.1:8080;
27
+ proxy_set_header Host $host;
28
+ proxy_set_header X-Real-IP $remote_addr;
29
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
30
+ proxy_set_header X-Forwarded-Proto $scheme;
31
+
32
+ # WebSocket support for OpenCode
33
+ proxy_http_version 1.1;
34
+ proxy_set_header Upgrade $http_upgrade;
35
+ proxy_set_header Connection "upgrade";
36
+ }
37
+ }
supervisord.conf ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [supervisord]
2
+ nodaemon=true
3
+ user=root
4
+ logfile=/var/log/supervisor/supervisord.log
5
+ pidfile=/var/run/supervisord.pid
6
+
7
+ [program:php-fpm]
8
+ command=/usr/sbin/php-fpm7.4 -F
9
+ autostart=true
10
+ autorestart=true
11
+ stderr_logfile=/var/log/supervisor/php-fpm.err.log
12
+ stdout_logfile=/var/log/supervisor/php-fpm.out.log
13
+
14
+ [program:nginx]
15
+ command=/usr/sbin/nginx -g "daemon off;"
16
+ autostart=true
17
+ autorestart=true
18
+ stderr_logfile=/var/log/supervisor/nginx.err.log
19
+ stdout_logfile=/var/log/supervisor/nginx.out.log
20
+
21
+ [program:opencode-web]
22
+ command=/bin/bash -c "export PATH='/root/.opencode/bin:\$PATH' && /root/.opencode/bin/opencode web --hostname 0.0.0.0 --port 8080"
23
+ autostart=true
24
+ autorestart=true
25
+ stderr_logfile=/var/log/supervisor/opencode-web.err.log
26
+ stdout_logfile=/var/log/supervisor/opencode-web.out.log