Resolves #152 #153

Merged
dan merged 1 commits from GBHC/cwtch:docker-volume-config-dir into master 2018-11-01 17:39:03 +00:00
Contributor

We use the environment variable CWTCH_CONFIG_DIR to prefix a directory for the cwtchserver.LoadConfig and save functions.

os.GetEnv returns a blank string if the env var is empty so shouldn't affect existing operation / scripts / config in non dockerised situations.

One needs to pass the env var CWTCH_CONFIG_DIR of /etc/cwtch/ to match the VOLUME specified in the Dockerfile;

sudo docker run -e CWTCH_CONFIG_DIR=/etc/cwtch/ cwtch:latest

In Action

$ sudo docker inspect hopeful_hawking
[
    {
        "Id": "e5aa99870f9507c0a3181cc996110e163113fe1c57f286bbb65fda8592026e84",
        <SNIP>
        "Mounts": [
            {
                "Type": "volume",
                "Name": "e5702cea21017fa2d7f4eea108664603e2e59682182f0487f624c317f9df07be",
                "Source": "/var/lib/docker/volumes/e5702cea21017fa2d7f4eea108664603e2e59682182f0487f624c317f9df07be/_data",
                "Destination": "/etc/cwtch",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            },

On the filesystem;

$ sudo cat /var/lib/docker/volumes/e5702cea21017fa2d7f4eea108664603e2e59682182f0487f624c317f9df07be/_data/serverConfig.json
{
	"maxBufferLines": 100000,
	"publicKey": "<snip>",
	"privateKey": "<snip>",
	"serverReporting": {
		"logMetricsToFile": false,
		"reportingGroupId": "",
		"reportingServerAddr": ""
	}
}

And stopping / starting;

$ sudo docker run -e CWTCH_CONFIG_DIR=/etc/cwtch/ cwtch:latest
changed ownership of '/var/lib/tor' to 100:101
mode of '/var/lib/tor' changed to 0700 (rwx------)

========================================================
Alpine Version: 3.8.1
Tor version 0.3.5.2-alpha.
========================================================

Nov 01 15:51:40.607 [notice] Tor 0.3.5.2-alpha running on Linux with Libevent 2.1.8-stable, OpenSSL LibreSSL 2.7.4, Zlib 1.2.11, Liblzma 5.2.4, and Libzstd 1.3.4.
Nov 01 15:51:40.609 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
Nov 01 15:51:40.609 [notice] This version is not a stable Tor release. Expect more bugs than usual.
Nov 01 15:51:40.609 [notice] Read configuration file "/etc/tor/torrc".
Nov 01 15:51:40.615 [notice] Opening Socks listener on 127.0.0.1:9050
Nov 01 15:51:40.616 [notice] Opened Socks listener on 127.0.0.1:9050
Nov 01 15:51:40.616 [notice] Opening Control listener on 127.0.0.1:9051
Nov 01 15:51:40.616 [notice] Opened Control listener on 127.0.0.1:9051
2018/11/01 15:51:55 Loading from /etc/cwtch/serverConfig.json
2018/11/01 15:51:55 Saving to /etc/cwtch/serverConfig.json
2018/11/01 15:51:55 starting cwtch server...
2018/11/01 15:51:55 using local port: 30058
2018/11/01 15:51:55 cwtch server running on cwtch:juvvnmqmdr5ii5ipvkdraii6jvyxn5t7fg2qtebxlttce4rttkpfmeid.onion:9878


^C

$ sudo docker start hopeful_hawking
hopeful_hawking

$ sudo docker logs hopeful_hawking
changed ownership of '/var/lib/tor' to 100:101
mode of '/var/lib/tor' changed to 0700 (rwx------)

========================================================
Alpine Version: 3.8.1
Tor version 0.3.5.2-alpha.
========================================================

Nov 01 15:51:40.607 [notice] Tor 0.3.5.2-alpha running on Linux with Libevent 2.1.8-stable, OpenSSL LibreSSL 2.7.4, Zlib 1.2.11, Liblzma 5.2.4, and Libzstd 1.3.4.
Nov 01 15:51:40.609 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
Nov 01 15:51:40.609 [notice] This version is not a stable Tor release. Expect more bugs than usual.
Nov 01 15:51:40.609 [notice] Read configuration file "/etc/tor/torrc".
Nov 01 15:51:40.615 [notice] Opening Socks listener on 127.0.0.1:9050
Nov 01 15:51:40.616 [notice] Opened Socks listener on 127.0.0.1:9050
Nov 01 15:51:40.616 [notice] Opening Control listener on 127.0.0.1:9051
Nov 01 15:51:40.616 [notice] Opened Control listener on 127.0.0.1:9051
2018/11/01 15:51:55 Loading from /etc/cwtch/serverConfig.json
2018/11/01 15:51:55 Saving to /etc/cwtch/serverConfig.json
2018/11/01 15:51:55 starting cwtch server...
2018/11/01 15:51:55 using local port: 30058
2018/11/01 15:51:55 cwtch server running on cwtch:juvvnmqmdr5ii5ipvkdraii6jvyxn5t7fg2qtebxlttce4rttkpfmeid.onion:9878
We use the environment variable `CWTCH_CONFIG_DIR` to prefix a directory for the `cwtchserver.LoadConfig` and save functions. `os.GetEnv` returns a blank string if the env var is empty so shouldn't affect existing operation / scripts / config in non dockerised situations. One needs to pass the env var `CWTCH_CONFIG_DIR` of `/etc/cwtch/` to match the `VOLUME` specified in the `Dockerfile`; ```sudo docker run -e CWTCH_CONFIG_DIR=/etc/cwtch/ cwtch:latest``` # In Action ``` $ sudo docker inspect hopeful_hawking [ { "Id": "e5aa99870f9507c0a3181cc996110e163113fe1c57f286bbb65fda8592026e84", <SNIP> "Mounts": [ { "Type": "volume", "Name": "e5702cea21017fa2d7f4eea108664603e2e59682182f0487f624c317f9df07be", "Source": "/var/lib/docker/volumes/e5702cea21017fa2d7f4eea108664603e2e59682182f0487f624c317f9df07be/_data", "Destination": "/etc/cwtch", "Driver": "local", "Mode": "", "RW": true, "Propagation": "" }, ``` On the filesystem; ``` $ sudo cat /var/lib/docker/volumes/e5702cea21017fa2d7f4eea108664603e2e59682182f0487f624c317f9df07be/_data/serverConfig.json { "maxBufferLines": 100000, "publicKey": "<snip>", "privateKey": "<snip>", "serverReporting": { "logMetricsToFile": false, "reportingGroupId": "", "reportingServerAddr": "" } } ``` And stopping / starting; ``` $ sudo docker run -e CWTCH_CONFIG_DIR=/etc/cwtch/ cwtch:latest changed ownership of '/var/lib/tor' to 100:101 mode of '/var/lib/tor' changed to 0700 (rwx------) ======================================================== Alpine Version: 3.8.1 Tor version 0.3.5.2-alpha. ======================================================== Nov 01 15:51:40.607 [notice] Tor 0.3.5.2-alpha running on Linux with Libevent 2.1.8-stable, OpenSSL LibreSSL 2.7.4, Zlib 1.2.11, Liblzma 5.2.4, and Libzstd 1.3.4. Nov 01 15:51:40.609 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning Nov 01 15:51:40.609 [notice] This version is not a stable Tor release. Expect more bugs than usual. Nov 01 15:51:40.609 [notice] Read configuration file "/etc/tor/torrc". Nov 01 15:51:40.615 [notice] Opening Socks listener on 127.0.0.1:9050 Nov 01 15:51:40.616 [notice] Opened Socks listener on 127.0.0.1:9050 Nov 01 15:51:40.616 [notice] Opening Control listener on 127.0.0.1:9051 Nov 01 15:51:40.616 [notice] Opened Control listener on 127.0.0.1:9051 2018/11/01 15:51:55 Loading from /etc/cwtch/serverConfig.json 2018/11/01 15:51:55 Saving to /etc/cwtch/serverConfig.json 2018/11/01 15:51:55 starting cwtch server... 2018/11/01 15:51:55 using local port: 30058 2018/11/01 15:51:55 cwtch server running on cwtch:juvvnmqmdr5ii5ipvkdraii6jvyxn5t7fg2qtebxlttce4rttkpfmeid.onion:9878 ^C $ sudo docker start hopeful_hawking hopeful_hawking $ sudo docker logs hopeful_hawking changed ownership of '/var/lib/tor' to 100:101 mode of '/var/lib/tor' changed to 0700 (rwx------) ======================================================== Alpine Version: 3.8.1 Tor version 0.3.5.2-alpha. ======================================================== Nov 01 15:51:40.607 [notice] Tor 0.3.5.2-alpha running on Linux with Libevent 2.1.8-stable, OpenSSL LibreSSL 2.7.4, Zlib 1.2.11, Liblzma 5.2.4, and Libzstd 1.3.4. Nov 01 15:51:40.609 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning Nov 01 15:51:40.609 [notice] This version is not a stable Tor release. Expect more bugs than usual. Nov 01 15:51:40.609 [notice] Read configuration file "/etc/tor/torrc". Nov 01 15:51:40.615 [notice] Opening Socks listener on 127.0.0.1:9050 Nov 01 15:51:40.616 [notice] Opened Socks listener on 127.0.0.1:9050 Nov 01 15:51:40.616 [notice] Opening Control listener on 127.0.0.1:9051 Nov 01 15:51:40.616 [notice] Opened Control listener on 127.0.0.1:9051 2018/11/01 15:51:55 Loading from /etc/cwtch/serverConfig.json 2018/11/01 15:51:55 Saving to /etc/cwtch/serverConfig.json 2018/11/01 15:51:55 starting cwtch server... 2018/11/01 15:51:55 using local port: 30058 2018/11/01 15:51:55 cwtch server running on cwtch:juvvnmqmdr5ii5ipvkdraii6jvyxn5t7fg2qtebxlttce4rttkpfmeid.onion:9878 ```
Member
Drone Build Status: failure https://build.openprivacy.ca/cwtch.im/cwtch/249
dan closed this pull request 2018-11-01 17:39:03 +00:00
Owner
  • go list ./... | xargs go vet

cwtch.im/cwtch/server

server/serverConfig.go:34: Println call has possible formatting directive %s

I'll fix that
thanks!

+ go list ./... | xargs go vet # cwtch.im/cwtch/server server/serverConfig.go:34: Println call has possible formatting directive %s I'll fix that thanks!
Sign in to join this conversation.
No description provided.