代码修改
git checkout v0.4.15
修改代码后提交。
镜像构建
export GOOS=linux
export GOARCH=amd64
export GOMAXPROCS=8go build -ldflags="-s -w -X 'github.com/zhenghaoz/gorse/cmd/version.Version=$(git describe --tags $(git rev-parse HEAD))' -X 'github.com/zhenghaoz/gorse/cmd/version.GitCommit=$(git rev-parse HEAD)' -X 'github.com/zhenghaoz/gorse/cmd/version.BuildTime=$(date)'" -o gorse-server main.go
# 使用官方的 Alpine 镜像作为基础镜像
FROM alpine:3.14# 下载本地的 gorse-server 可执行文件
COPY ./gorse-server /usr/bin/gorse-server# 设置适当的权限
RUN chmod +x /usr/bin/gorse-server
ENV USER=root
ENTRYPOINT ["/usr/bin/gorse-server"]
拷贝编译好的可执行文件到服务器的目录。与Dockerfile 同级
构建本地镜像
docker build -t rse-server .
修改compose
version: "3"
services:worker:image: zhenghaoz/gorse-workercontainer_name: gorse-workerrestart: unless-stoppedports:- 8089:8089 # Prometheus metrics export port.command: >--master-host master --master-port 8086--http-host 0.0.0.0 --http-port 8089--log-path /var/log/gorse/worker.log--jobs 32--cache-path /var/lib/gorse/worker_cache.datavolumes:- /root/gorse/logs:/var/log/gorse # Mount log files in volume.- /tmp/gorse-worker:/var/lib/gorse # Mount cache files in volume.depends_on:- masterserver:image: zhenghaoz/gorse-servercontainer_name: gorse-serverrestart: unless-stoppedports:- 8087:8087 # RESTful APIs and Prometheus metrics export port.command: >--master-host master --master-port 8086--http-host 0.0.0.0 --http-port 8087--log-path /var/log/gorse/server.log--cache-path /var/lib/gorse/server_cache.datavolumes:- /root/gorse/logs:/var/log/gorse # Mount log files in volume.- /tmp/gorse-server:/var/lib/gorse # Mount cache files in volume.depends_on:- mastermyserver:image: rse-servercontainer_name: rse-serverrestart: unless-stoppedports:- 8097:8087 # RESTful APIs and Prometheus metrics export port.command: >--master-host master --master-port 8086--http-host 0.0.0.0 --http-port 8087--log-path /var/log/gorse/myserver.log--cache-path /var/lib/gorse/myserver_cache.datavolumes:- /root/gorse/logs:/var/log/gorse # Mount log files in volume.- /tmp/gorse-myserver:/var/lib/gorse # Mount cache files in volume.depends_on:- mastermaster:image: zhenghaoz/gorse-mastercontainer_name: gorse-masterrestart: unless-stoppedports:- 8086:8086 # HTTP port- 8088:8088 # gRPC portcommand: >-c /etc/gorse/config.toml--log-path /var/log/gorse/master.log--cache-path /var/lib/gorse/master_cache.datavolumes:# Mount the configuration file.- ./config.toml:/etc/gorse/config.toml# Mount log files in volume.- /root/gorse/logs:/var/log/gorse # Mount log files in volume.# Mount cache files in volume.- /tmp/gorse-master:/var/lib/gorsevolumes:worker_data:server_data:master_data:gorse_log:
启动自定义服务
docker compose up myserver -d
至此 添加一下白名单,端口,就可以联通了。