mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
adding frpc support for develop docker
This commit is contained in:
parent
961e786cc6
commit
75a12497aa
@ -86,11 +86,4 @@ RUN cd /root && wget https://gitee.com/Lyon1998/pikapython/attach_files/1420660/
|
||||
mv frp_0.48.0_linux_amd64/frpc /usr/local/bin/frpc
|
||||
|
||||
COPY frpc.ini /etc/frpc.ini
|
||||
ARG FRPC_SERVER_ADDR
|
||||
ARG FRPC_SERVER_PORT
|
||||
ARG FRPC_REMOTE_PORT
|
||||
ARG FRPC_TOKEN
|
||||
RUN sed -i "s|%FRPC_SERVER_ADDR%|${FRPC_SERVER_ADDR}|" /etc/frpc.ini && \
|
||||
sed -i "s|%FRPC_SERVER_PORT%|${FRPC_SERVER_PORT}|" /etc/frpc.ini && \
|
||||
sed -i "s|%FRPC_REMOTE_PORT%|${FRPC_REMOTE_PORT}|" /etc/frpc.ini && \
|
||||
sed -i "s|%FRPC_TOKEN%|${FRPC_TOKEN}|" /etc/frpc.ini
|
||||
COPY frpc.sh /etc/frpc.sh
|
||||
|
@ -1,12 +1,14 @@
|
||||
# 全局配置
|
||||
####### Frpc config #######
|
||||
|
||||
[common]
|
||||
server_addr = %FRPC_SERVER_ADDR%
|
||||
server_port = %FRPC_SERVER_PORT%
|
||||
token = %FRPC_TOKEN%
|
||||
|
||||
# SSH代理配置
|
||||
[ssh]
|
||||
type = tcp
|
||||
local_ip = 127.0.0.1
|
||||
local_port = 22
|
||||
remote_port = %FRPC_REMOTE_PORT%
|
||||
|
||||
####### Frpc config #######
|
||||
|
6
docker/frpc.sh
Normal file
6
docker/frpc.sh
Normal file
@ -0,0 +1,6 @@
|
||||
sed -i "s|%FRPC_SERVER_ADDR%|${FRPC_SERVER_ADDR}|" /etc/frpc.ini && \
|
||||
sed -i "s|%FRPC_SERVER_PORT%|${FRPC_SERVER_PORT}|" /etc/frpc.ini && \
|
||||
sed -i "s|%FRPC_REMOTE_PORT%|${FRPC_REMOTE_PORT}|" /etc/frpc.ini && \
|
||||
sed -i "s|%FRPC_TOKEN%|${FRPC_TOKEN}|" /etc/frpc.ini
|
||||
cat /etc/frpc.ini
|
||||
/usr/local/bin/frpc -c /etc/frpc.ini
|
@ -1,13 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
DOCKER_NAME=pikadev
|
||||
|
||||
docker rm $DOCKER_NAME -f
|
||||
|
||||
# 解析命令行参数
|
||||
while getopts ":p:s:t:r:" opt; do
|
||||
case $opt in
|
||||
p) frpc_port=$OPTARG;;
|
||||
p) frpc_server_port=$OPTARG;;
|
||||
s) frpc_server_addr=$OPTARG;;
|
||||
t) frpc_token=$OPTARG;;
|
||||
r) frpc_remote_port=$OPTARG;;
|
||||
@ -15,27 +11,33 @@ while getopts ":p:s:t:r:" opt; do
|
||||
esac
|
||||
done
|
||||
|
||||
# 检查是否设置了frpc_port参数
|
||||
if [ -n "$frpc_port" ]; then
|
||||
DOCKER_NAME="pikadev"
|
||||
if [ -n "$frpc_remote_port" ]; then
|
||||
DOCKER_NAME+="_$frpc_remote_port"
|
||||
fi
|
||||
|
||||
# 检查是否设置了frpc_server_port参数
|
||||
if [ -n "$frpc_server_port" ]; then
|
||||
# 启动frpc
|
||||
echo "Starting frpc..."
|
||||
docker run -d --name $DOCKER_NAME \
|
||||
docker rm $DOCKER_NAME -f
|
||||
docker run -it --name $DOCKER_NAME \
|
||||
--restart always \
|
||||
-w /root/pikascript \
|
||||
-e FRPC_REMOTE_PORT=$frpc_remote_port \
|
||||
-e FRPC_SERVER_ADDR=$frpc_server_addr \
|
||||
-e FRPC_SERVER_PORT=$frpc_server_port \
|
||||
-e FRPC_TOKEN=$frpc_token \
|
||||
$DOCKER_NAME \
|
||||
/usr/local/bin/frpc -c /etc/frpc.ini
|
||||
pikadev \
|
||||
bash /etc/frpc.sh
|
||||
echo "frpc started."
|
||||
else
|
||||
# 不启动frpc
|
||||
echo "frpc_port is not set. Skipping frpc startup."
|
||||
echo "frpc_server_port is not set. Skipping frpc startup."
|
||||
docker rm $DOCKER_NAME -f
|
||||
docker run -it --name $DOCKER_NAME \
|
||||
--restart always \
|
||||
-w /root/pikascript \
|
||||
$DOCKER_NAME \
|
||||
pikadev \
|
||||
bash
|
||||
fi
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user