mirror of
https://github.com/ICKelin/gtun.git
synced 2025-09-26 19:11:15 +08:00
feat: add docker-build for gtund
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -13,4 +13,5 @@ research
|
||||
|
||||
docker-build/gtun/gtun*
|
||||
docker-build/gtund/gtund
|
||||
release
|
||||
release
|
||||
images
|
2
build.sh
2
build.sh
@@ -13,7 +13,7 @@ cp scripts/install_gtun.sh release/gtun/install.sh
|
||||
cp -r etc/gtun/* release/gtun/etc
|
||||
|
||||
cd src/gtund
|
||||
GOOS=linux go build -o gtund
|
||||
GOOS=linux GOARCH=amd64 go build -o gtund
|
||||
mv gtund $DIR/release/gtund/
|
||||
cd $DIR
|
||||
cp scripts/install_gtund.sh release/gtund/install.sh
|
||||
|
6
docker-build/gtun/Dockerfile
Normal file
6
docker-build/gtun/Dockerfile
Normal file
@@ -0,0 +1,6 @@
|
||||
FROM ubuntu:20.04
|
||||
RUN mkdir -p /opt/apps/gtun/logs
|
||||
COPY . /opt/apps/gtun
|
||||
COPY start.sh /
|
||||
RUN chmod +x start.sh && chmod +x /opt/apps/gtun/gtun
|
||||
CMD /start.sh
|
12
docker-build/gtun/docker-compose.yaml
Normal file
12
docker-build/gtun/docker-compose.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
version: '3'
|
||||
services:
|
||||
accelerator:
|
||||
build: .
|
||||
container_name: gtun
|
||||
restart: always
|
||||
network_mode: host
|
||||
privileged: true
|
||||
volumes:
|
||||
- /opt/apps/gtun/logs:/opt/apps/gtun/logs
|
||||
environment:
|
||||
TIME_ZONE: Asia/Shanghai
|
6
docker-build/gtun/start.sh
Normal file
6
docker-build/gtun/start.sh
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
if [ "$TIME_ZONE" != "" ]; then
|
||||
ln -snf /usr/share/zoneinfo/$TIME_ZONE /etc/localtime && echo $TIME_ZONE > /etc/timezone
|
||||
fi
|
||||
|
||||
/opt/apps/gtun/gtun -c /opt/apps/gtun/etc/gtun.yaml
|
6
docker-build/gtund/Dockerfile
Normal file
6
docker-build/gtund/Dockerfile
Normal file
@@ -0,0 +1,6 @@
|
||||
FROM ubuntu:20.04
|
||||
RUN mkdir -p /opt/apps/gtund/logs
|
||||
COPY . /opt/apps/gtund
|
||||
COPY start.sh /
|
||||
RUN chmod +x start.sh && chmod +x /opt/apps/gtund/gtund
|
||||
CMD /start.sh
|
12
docker-build/gtund/docker-compose.yaml
Normal file
12
docker-build/gtund/docker-compose.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
version: '3'
|
||||
services:
|
||||
accelerator:
|
||||
build: .
|
||||
container_name: gtund
|
||||
restart: always
|
||||
network_mode: host
|
||||
privileged: true
|
||||
volumes:
|
||||
- /opt/apps/gtund/logs:/opt/apps/gtund/logs
|
||||
environment:
|
||||
TIME_ZONE: Asia/Shanghai
|
6
docker-build/gtund/start.sh
Normal file
6
docker-build/gtund/start.sh
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
if [ "$TIME_ZONE" != "" ]; then
|
||||
ln -snf /usr/share/zoneinfo/$TIME_ZONE /etc/localtime && echo $TIME_ZONE > /etc/timezone
|
||||
fi
|
||||
|
||||
/opt/apps/gtund/gtund -c /opt/apps/gtund/etc/gtund.yaml
|
11
docker_build.sh
Executable file
11
docker_build.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
./build.sh
|
||||
|
||||
rm -r images
|
||||
|
||||
mkdir -p images/gtun
|
||||
cp -r release/gtun/* images/gtun/
|
||||
cp -r docker-build/gtun/* images/gtun/
|
||||
|
||||
mkdir -p images/gtund
|
||||
cp -r release/gtund/* images/gtund
|
||||
cp -r docker-build/gtund/* images/gtund/
|
@@ -7,6 +7,7 @@ import (
|
||||
)
|
||||
|
||||
var gConfig *Config
|
||||
var signatureKey = os.Getenv("GTUN_SIGNATURE")
|
||||
|
||||
type Config struct {
|
||||
RouteFile string `yaml:"route_file"`
|
||||
@@ -33,8 +34,16 @@ func Parse(path string) (*Config, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//lines := strings.Split(content, "\n")
|
||||
//if !strings.HasPrefix(lines[0], "SIGNATURE=") {
|
||||
// return nil, fmt.Errorf("signature error")
|
||||
//}
|
||||
//
|
||||
//signature := strings.Split(lines[0], "SIGNATURE=")[1]
|
||||
//
|
||||
//configContent := strings.Join(lines[1:], "\n")
|
||||
|
||||
return ParseBuffer(content)
|
||||
return ParseBuffer([]byte(content))
|
||||
}
|
||||
|
||||
func ParseBuffer(content []byte) (*Config, error) {
|
||||
|
Reference in New Issue
Block a user