mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-19 20:32:35 +02:00
added some docker compose examples; fixed defaults to wrong host; updated watcher behavior to retry connection every 3 secs until success or until cancelled
This commit is contained in:
parent
6388d9d44d
commit
a11ce46028
8 changed files with 119 additions and 15 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -1,7 +1,7 @@
|
|||
compose.yml
|
||||
|
||||
config/
|
||||
certs/
|
||||
config*/
|
||||
certs*/
|
||||
bin/
|
||||
|
||||
templates/codemirror/
|
||||
|
@ -13,6 +13,6 @@ log/
|
|||
|
||||
go.work.sum
|
||||
|
||||
!src/config/
|
||||
!src/**/
|
||||
|
||||
todo.md
|
|
@ -54,7 +54,9 @@ A lightweight, easy-to-use, and [performant](docs/benchmark_result.md) reverse p
|
|||
|
||||
2. Setup `go-proxy` [See here](docs/docker.md)
|
||||
|
||||
3. Configure `go-proxy`
|
||||
3. Setup `docker-socket-proxy` (see [example](docs/docker_socket_proxy.md) other machine that is running docker (if any)
|
||||
|
||||
4. Configure `go-proxy`
|
||||
- with text editor (e.g. Visual Studio Code)
|
||||
- or with web config editor via `http://gp.y.z`
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@
|
|||
| `proxy.stop_timeout` | time to wait for stop command | `10s` | `number[unit]...` |
|
||||
| `proxy.stop_signal` | signal sent to container for `stop` and `kill` methods | docker's default | `SIGINT`, `SIGTERM`, `SIGHUP`, `SIGQUIT` and those without **SIG** prefix |
|
||||
| `proxy.<alias>.<field>` | set field for specific alias | N/A | N/A |
|
||||
| `proxy.$<index>.<field>` | set field for specific alias at index (starting from **1**) | N/A | N/A |
|
||||
| `proxy.$<index>.<field>` | set field for specific alias at index (starting from **1**) | N/A | N/A |
|
||||
| `proxy.*.<field>` | set field for all aliases | N/A | N/A |
|
||||
|
||||
### Fields
|
||||
|
@ -215,6 +215,8 @@ service_a:
|
|||
|
||||
## Docker compose examples
|
||||
|
||||
More examples in [here](examples/)
|
||||
|
||||
```yaml
|
||||
volumes:
|
||||
adg-work:
|
||||
|
|
59
docs/docker_socket_proxy.md
Normal file
59
docs/docker_socket_proxy.md
Normal file
|
@ -0,0 +1,59 @@
|
|||
## Docker Socket Proxy
|
||||
|
||||
For docker client on other machine, set this up, then add `name: tcp://<machine_ip>:2375` to `config.yml` under `docker` section
|
||||
|
||||
```yml
|
||||
# compose.yml on remote machine (e.g. server1)
|
||||
services:
|
||||
docker-proxy:
|
||||
container_name: docker-proxy
|
||||
image: ghcr.io/linuxserver/socket-proxy
|
||||
environment:
|
||||
- ALLOW_START=1 #optional
|
||||
- ALLOW_STOP=1 #optional
|
||||
- ALLOW_RESTARTS=0 #optional
|
||||
- AUTH=0 #optional
|
||||
- BUILD=0 #optional
|
||||
- COMMIT=0 #optional
|
||||
- CONFIGS=0 #optional
|
||||
- CONTAINERS=1 #optional
|
||||
- DISABLE_IPV6=1 #optional
|
||||
- DISTRIBUTION=0 #optional
|
||||
- EVENTS=1 #optional
|
||||
- EXEC=0 #optional
|
||||
- IMAGES=0 #optional
|
||||
- INFO=0 #optional
|
||||
- NETWORKS=0 #optional
|
||||
- NODES=0 #optional
|
||||
- PING=1 #optional
|
||||
- POST=1 #optional
|
||||
- PLUGINS=0 #optional
|
||||
- SECRETS=0 #optional
|
||||
- SERVICES=0 #optional
|
||||
- SESSION=0 #optional
|
||||
- SWARM=0 #optional
|
||||
- SYSTEM=0 #optional
|
||||
- TASKS=0 #optional
|
||||
- VERSION=1 #optional
|
||||
- VOLUMES=0 #optional
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
restart: always
|
||||
tmpfs:
|
||||
- /run
|
||||
ports:
|
||||
- 2375:2375
|
||||
```
|
||||
|
||||
```yml
|
||||
# config.yml on go-proxy machine
|
||||
autocert:
|
||||
... # your config
|
||||
|
||||
providers:
|
||||
include:
|
||||
...
|
||||
docker:
|
||||
...
|
||||
server1: tcp://<machine_ip>:2375
|
||||
```
|
16
examples/microbin.yml
Normal file
16
examples/microbin.yml
Normal file
|
@ -0,0 +1,16 @@
|
|||
services:
|
||||
app:
|
||||
container_name: microbin
|
||||
cpu_shares: 10
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
memory: 256M
|
||||
env_file: .env
|
||||
image: docker.i.sh/danielszabo99/microbin:latest
|
||||
ports:
|
||||
- 8080
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./data:/app/microbin_data
|
||||
# microbin.domain.tld
|
16
examples/siyuan.yml
Normal file
16
examples/siyuan.yml
Normal file
|
@ -0,0 +1,16 @@
|
|||
services:
|
||||
main:
|
||||
image: b3log/siyuan:v3.1.0
|
||||
container_name: siyuan
|
||||
command:
|
||||
- --workspace=/siyuan/workspace/
|
||||
- --accessAuthCode=<some password>
|
||||
user: 1000:1000
|
||||
volumes:
|
||||
- ./workspace:/siyuan/workspace
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- TZ=Asia/Hong_Kong
|
||||
ports:
|
||||
- 6806
|
||||
# siyuan.domain.tld
|
|
@ -21,9 +21,8 @@ type Client struct {
|
|||
}
|
||||
|
||||
func ParseDockerHostname(host string) (string, E.NestedError) {
|
||||
if host == common.DockerHostFromEnv {
|
||||
return host, nil
|
||||
} else if host == "" {
|
||||
switch host {
|
||||
case common.DockerHostFromEnv, "":
|
||||
return "localhost", nil
|
||||
}
|
||||
url, err := E.Check(client.ParseHostURL(host))
|
||||
|
|
|
@ -2,6 +2,7 @@ package watcher
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
docker_events "github.com/docker/docker/api/types/events"
|
||||
|
@ -59,19 +60,28 @@ func (w DockerWatcher) EventsWithOptions(ctx context.Context, options DockerList
|
|||
defer close(eventCh)
|
||||
defer close(errCh)
|
||||
|
||||
defer func() {
|
||||
if w.client.Connected() {
|
||||
w.client.Close()
|
||||
}
|
||||
}()
|
||||
|
||||
if !w.client.Connected() {
|
||||
var err E.NestedError
|
||||
for range 3 {
|
||||
for {
|
||||
w.client, err = D.ConnectClient(w.host)
|
||||
attempts := 0
|
||||
if err != nil {
|
||||
defer w.client.Close()
|
||||
break
|
||||
}
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
if err.HasError() {
|
||||
errCh <- E.FailWith("docker connection", err)
|
||||
return
|
||||
attempts++
|
||||
errCh <- E.FailWith(fmt.Sprintf("docker connection attempt #%d", attempts), err)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
default:
|
||||
time.Sleep(3 * time.Second)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue