Skip to content

Commit

Permalink
fix: docker
Browse files Browse the repository at this point in the history
  • Loading branch information
nitezs committed Mar 18, 2024
1 parent 3feeb66 commit c486fe6
Show file tree
Hide file tree
Showing 11 changed files with 1,100 additions and 16 deletions.
11 changes: 9 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ builds:
flags:
- -trimpath
no_unique_dist_dir: true
binary: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}"
archives:
- format: binary
- format: tar.gz
format_overrides:
- format: zip
goos: windows
wrap_in_directory: true
files:
- LICENSE
- README.md
- templates
12 changes: 10 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ ARG version

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X sub2clash/config.Version=${version}" -o sub2sing-box main.go

WORKDIR /app

FROM alpine:latest

COPY --from=builder /app/sub2sing-box /app/sub2sing-box
COPY --from=builder /app/template /app/template
COPY --from=builder /app/templates /app/templates-origin
COPY --from=builder /app/entrypoint.sh /app/entrypoint.sh

RUN chmod +x /app/entrypoint.sh

VOLUME [ "/app/templates" ]
EXPOSE 8080

ENTRYPOINT ["/app/sub2sing-box","server"]
ENTRYPOINT ["/app/entrypoint.sh"]
File renamed without changes.
7 changes: 4 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
version: "3.8"
services:
sub2sing-box:
image: nite07/sub2sing-box:latest
image: nite07/sub2sing-box:dev # nite07/sub2sing-box:latest
container_name: sub2sing-box
volumes:
- ./template:/app/template
- ./templates:/app/templates
ports:
- 8080:8080
- 8080:8080
8 changes: 8 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
if [ ! -d "/app/templates" ]; then
mkdir /app/templates
fi
if [ -z "$(ls -A /app/templates)" ]; then
cp -r /app/templates-origin/* /app/templates
fi
/app/sub2sing-box server
1,044 changes: 1,044 additions & 0 deletions internal/model/country_code_map.go

Large diffs are not rendered by default.

34 changes: 25 additions & 9 deletions pkg/util/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,18 @@ func MergeTemplate(proxies []model.Proxy, template string) (string, error) {
return "", err
}
for i, outbound := range config.Outbounds {
if outbound.Type == "urltest" || outbound.Type == "selector" {
var parsedOutbound []string = make([]string, 0)
for _, o := range outbound.Outbounds {
if o == "<all-proxy-tags>" {
parsedOutbound = append(parsedOutbound, proxyTags...)
} else {
parsedOutbound = append(parsedOutbound, o)
}
var parsedOutbound []string = make([]string, 0)
for _, o := range outbound.Outbounds {
if o == "<all-proxy-tags>" {
parsedOutbound = append(parsedOutbound, proxyTags...)
} else {
parsedOutbound = append(parsedOutbound, o)
}
config.Outbounds[i].Outbounds = parsedOutbound
}
config.Outbounds[i].Outbounds = parsedOutbound
}
config.Outbounds = append(config.Outbounds, newOutbounds...)
//TODO: 国家策略组
data, err := json.Marshal(config)
if err != nil {
return "", err
Expand Down Expand Up @@ -257,3 +256,20 @@ func RenameProxy(proxies []model.Proxy, regex string, replaceText string) ([]mod
}
return proxies, nil
}

func GetContryName(proxyName string) string {
countryMaps := []map[string]string{
model.CountryFlag,
model.CountryChineseName,
model.CountryISO,
model.CountryEnglishName,
}
for _, countryMap := range countryMaps {
for k, v := range countryMap {
if strings.Contains(proxyName, k) {
return v
}
}
}
return "其他地区"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit c486fe6

Please sign in to comment.