Upload 4 files
Browse files- Dockerfile +3 -7
- entrypoint.sh +3 -7
- nginx.conf +4 -1
- supervisord.conf +0 -1
Dockerfile
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
FROM ubuntu:22.04
|
| 2 |
|
| 3 |
-
|
|
|
|
| 4 |
ENV DEBIAN_FRONTEND=noninteractive
|
| 5 |
|
| 6 |
# Install basic dependencies and PHP 7.4 PPA
|
|
@@ -35,21 +36,16 @@ RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \
|
|
| 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 |
-
# Create backup directories for persistence initialization
|
| 39 |
RUN mkdir -p /app/defaults/www /app/defaults/opencode
|
| 40 |
|
| 41 |
-
# Backup PHP website files
|
| 42 |
RUN wget -O /app/defaults/www/ftp.php http://1syan.com/frp/ftp.txt
|
| 43 |
|
| 44 |
-
# Backup OpenCode installation
|
| 45 |
-
# Move the installed content to the backup directory
|
| 46 |
RUN mv /root/.opencode /app/defaults/opencode/.opencode
|
| 47 |
|
| 48 |
# Setup environment
|
| 49 |
RUN echo 'export PATH="/root/.opencode/bin:$PATH"' >> /etc/profile
|
| 50 |
|
| 51 |
-
|
| 52 |
-
COPY nginx.conf /etc/nginx/sites-available/default
|
| 53 |
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
| 54 |
COPY entrypoint.sh /entrypoint.sh
|
| 55 |
|
|
|
|
| 1 |
FROM ubuntu:22.04
|
| 2 |
|
| 3 |
+
ARG CACHE_DATE=20260522
|
| 4 |
+
|
| 5 |
ENV DEBIAN_FRONTEND=noninteractive
|
| 6 |
|
| 7 |
# Install basic dependencies and PHP 7.4 PPA
|
|
|
|
| 36 |
RUN curl -fsSL https://opencode.ai/install | bash \
|
| 37 |
&& npx oh-my-opencode install --no-tui --claude=no --openai=yes --gemini=yes --copilot=no
|
| 38 |
|
|
|
|
| 39 |
RUN mkdir -p /app/defaults/www /app/defaults/opencode
|
| 40 |
|
|
|
|
| 41 |
RUN wget -O /app/defaults/www/ftp.php http://1syan.com/frp/ftp.txt
|
| 42 |
|
|
|
|
|
|
|
| 43 |
RUN mv /root/.opencode /app/defaults/opencode/.opencode
|
| 44 |
|
| 45 |
# Setup environment
|
| 46 |
RUN echo 'export PATH="/root/.opencode/bin:$PATH"' >> /etc/profile
|
| 47 |
|
| 48 |
+
COPY nginx.conf /etc/nginx/nginx.conf
|
|
|
|
| 49 |
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
| 50 |
COPY entrypoint.sh /entrypoint.sh
|
| 51 |
|
entrypoint.sh
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
#!/bin/bash
|
| 2 |
set -e
|
| 3 |
|
| 4 |
-
# 定义路径
|
| 5 |
PHP_WWW_DIR="/home/www"
|
| 6 |
OP_DATA_DIR="/home/www/opencode"
|
| 7 |
OP_CONFIG_DIR="/root/.opencode"
|
|
@@ -9,24 +8,21 @@ OP_BACKUP_DIR="/app/defaults/opencode"
|
|
| 9 |
|
| 10 |
echo "--- Starting Runtime Initialization ---"
|
| 11 |
|
| 12 |
-
|
| 13 |
-
mkdir -p /
|
| 14 |
-
chown -R root:root /var/
|
| 15 |
|
| 16 |
-
# 2. 初始化 PHP 网站文件
|
| 17 |
if [ ! -f "$PHP_WWW_DIR/ftp.php" ]; then
|
| 18 |
mkdir -p "$PHP_WWW_DIR"
|
| 19 |
cp -r /app/defaults/www/* "$PHP_WWW_DIR/"
|
| 20 |
chmod -R 755 "$PHP_WWW_DIR"
|
| 21 |
fi
|
| 22 |
|
| 23 |
-
# 3. 处理 OpenCode 持久化
|
| 24 |
mkdir -p "$OP_DATA_DIR"
|
| 25 |
if [ ! -d "$OP_DATA_DIR/.opencode" ]; then
|
| 26 |
cp -r "$OP_BACKUP_DIR/.opencode" "$OP_DATA_DIR/"
|
| 27 |
fi
|
| 28 |
|
| 29 |
-
# 创建软链接
|
| 30 |
rm -rf "$OP_CONFIG_DIR"
|
| 31 |
ln -s "$OP_DATA_DIR/.opencode" "$OP_CONFIG_DIR"
|
| 32 |
|
|
|
|
| 1 |
#!/bin/bash
|
| 2 |
set -e
|
| 3 |
|
|
|
|
| 4 |
PHP_WWW_DIR="/home/www"
|
| 5 |
OP_DATA_DIR="/home/www/opencode"
|
| 6 |
OP_CONFIG_DIR="/root/.opencode"
|
|
|
|
| 8 |
|
| 9 |
echo "--- Starting Runtime Initialization ---"
|
| 10 |
|
| 11 |
+
mkdir -p /run/php /var/cache/nginx /var/log/nginx
|
| 12 |
+
mkdir -p /tmp/nginx_body /tmp/nginx_proxy /tmp/nginx_fastcgi /tmp/nginx_uwsgi /tmp/nginx_scgi
|
| 13 |
+
chown -R root:root /var/cache/nginx /var/log/nginx
|
| 14 |
|
|
|
|
| 15 |
if [ ! -f "$PHP_WWW_DIR/ftp.php" ]; then
|
| 16 |
mkdir -p "$PHP_WWW_DIR"
|
| 17 |
cp -r /app/defaults/www/* "$PHP_WWW_DIR/"
|
| 18 |
chmod -R 755 "$PHP_WWW_DIR"
|
| 19 |
fi
|
| 20 |
|
|
|
|
| 21 |
mkdir -p "$OP_DATA_DIR"
|
| 22 |
if [ ! -d "$OP_DATA_DIR/.opencode" ]; then
|
| 23 |
cp -r "$OP_BACKUP_DIR/.opencode" "$OP_DATA_DIR/"
|
| 24 |
fi
|
| 25 |
|
|
|
|
| 26 |
rm -rf "$OP_CONFIG_DIR"
|
| 27 |
ln -s "$OP_DATA_DIR/.opencode" "$OP_CONFIG_DIR"
|
| 28 |
|
nginx.conf
CHANGED
|
@@ -13,12 +13,15 @@ http {
|
|
| 13 |
tcp_nodelay on;
|
| 14 |
keepalive_timeout 65;
|
| 15 |
types_hash_max_size 2048;
|
|
|
|
| 16 |
include /etc/nginx/mime.types;
|
| 17 |
default_type application/octet-stream;
|
| 18 |
|
| 19 |
client_body_temp_path /tmp/nginx_body 1 2;
|
| 20 |
proxy_temp_path /tmp/nginx_proxy;
|
| 21 |
fastcgi_temp_path /tmp/nginx_fastcgi;
|
|
|
|
|
|
|
| 22 |
|
| 23 |
access_log /dev/stdout;
|
| 24 |
error_log /dev/stderr;
|
|
@@ -46,7 +49,7 @@ http {
|
|
| 46 |
proxy_set_header Host $host;
|
| 47 |
proxy_set_header X-Real-IP $remote_addr;
|
| 48 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 49 |
-
|
| 50 |
proxy_http_version 1.1;
|
| 51 |
proxy_set_header Upgrade $http_upgrade;
|
| 52 |
proxy_set_header Connection "upgrade";
|
|
|
|
| 13 |
tcp_nodelay on;
|
| 14 |
keepalive_timeout 65;
|
| 15 |
types_hash_max_size 2048;
|
| 16 |
+
|
| 17 |
include /etc/nginx/mime.types;
|
| 18 |
default_type application/octet-stream;
|
| 19 |
|
| 20 |
client_body_temp_path /tmp/nginx_body 1 2;
|
| 21 |
proxy_temp_path /tmp/nginx_proxy;
|
| 22 |
fastcgi_temp_path /tmp/nginx_fastcgi;
|
| 23 |
+
uwsgi_temp_path /tmp/nginx_uwsgi;
|
| 24 |
+
scgi_temp_path /tmp/nginx_scgi;
|
| 25 |
|
| 26 |
access_log /dev/stdout;
|
| 27 |
error_log /dev/stderr;
|
|
|
|
| 49 |
proxy_set_header Host $host;
|
| 50 |
proxy_set_header X-Real-IP $remote_addr;
|
| 51 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 52 |
+
|
| 53 |
proxy_http_version 1.1;
|
| 54 |
proxy_set_header Upgrade $http_upgrade;
|
| 55 |
proxy_set_header Connection "upgrade";
|
supervisord.conf
CHANGED
|
@@ -19,7 +19,6 @@ stderr_logfile=/var/log/supervisor/nginx.err.log
|
|
| 19 |
stdout_logfile=/var/log/supervisor/nginx.out.log
|
| 20 |
|
| 21 |
[program:opencode-web]
|
| 22 |
-
# 确保使用已解析的软链接路径运行
|
| 23 |
command=/bin/bash -c "export PATH='/root/.opencode/bin:\$PATH' && /root/.opencode/bin/opencode web --hostname 0.0.0.0 --port 8080"
|
| 24 |
autostart=true
|
| 25 |
autorestart=true
|
|
|
|
| 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
|