feat: add docker-build for gtund

This commit is contained in:
ICKelin
2024-04-05 22:14:14 +08:00
parent 7600c87eeb
commit e7f46b03fc
15 changed files with 72 additions and 3 deletions

3
.gitignore vendored
View File

@@ -13,4 +13,5 @@ research
docker-build/gtun/gtun*
docker-build/gtund/gtund
release
release
images

View File

@@ -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

View 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

View 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

View 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

View 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

View 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

View 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
View 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/

View File

@@ -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) {