Skip to content

Commit

Permalink
Merge pull request #45 from ronivay/feat/allow-custom-configuration-file
Browse files Browse the repository at this point in the history
feat: allow preserving config file on volume or bind mount
  • Loading branch information
ronivay authored Aug 8, 2024
2 parents 30975e1 + 88a893c commit c875baf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,16 @@ Path inside container for user specified key file. Example: '/path/to/key'
Note: single quotes are part of the value and mandatory!

if HTTPS_PORT is set and KEY_PATH not given, a self-signed certificate and key will be generated automatically.

#### Configuration

xo-server configuration inside container is generated only once based on variables if config file is missing.

If you wish to customize the xo-server configuration file manually. Mount some directory to `/etc/xo-server` path inside container, eq:

```
docker run -itd -p 80:80 -v /path/to/xo-config:/etc/xo-server ronivay/xen-orchestra
```

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.
Restarting container will apply the modified configuration.
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ services:
volumes:
- xo-data:/var/lib/xo-server
- redis-data:/var/lib/redis
# to preserve xo-server config on host dir after generated by container
#- /path/to/config:/etc/xo-server
# mount certificate files to container if HTTPS is set with cert/key paths
#- /path/to/cert.pem:/cert.pem
#- /path/to/cert.key:/cert.key
Expand Down
7 changes: 6 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ function StopProcesses {
exit 0
}


if [[ ! -f /etc/xo-server/config.toml ]]; then
# generate configuration
set -a

[[ ! -d /etc/xo-server ]] && mkdir /etc/xo-server

HTTP_PORT=${HTTP_PORT:-"80"}
CERT_PATH=${CERT_PATH:-\'./temp-cert.pem\'}
KEY_PATH=${KEY_PATH:-\'./temp-key.pem\'}
Expand All @@ -22,10 +26,11 @@ import sys
import jinja2
sys.stdout.write(
jinja2.Template(sys.stdin.read()
).render(env=os.environ))' </xo-server.toml.j2 >/etc/xen-orchestra/packages/xo-server/.xo-server.toml
).render(env=os.environ))' </xo-server.toml.j2 >/etc/xo-server/config.toml

set +a
# start services
fi

trap StopProcesses EXIT TERM

Expand Down

0 comments on commit c875baf

Please sign in to comment.