From d7d77fd1c9035ec6356abb57a5486f0a13029628 Mon Sep 17 00:00:00 2001 From: Mike Crute Date: Mon, 31 Jul 2023 15:46:25 -0700 Subject: Make docker build work --- Dockerfile | 11 +++++++++++ Makefile | 6 +++--- cmd/web/server.go | 4 ++-- main.go | 8 +++++++- 4 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d817d70 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM alpine:latest +LABEL maintainer="Mike Crute " + +ENV TZ America/Los_Angeles + +RUN set -euxo pipefail; \ + apk --no-cache add tzdata; + +ADD ssh-proxy /ssh-proxy + +CMD ["/ssh-proxy", "web"] diff --git a/Makefile b/Makefile index cc3fc5f..6baad7f 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ IMAGE=docker.crute.me/ssh-proxy BINARY=ssh-proxy CLIENT_BINARY=ssh-proxy-client -$(BINARY): $(CLIENT_BINARY) $(shell find . -name '*.go') +$(BINARY): $(CLIENT_BINARY) $(shell find . -name '*.go' -o -name '*.tpl' -o -name '*.js') @[ "$(CLIENT_ID)" ] || ( echo "CLIENT_ID must be set"; exit 1 ) CGO_ENABLED=0 go build \ @@ -26,7 +26,7 @@ vet: main.go .PHONY: docker docker: $(BINARY) - mkdir docker; cp Dockerfile web-server docker; cd docker; \ + mkdir docker; cp Dockerfile $(BINARY) docker; cd docker; \ docker pull $(shell grep '^FROM ' Dockerfile | cut -d' ' -f2); \ docker build --no-cache -t $(IMAGE):stage . @@ -58,6 +58,6 @@ run-web: clean $(BINARY) test -n "$(VAULT_SECRET_ID)" # Caller must also export VAULT_SECRET_ID VAULT_ADDR="https://vault.sea4.crute.me:8200" \ VAULT_SKIP_VERIFY=true \ - ./$(BINARY) --debug \ + ./$(BINARY) \ --hostname=dev.ssh-proxy.crute.me \ web diff --git a/cmd/web/server.go b/cmd/web/server.go index 62624e2..83f4fc8 100644 --- a/cmd/web/server.go +++ b/cmd/web/server.go @@ -148,7 +148,7 @@ func webMain(cfg app.Config, embeddedTemplates, embeddedClients fs.FS, appVersio RPDisplayName: cfg.OauthRPName, RPID: cfg.Hostnames[0], RPOrigins: []string{ - fmt.Sprintf("https://%s:8070", cfg.Hostnames[0]), // TODO: Expose port in echo server for use here + fmt.Sprintf("https://%s", cfg.Hostnames[0]), // TODO: Expose port in echo server for use here }, }) if err != nil { @@ -176,7 +176,7 @@ func webMain(cfg app.Config, embeddedTemplates, embeddedClients fs.FS, appVersio Logger: s.Logger, AuthSessions: authSessionStore, OauthClients: oauthClientStore, - Hostname: fmt.Sprintf("https://%s:8070", cfg.Hostnames[0]), // TODO + Hostname: fmt.Sprintf("https://%s", cfg.Hostnames[0]), // TODO PollSeconds: cfg.OauthDevicePollSecs, SessionExpiration: cfg.OauthSessionTimeout, } diff --git a/main.go b/main.go index 7cc3e90..a9c084d 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ package main import ( "embed" + "io/fs" "log" "code.crute.us/mcrute/ssh-proxy/app" @@ -35,7 +36,12 @@ func main() { } cli.AddFlags(rootCmd, &app.Config{}, app.DefaultConfig, "") - web.Register(rootCmd, embeddedTemplates, embeddedClients, appVersion) + templates, err := fs.Sub(embeddedTemplates, "templates") + if err != nil { + log.Fatalf("Error building sub-fs of embeded fs") + } + + web.Register(rootCmd, templates, embeddedClients, appVersion) client.Register(rootCmd) register.Register(rootCmd) -- cgit v1.2.3