Merge branch 'docker-volume-config-dir' of GBHC/cwtch into master

+ go list ./... | xargs go vet
# cwtch.im/cwtch/server
server/serverConfig.go:34: Println call has possible formatting directive %s
This commit is contained in:
Dan Ballard 2018-11-01 17:39:03 +00:00 committed by Gogs
commit bcc94c46e7
4 changed files with 8 additions and 6 deletions

View File

@ -57,7 +57,7 @@ COPY --from=tor-build-stage /usr/local/ /usr/local/
# Create an unprivileged tor user # Create an unprivileged tor user
#RUN addgroup -g 19001 -S $TOR_USER && adduser -u 19001 -G $TOR_USER -S $TOR_USER #RUN addgroup -g 19001 -S $TOR_USER && adduser -u 19001 -G $TOR_USER -S $TOR_USER
RUN addgroup -S $TOR_USER && adduser -G $TOR_USER -S $TOR_USER && adduser -G _tor -S cwtchd RUN addgroup -S $TOR_USER && adduser -G $TOR_USER -S $TOR_USER && adduser -G _tor -S cwtchd && mkdir /run/tor
# Copy Tor configuration file # Copy Tor configuration file
COPY ./server/docker/torrc /etc/tor/torrc COPY ./server/docker/torrc /etc/tor/torrc
@ -69,7 +69,7 @@ COPY ./server/docker/docker-entrypoint /usr/local/bin/
COPY --from=server-build-stage /go/src/cwtch.im/cwtch/server/app/app /usr/local/bin/cwtch_server COPY --from=server-build-stage /go/src/cwtch.im/cwtch/server/app/app /usr/local/bin/cwtch_server
# Persist data # Persist data
VOLUME /etc/tor /var/lib/tor VOLUME /etc/tor /var/lib/tor /etc/cwtch
ENTRYPOINT ["docker-entrypoint"] ENTRYPOINT ["docker-entrypoint"]

View File

@ -3,6 +3,7 @@ package main
import ( import (
cwtchserver "cwtch.im/cwtch/server" cwtchserver "cwtch.im/cwtch/server"
"log" "log"
"os"
) )
const ( const (
@ -10,7 +11,9 @@ const (
) )
func main() { func main() {
serverConfig := cwtchserver.LoadConfig(serverConfigFile) configDir := os.Getenv("CWTCH_CONFIG_DIR")
serverConfig := cwtchserver.LoadConfig(configDir + serverConfigFile)
server := new(cwtchserver.Server) server := new(cwtchserver.Server)
log.Printf("starting cwtch server...") log.Printf("starting cwtch server...")

View File

@ -6,7 +6,6 @@ chmod_files() { find $2 -type f -exec chmod -v $1 {} \;
chmod_dirs() { find $2 -type d -exec chmod -v $1 {} \; chmod_dirs() { find $2 -type d -exec chmod -v $1 {} \;
} }
mkdir /run/tor/
chown ${TOR_USER}:${TOR_USER} /run/tor/ chown ${TOR_USER}:${TOR_USER} /run/tor/
chmod 770 /run/tor chmod 770 /run/tor
@ -29,5 +28,3 @@ sleep 15
#Run cwtch (or whatever the user passed) #Run cwtch (or whatever the user passed)
exec "$@" exec "$@"
#$@ #$@

View File

@ -31,12 +31,14 @@ func (config *Config) Identity() identity.Identity {
// Save dumps the latest version of the config to a json file given by filename // Save dumps the latest version of the config to a json file given by filename
func (config *Config) Save(filename string) { func (config *Config) Save(filename string) {
log.Println("Saving config to %s", filename)
bytes, _ := json.MarshalIndent(config, "", "\t") bytes, _ := json.MarshalIndent(config, "", "\t")
ioutil.WriteFile(filename, bytes, 0600) ioutil.WriteFile(filename, bytes, 0600)
} }
// LoadConfig loads a Config from a json file specified by filename // LoadConfig loads a Config from a json file specified by filename
func LoadConfig(filename string) Config { func LoadConfig(filename string) Config {
log.Printf("Loading config from %s\n", filename)
config := Config{} config := Config{}
config.MaxBufferLines = 100000 config.MaxBufferLines = 100000
config.ServerReporting.LogMetricsToFile = false config.ServerReporting.LogMetricsToFile = false