build: one image, nginx in front of the backend on loopback (closes #52)
check / check (push) Successful in 48s
check / check (push) Successful in 48s
The root Dockerfile builds the only image; Dockerfile.backend is gone. Its stages: lint, a Go stage that runs the tests and builds netwatch-server, the node stage, and an nginx runtime. nginx serves dist/ on 8080 and proxies /api/ and /.well-known/healthcheck to the backend on 127.0.0.1:8081. bin/entrypoint.sh starts both, turns TERM or INT into a stop of both, and exits non-zero when either exits on its own. The backend runs as user netwatch and keeps reports on the /data volume. New setting BIND_ADDRESS (empty: every interface). STOPSIGNAL is SIGTERM, since the nginx image's SIGQUIT would miss the entrypoint. script/docker is the org model verbatim. Model: opus-5-5
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package server_test
|
||||
|
||||
import "testing"
|
||||
|
||||
// TestListenAddress checks that the server listens on BIND_ADDRESS
|
||||
// and PORT, and on port 8080 on every interface when neither is set.
|
||||
// The container image sets both, to keep the backend on loopback
|
||||
// behind nginx.
|
||||
func TestListenAddress(t *testing.T) {
|
||||
tests := []struct {
|
||||
bindAddress string
|
||||
port string
|
||||
want string
|
||||
}{
|
||||
{bindAddress: "", port: "", want: ":8080"},
|
||||
{bindAddress: "127.0.0.1", port: "8081", want: "127.0.0.1:8081"},
|
||||
{bindAddress: "::1", port: "8081", want: "[::1]:8081"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.want, func(t *testing.T) {
|
||||
// t.Setenv rules out t.Parallel.
|
||||
t.Setenv("BIND_ADDRESS", tt.bindAddress)
|
||||
t.Setenv("PORT", tt.port)
|
||||
|
||||
got := newServer(t).ListenAddr()
|
||||
if got != tt.want {
|
||||
t.Errorf("listen address = %q, want %q", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user