diff --git a/.github/contatto.service b/.github/contatto.service new file mode 100644 index 0000000..72660f3 --- /dev/null +++ b/.github/contatto.service @@ -0,0 +1,12 @@ +[Unit] +Description=Contatto proxy server +After=network.target + +[Service] +Type=simple +ExecStart=/bin/contatto -f /etc/contatto.toml +Restart=on-failure +RestartSec=1min + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 34b443a..f244759 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -19,23 +19,25 @@ jobs: - uses: actions/checkout@v4 - name: build matrix run: | - mkdir -p etc + mkdir -p etc/systemd/system mv conf/contatto.toml etc/contatto.toml + mv .github/contatto.service etc/systemd/system/contatto.service + file_list=(bin/contatto etc/contatto.toml etc/systemd/system/contatto.service) make build GO='GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go' - tar czvf contatto-linux-amd64.tar.gz ./bin/ ./etc/contatto.toml + tar czvf contatto-linux-amd64.tar.gz ${file_list[*]} make clean make build GO='GOOS=linux GOARCH=arm CGO_ENABLED=0 go' - tar czvf contatto-linux-arm.tar.gz ./bin/ ./etc/contatto.toml + tar czvf contatto-linux-arm.tar.gz ${file_list[*]} make clean make build GO='GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go' - tar czvf contatto-linux-arm64.tar.gz ./bin/ ./etc/contatto.toml + tar czvf contatto-linux-arm64.tar.gz ${file_list[*]} make clean make build GO='GOOS=linux GOARCH=mips CGO_ENABLED=0 go' - tar czvf contatto-linux-mips.tar.gz ./bin/ ./etc/contatto.toml + tar czvf contatto-linux-mips.tar.gz ${file_list[*]} make clean make build GO='GOOS=linux GOARCH=mipsle CGO_ENABLED=0 go' - tar czvf contatto-linux-mipsle.tar.gz ./bin/ ./etc/contatto.toml + tar czvf contatto-linux-mipsle.tar.gz ${file_list[*]} make clean - uses: ncipollo/release-action@v1 diff --git a/Makefile b/Makefile index 4503760..ac6bb98 100644 --- a/Makefile +++ b/Makefile @@ -9,8 +9,8 @@ test: build: test ${GO} build -trimpath -ldflags "\ - -X main.version=$(shell git describe --tags --always) \ - -X main.date=$(shell date +%Y-%m-%d)" \ + -X github.com/wweir/contatto/conf.Version=$(shell git describe --tags --always) \ + -X github.com/wweir/contatto/conf.Date=$(shell date +%Y-%m-%d)" \ -o bin/contatto . run: build ./bin/contatto proxy --debug -c contatto.toml diff --git a/conf/config.go b/conf/config.go index 1db9e9a..2c84269 100644 --- a/conf/config.go +++ b/conf/config.go @@ -15,7 +15,7 @@ import ( "gopkg.in/yaml.v3" ) -var Branch, Version, Date string +var Version, Date string type Config struct { Addr string @@ -63,7 +63,7 @@ func ReadConfig(file string) (*Config, error) { return nil, fmt.Errorf("mapstructure config: %w", err) } - slog.Info("Starting with config", "branch", Branch, "version", Version, "date", Date, "config", c) + slog.Info("Starting with config", "version", Version, "date", Date, "config", c) for host, registry := range c.Registry { if registry.registry == "" { diff --git a/main.go b/main.go index 6fd2682..fb346fb 100644 --- a/main.go +++ b/main.go @@ -13,10 +13,10 @@ import ( var cli struct { Config string `short:"c" required:"" default:"/etc/contatto.toml"` - Debug bool `help:"debug mode"` + Debug bool `help:"Enable debug logging"` Install *InstallCmd `cmd:"" help:"install contatto"` - Proxy *ProxyCmd `cmd:"" help:"run as registry proxy"` + Proxy *ProxyCmd `cmd:"" help:"Execute Contatto as a registry proxy."` } func main() { @@ -27,7 +27,8 @@ func main() { ctx := kong.Parse(&cli, kong.UsageOnError(), - kong.Description(fmt.Sprintf(`Contatto %s (%s %s)`, conf.Version, conf.Branch, conf.Date)), + kong.Description(fmt.Sprintf( + `Contatto %s(%s) is a container registry transparent proxy.`, conf.Version, conf.Date)), ) config, err := conf.ReadConfig(cli.Config)