Browse Source

Changes to resolve ticket #152

pull/153/head
parent
commit
04b2191238
  1. 4
      Dockerfile
  2. 5
      server/app/main.go
  3. 3
      server/docker/docker-entrypoint
  4. 2
      server/serverConfig.go

4
Dockerfile

@ -57,7 +57,7 @@ COPY --from=tor-build-stage /usr/local/ /usr/local/
# Create an unprivileged 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 ./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
# Persist data
VOLUME /etc/tor /var/lib/tor
VOLUME /etc/tor /var/lib/tor /etc/cwtch
ENTRYPOINT ["docker-entrypoint"]

5
server/app/main.go

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

3
server/docker/docker-entrypoint

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

2
server/serverConfig.go

@ -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
func (config *Config) Save(filename string) {
log.Println("Saving config to %s", filename)
bytes, _ := json.MarshalIndent(config, "", "\t")
ioutil.WriteFile(filename, bytes, 0600)
}
// LoadConfig loads a Config from a json file specified by filename
func LoadConfig(filename string) Config {
log.Printf("Loading config from %s\n", filename)
config := Config{}
config.MaxBufferLines = 100000
config.ServerReporting.LogMetricsToFile = false

Loading…
Cancel
Save