From 9c585ab684c53e38190fb0fa4e77dd204271a592 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Thu, 17 Feb 2022 17:01:25 +0800 Subject: [PATCH] update: docker environment --- Dockerfile | 45 ++++++++++++++++---- docker/compile.py | 10 +++++ docker/init.sh | 3 ++ {test/docker => docker/test}/shadowsocks.py | 0 {test/docker => docker/test}/shadowsocksr.py | 0 {test/docker => docker/test}/sip003.py | 0 6 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 docker/compile.py create mode 100644 docker/init.sh rename {test/docker => docker/test}/shadowsocks.py (100%) rename {test/docker => docker/test}/shadowsocksr.py (100%) rename {test/docker => docker/test}/sip003.py (100%) diff --git a/Dockerfile b/Dockerfile index 6be9efa..b95fe58 100644 --- a/Dockerfile +++ b/Dockerfile @@ -73,12 +73,36 @@ cd /tmp/ && tar xf openssl-1.0.2u.tar.gz && cd ./openssl-1.0.2u/ && \ ./config --shared --prefix=/usr && make && make install && \ cp /usr/lib/libcrypto.so.1.0.0 /tmp/release/ && \ \ -# Install and package numpy / salsa20 -pip install numpy salsa20 && \ +# Install and package numpy / salsa20 / flask / IPy / redis / pysocks / requests +pip install numpy salsa20 flask IPy redis pysocks && \ mkdir /tmp/packages/ && cd /tmp/packages/ && \ -PYTHON_DIR=/usr/lib/`ls /usr/lib/ | grep ^python` && \ -cp -r $PYTHON_DIR/site-packages/*numpy* ./ && \ -cp -r $PYTHON_DIR/site-packages/*salsa20* ./ && \ +PACKAGE_DIR=/usr/lib/`ls /usr/lib/ | grep ^python`/site-packages && \ +cp -r $PACKAGE_DIR/*certifi* ./ && \ +cp -r $PACKAGE_DIR/*charset* ./ && \ +cp -r $PACKAGE_DIR/*click* ./ && \ +cp -r $PACKAGE_DIR/*deprecated* ./ && \ +cp -r $PACKAGE_DIR/*Deprecated* ./ && \ +cp -r $PACKAGE_DIR/*flask* ./ && \ +cp -r $PACKAGE_DIR/*Flask* ./ && \ +cp -r $PACKAGE_DIR/*idna* ./ && \ +cp -r $PACKAGE_DIR/*IPy* ./ && \ +cp -r $PACKAGE_DIR/*itsdangerous* ./ && \ +cp -r $PACKAGE_DIR/*Jinja2* ./ && \ +cp -r $PACKAGE_DIR/*jinja2* ./ && \ +cp -r $PACKAGE_DIR/*Jinja2* ./ && \ +cp -r $PACKAGE_DIR/*markupsafe* ./ && \ +cp -r $PACKAGE_DIR/*MarkupSafe* ./ && \ +cp -r $PACKAGE_DIR/*numpy* ./ && \ +cp -r $PACKAGE_DIR/*packaging* ./ && \ +cp -r $PACKAGE_DIR/*PySocks* ./ && \ +cp -r $PACKAGE_DIR/*redis* ./ && \ +cp -r $PACKAGE_DIR/*requests* ./ && \ +cp -r $PACKAGE_DIR/*salsa20* ./ && \ +cp -r $PACKAGE_DIR/*socks* ./ && \ +cp -r $PACKAGE_DIR/*urllib3* ./ && \ +cp -r $PACKAGE_DIR/*werkzeug* ./ && \ +cp -r $PACKAGE_DIR/*Werkzeug* ./ && \ +cp -r $PACKAGE_DIR/*wrapt* ./ && \ rm -rf `find ./ -name '__pycache__'` && \ strip `find ./ -name '*.so'` && \ cd ../ && tar czf packages.tar.gz ./packages/ && \ @@ -241,14 +265,16 @@ cd /tmp/packages/ && \ tar xf ssr-python.tar.bz2 && rm -f ./ssr-python.tar.bz2 && \ tar xf ss-python.tar.bz2 && rm -f ./ss-python.tar.bz2 && \ tar xf ss-python-legacy.tar.bz2 && rm -f ./ss-python-legacy.tar.bz2 && \ -PYTHON_NAME=`ls /usr/lib/ | grep ^python` && \ -mkdir -p /tmp/lib/$PYTHON_NAME/ && \ -mv /tmp/packages/ /tmp/lib/$PYTHON_NAME/site-packages/ +PYTHON_DIR=`ls /usr/lib/ | grep ^python` && \ +mkdir -p /tmp/lib/$PYTHON_DIR/ && \ +mv /tmp/packages/ /tmp/lib/$PYTHON_DIR/site-packages/ FROM alpine:3.15 +COPY . /usr/local/share/ProxyC COPY --from=asset /tmp/bin/ /usr/bin/ COPY --from=asset /tmp/lib/ /usr/lib/ -RUN apk add --no-cache c-ares glib libev libsodium mbedtls pcre python3 udns && \ +RUN apk add --no-cache c-ares glib libev libsodium mbedtls pcre python3 redis udns && \ +echo "daemonize yes" >> /etc/redis.conf && \ PKG_DIR=/usr/lib/`ls /usr/lib/ | grep ^python`/site-packages && \ rm -rf `find /usr/lib/ -name '__pycache__'` && \ ln -s $PKG_DIR/ssr-python/local.py /usr/bin/ssr-local && \ @@ -258,3 +284,4 @@ ln -s $PKG_DIR/ss-python/server.py /usr/bin/ss-python-server && \ ln -s $PKG_DIR/ss-python-legacy/local.py /usr/bin/ss-python-legacy-local && \ ln -s $PKG_DIR/ss-python-legacy/server.py /usr/bin/ss-python-legacy-server && \ ln -s /usr/bin/python3 /usr/bin/python +EXPOSE 43581 diff --git a/docker/compile.py b/docker/compile.py new file mode 100644 index 0000000..5751689 --- /dev/null +++ b/docker/compile.py @@ -0,0 +1,10 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +import compileall + +maxLevels = 256 +compileDir = '/usr' +compileall.compile_dir(compileDir, quiet = 1, maxlevels = maxLevels) +compileall.compile_dir(compileDir, quiet = 1, maxlevels = maxLevels, optimize = 1) +compileall.compile_dir(compileDir, quiet = 1, maxlevels = maxLevels, optimize = 2) diff --git a/docker/init.sh b/docker/init.sh new file mode 100644 index 0000000..e48aa5e --- /dev/null +++ b/docker/init.sh @@ -0,0 +1,3 @@ +python /usr/local/share/ProxyC/docker/compile.py & +/usr/bin/redis-server /etc/redis.conf +echo "ProxyC is running..." diff --git a/test/docker/shadowsocks.py b/docker/test/shadowsocks.py similarity index 100% rename from test/docker/shadowsocks.py rename to docker/test/shadowsocks.py diff --git a/test/docker/shadowsocksr.py b/docker/test/shadowsocksr.py similarity index 100% rename from test/docker/shadowsocksr.py rename to docker/test/shadowsocksr.py diff --git a/test/docker/sip003.py b/docker/test/sip003.py similarity index 100% rename from test/docker/sip003.py rename to docker/test/sip003.py