diff --git a/Dockerfile b/Dockerfile index 944fffdd5eca72db44a4b9968666da70a1cc4fa8..462af4d71f0d5dac4a1812ae6defae6d99cc28fe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,4 +3,6 @@ FROM golang:1.6 ADD . /go/src/github.com/nsheridan/cashier RUN go install github.com/nsheridan/cashier/cmd/cashierd +ONBUILD COPY . /cashier +WORKDIR /cashier ENTRYPOINT /go/bin/cashierd diff --git a/README.md b/README.md index 512e2987990f05de392526ecdab2c0fe600afef6..e62df2542b807a78d77f918384730d34c0c81cb0 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,13 @@ go get github.com/cashier/cmd/... 2. Create a signing key with `ssh-keygen` and a [config.json](exampleconfig.json) 3. Run the cashier server with `cashierd` and the cli with `cashier`. +## Using docker +1. Create a signing key with `ssh-keygen` and a [config.json](exampleconfig.json) +2. Run +``` +docker run -it --rm -p 10000:10000 --name cashier -v $(pwd):/cashier nsheridan/cashier +``` + # Configuration Configuration is divided into three sections: `server`, `auth`, and `ssh`. diff --git a/cmd/cashierd/main.go b/cmd/cashierd/main.go index bc460da5b1e625dfa9f530aba4151611d7349e90..e482ddec394f1af54c1de761df22038e7fe69db3 100644 --- a/cmd/cashierd/main.go +++ b/cmd/cashierd/main.go @@ -13,6 +13,7 @@ import ( "log" "net/http" "os" + "path" "strings" "time" @@ -221,7 +222,7 @@ func main() { ctx := &appContext{ cookiestore: sessions.NewCookieStore([]byte(config.Server.CookieSecret)), authprovider: authprovider, - views: template.Must(template.ParseGlob("templates/*")), + views: template.Must(template.ParseGlob(path.Join(config.Server.TemplateDir, "*"))), sshKeySigner: signer, } ctx.cookiestore.Options = &sessions.Options{ diff --git a/exampleconfig.json b/exampleconfig.json index 683304e155564afdc95ea212ec78fefcaa238c5d..eeb1453a692d74bd7d6bb7ebffe2106b30a127f8 100644 --- a/exampleconfig.json +++ b/exampleconfig.json @@ -4,7 +4,8 @@ "tls_key": "server.key", "tls_cert": "server.crt", "port": 443, - "cookie_secret": "supersecret" + "cookie_secret": "supersecret", + "template_dir": "/go/src/github.com/nsheridan/cashier/templates" }, "auth": { "provider": "google", diff --git a/server/config/config.go b/server/config/config.go index 7598f0a909daf7e7861dc50406a3d2bc04601428..8922ff63396a04a7c3d2f307607021f3092ef181 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -20,6 +20,7 @@ type Server struct { TLSCert string `mapstructure:"tls_cert"` Port int `mapstructure:"port"` CookieSecret string `mapstructure:"cookie_secret"` + TemplateDir string `mapstructure:"template_dir"` } // Auth holds the configuration specific to the OAuth provider. diff --git a/server/config/config_test.go b/server/config/config_test.go index 6baf76d2a5f699e5a4b99d3fc75d8f06f390c056..e528e7debf1a09a76cb1eed257cf4a5cd8d4660b 100644 --- a/server/config/config_test.go +++ b/server/config/config_test.go @@ -22,6 +22,7 @@ func TestServerConfig(t *testing.T) { a.Equal(server.TLSCert, "server.crt") a.Equal(server.Port, 443) a.Equal(server.CookieSecret, "supersecret") + a.Equal(server.TemplateDir, "templates") } func TestAuthConfig(t *testing.T) { diff --git a/testdata/config.go b/testdata/config.go index bb2f5111dd88a44ffc89c98ddb8f6b60111d9213..a64ebd55218d659d8bc37ba17145ca585b42236c 100644 --- a/testdata/config.go +++ b/testdata/config.go @@ -6,7 +6,8 @@ var ServerConfig = []byte(`{ "tls_key": "server.key", "tls_cert": "server.crt", "port": 443, - "cookie_secret": "supersecret" + "cookie_secret": "supersecret", + "template_dir": "templates" } }`)