Skip to content

Commit 88a893c

Browse files
committed
feat: allow preserving config file on volume or bind mount
1 parent 30975e1 commit 88a893c

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,16 @@ Path inside container for user specified key file. Example: '/path/to/key'
160160
Note: single quotes are part of the value and mandatory!
161161

162162
if HTTPS_PORT is set and KEY_PATH not given, a self-signed certificate and key will be generated automatically.
163+
164+
#### Configuration
165+
166+
xo-server configuration inside container is generated only once based on variables if config file is missing.
167+
168+
If you wish to customize the xo-server configuration file manually. Mount some directory to `/etc/xo-server` path inside container, eq:
169+
170+
```
171+
docker run -itd -p 80:80 -v /path/to/xo-config:/etc/xo-server ronivay/xen-orchestra
172+
```
173+
174+
Once container has started for the first time, you'll now have a configuration file at `/path/to/xo-config/config.toml` which you can edit.
175+
Restarting container will apply the modified configuration.

docker-compose.yml

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ services:
2727
volumes:
2828
- xo-data:/var/lib/xo-server
2929
- redis-data:/var/lib/redis
30+
# to preserve xo-server config on host dir after generated by container
31+
#- /path/to/config:/etc/xo-server
3032
# mount certificate files to container if HTTPS is set with cert/key paths
3133
#- /path/to/cert.pem:/cert.pem
3234
#- /path/to/cert.key:/cert.key

run.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@ function StopProcesses {
1010
exit 0
1111
}
1212

13+
14+
if [[ ! -f /etc/xo-server/config.toml ]]; then
1315
# generate configuration
1416
set -a
1517

18+
[[ ! -d /etc/xo-server ]] && mkdir /etc/xo-server
19+
1620
HTTP_PORT=${HTTP_PORT:-"80"}
1721
CERT_PATH=${CERT_PATH:-\'./temp-cert.pem\'}
1822
KEY_PATH=${KEY_PATH:-\'./temp-key.pem\'}
@@ -22,10 +26,11 @@ import sys
2226
import jinja2
2327
sys.stdout.write(
2428
jinja2.Template(sys.stdin.read()
25-
).render(env=os.environ))' </xo-server.toml.j2 >/etc/xen-orchestra/packages/xo-server/.xo-server.toml
29+
).render(env=os.environ))' </xo-server.toml.j2 >/etc/xo-server/config.toml
2630

2731
set +a
2832
# start services
33+
fi
2934

3035
trap StopProcesses EXIT TERM
3136

0 commit comments

Comments
 (0)