fix(binary): persist CSRF auth file in a volume (#22)
* fix(binary): persist CSRF auth file in a volume * docs(options): document the `-data` optionpull/25/head
parent
aa3fda6de9
commit
5d0af27a3f
|
@ -2,5 +2,7 @@ FROM scratch
|
|||
|
||||
COPY dist /
|
||||
|
||||
VOLUME /data
|
||||
|
||||
EXPOSE 9000
|
||||
ENTRYPOINT ["/ui-for-docker"]
|
||||
|
|
|
@ -76,6 +76,7 @@ The following options are available for the `ui-for-docker` binary:
|
|||
|
||||
* `-endpoint`, `-e`: Docker deamon endpoint (default: *"/var/run/docker.sock"*)
|
||||
* `-bind`, `-p`: Address and port to serve UI For Docker (default: *":9000"*)
|
||||
* `-data`, `-d`: Path to the data folder (default: *"."*)
|
||||
* `-assets`, `-a`: Path to the assets (default: *"."*)
|
||||
* `-swarm`, `-s`: Swarm cluster support (default: *false*)
|
||||
* `-hide-label`, `-l`: Hide containers with a specific label in the UI
|
||||
|
|
10
dockerui.go
10
dockerui.go
|
@ -21,6 +21,7 @@ var (
|
|||
endpoint = kingpin.Flag("endpoint", "Dockerd endpoint").Default("/var/run/docker.sock").Short('e').String()
|
||||
addr = kingpin.Flag("bind", "Address and port to serve UI For Docker").Default(":9000").Short('p').String()
|
||||
assets = kingpin.Flag("assets", "Path to the assets").Default(".").Short('a').String()
|
||||
data = kingpin.Flag("data", "Path to the data").Default(".").Short('d').String()
|
||||
swarm = kingpin.Flag("swarm", "Swarm cluster support").Default("false").Short('s').Bool()
|
||||
labels = LabelParser(kingpin.Flag("hide-label", "Hide containers with a specific label in the UI").Short('l'))
|
||||
authKey []byte
|
||||
|
@ -117,7 +118,7 @@ func createUnixHandler(e string) http.Handler {
|
|||
return &UnixHandler{e}
|
||||
}
|
||||
|
||||
func createHandler(dir string, e string, c Config) http.Handler {
|
||||
func createHandler(dir string, d string, e string, c Config) http.Handler {
|
||||
var (
|
||||
mux = http.NewServeMux()
|
||||
fileHandler = http.FileServer(http.Dir(dir))
|
||||
|
@ -137,11 +138,12 @@ func createHandler(dir string, e string, c Config) http.Handler {
|
|||
}
|
||||
|
||||
// Use existing csrf authKey if present or generate a new one.
|
||||
dat, err := ioutil.ReadFile(authKeyFile)
|
||||
var authKeyPath = d + "/" + authKeyFile
|
||||
dat, err := ioutil.ReadFile(authKeyPath)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
authKey = securecookie.GenerateRandomKey(32)
|
||||
err := ioutil.WriteFile(authKeyFile, authKey, 0644)
|
||||
err := ioutil.WriteFile(authKeyPath, authKey, 0644)
|
||||
if err != nil {
|
||||
fmt.Println("unable to persist auth key", err)
|
||||
}
|
||||
|
@ -179,7 +181,7 @@ func main() {
|
|||
HiddenLabels: *labels,
|
||||
}
|
||||
|
||||
handler := createHandler(*assets, *endpoint, configuration)
|
||||
handler := createHandler(*assets, *data, *endpoint, configuration)
|
||||
if err := http.ListenAndServe(*addr, handler); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -260,14 +260,14 @@ module.exports = function (grunt) {
|
|||
command: [
|
||||
'docker stop ui-for-docker',
|
||||
'docker rm ui-for-docker',
|
||||
'docker run --privileged -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock --name ui-for-docker ui-for-docker'
|
||||
'docker run --privileged -d -p 9000:9000 -v /tmp/docker-ui:/data -v /var/run/docker.sock:/var/run/docker.sock --name ui-for-docker ui-for-docker -d /data'
|
||||
].join(';')
|
||||
},
|
||||
runSwarm: {
|
||||
command: [
|
||||
'docker stop ui-for-docker',
|
||||
'docker rm ui-for-docker',
|
||||
'docker run --privileged -d -p 9000:9000 --name ui-for-docker ui-for-docker -e http://10.0.7.10:4000 -swarm'
|
||||
'docker run --privileged -d -p 9000:9000 -v /tmp/docker-ui:/data --name ui-for-docker ui-for-docker -e http://10.0.7.10:4000 -swarm -d /data'
|
||||
].join(';')
|
||||
},
|
||||
cleanImages: {
|
||||
|
|
Loading…
Reference in New Issue