Skip to content

Commit a87c20f

Browse files
committed
change base image to ubuntu, add config options and docker-compose example file
1 parent efe59ca commit a87c20f

7 files changed

+325
-27
lines changed

Dockerfile

+22-25
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
1-
FROM centos:8
1+
FROM ubuntu:focal
22

33
MAINTAINER Roni Väyrynen <[email protected]>
44

55
# Install set of dependencies to support running Xen-Orchestra
66

7+
# build dependencies, git for fetching source and redis server for storing data
8+
RUN apt update && \
9+
apt install -y build-essential redis-server libpng-dev git libvhdi-utils python2-minimal lvm2 nfs-common cifs-utils curl python3-jinja2
10+
711
# Node v14
8-
RUN curl -s -L https://rpm.nodesource.com/setup_14.x | bash -
12+
RUN curl -s -L https://deb.nodesource.com/setup_14.x | bash -
913

1014
# yarn for installing node packages
11-
RUN curl -s -o /etc/yum.repos.d/yarn.repo https://dl.yarnpkg.com/rpm/yarn.repo
12-
RUN yum -y install yarn
13-
14-
# epel-release for various packages not available from base repo
15-
RUN yum -y install epel-release
16-
17-
# build dependencies, git for fetching source and redis server for storing data
18-
RUN yum -y install gcc gcc-c++ make openssl openssl-devel redis libpng-devel python3 git nfs-utils cifs-utils
19-
20-
# libvhdi-tools for file-level restore
21-
RUN rpm -ivh https://forensics.cert.org/cert-forensics-tools-release-el7.rpm
22-
RUN yum --enablerepo=forensics install -y libvhdi-tools
15+
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
16+
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
17+
apt update && \
18+
apt install -y yarn
2319

2420
# monit to keep an eye on processes
25-
RUN yum -y install monit
26-
ADD monit-services /etc/monit.d/services
21+
RUN apt -y install monit
22+
ADD conf/monit-services /etc/monit/conf.d/services
2723

2824
# Fetch Xen-Orchestra sources from git stable branch
2925
RUN git clone -b master https://github.com/vatesfr/xen-orchestra /etc/xen-orchestra
@@ -35,29 +31,30 @@ RUN cd /etc/xen-orchestra && yarn && yarn build
3531
RUN find /etc/xen-orchestra/packages/ -maxdepth 1 -mindepth 1 -not -name "xo-server" -not -name "xo-web" -not -name "xo-server-cloud" -exec ln -s {} /etc/xen-orchestra/packages/xo-server/node_modules \;
3632
RUN cd /etc/xen-orchestra && yarn && yarn build
3733

38-
# Fix path for xo-web content in xo-server configuration
39-
RUN sed -i "s/#'\/' = '\/path\/to\/xo-web\/dist\//'\/' = '..\/xo-web\/dist\//" /etc/xen-orchestra/packages/xo-server/sample.config.toml
40-
41-
# Move edited config sample to place
42-
RUN mv /etc/xen-orchestra/packages/xo-server/sample.config.toml /etc/xen-orchestra/packages/xo-server/.xo-server.toml
43-
4434
# Install forever for starting/stopping Xen-Orchestra
4535
RUN npm install forever -g
4636

37+
# cleanup
38+
RUN yarn cache clean --all
39+
4740
# Logging
48-
RUN ln -sf /proc/1/fd/1 /var/log/redis/redis.log
49-
RUN ln -sf /proc/1/fd/1 /var/log/xo-server.log
41+
RUN ln -sf /proc/1/fd/1 /var/log/redis/redis-server.log && \
42+
ln -sf /proc/1/fd/1 /var/log/xo-server.log && \
43+
ln -sf /proc/1/fd/1 /var/log/monit.log
5044

5145
# Healthcheck
5246
ADD healthcheck.sh /healthcheck.sh
5347
RUN chmod +x /healthcheck.sh
5448
HEALTHCHECK --start-period=1m --interval=30s --timeout=5s --retries=2 CMD /healthcheck.sh
5549

50+
# Copy xo-server configuration template
51+
ADD conf/xo-server.toml.j2 /xo-server.toml.j2
52+
5653
# Copy startup script
5754
ADD run.sh /run.sh
5855
RUN chmod +x /run.sh
5956

60-
WORKDIR /etc/xen-orchestra/xo-server
57+
WORKDIR /etc/xen-orchestra/packages/xo-server
6158

6259
EXPOSE 80
6360

README.md

+73-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Xen-Orchestra docker container
22

3+
Image has been refactored with Ubuntu as base image and quite a few changes starting 14th Jun 2021. It should be drop in replacement for old image, but in case needed, old image is found with tag centos.
4+
35
This repository contains files to build Xen-Orchestra community edition docker container with all features and plugins installed
46

57
Latest tag is daily build from xen orchestra sources master branch. xen orchestra github project has stopped making versioned releases, therefore container is built only against master branch. All other container tags are old and only kept for compatibility.
@@ -53,7 +55,7 @@ In case your system is also using an application security framework AppArmor or
5355

5456
For AppArmor you will have to add also `--security-opt apparmor:unconfined`.
5557

56-
Bellow is an example command for running the app in a docker container with:
58+
Below is an example command for running the app in a docker container with:
5759

5860
* automatic container start on boot / crash
5961
* enogh capabilities to mount nfs shares
@@ -72,3 +74,73 @@ docker run -itd \
7274
7375
```
7476

77+
You may also use docker-compose. Copy configuration from below of example docker-compose.yml from github repository
78+
79+
```
80+
version: '3'
81+
services:
82+
xen-orchestra:
83+
restart: unless-stopped
84+
image: ronivay/xen-orchestra:latest
85+
container_name: xen-orchestrea
86+
stop_grace_period: 1m
87+
ports:
88+
- "80:80"
89+
#- "443:443"
90+
environment:
91+
- HTTP_PORT=80
92+
#- HTTPS_PORT=443
93+
94+
#redirect takes effect only if HTTPS_PORT is defined
95+
#- REDIRECT_TO_HTTPS=true
96+
97+
#if HTTPS_PORT is defined and CERT/KEY paths are empty, a self-signed certificate will be generated
98+
#- CERT_PATH='/cert.pem'
99+
#- KEY_PATH='/cert.key'
100+
# capabilities are needed for NFS mount
101+
cap_add:
102+
- SYS_ADMIN
103+
# additional setting required for apparmor enabled systems. also needed for NFS mount
104+
security_opt:
105+
- apparmor:unconfined
106+
volumes:
107+
- xo-data:/var/lib/xo-server
108+
# mount certificate files to container if HTTPS is set with cert/key paths
109+
#- ./temp-cert.pem:/temp-cert.pem
110+
#- ./temp-key.pem:/temp-key.pem
111+
# logging
112+
logging: &default_logging
113+
driver: "json-file"
114+
options:
115+
max-size: "1M"
116+
max-file: "2"
117+
118+
volumes:
119+
xo-data:
120+
```
121+
122+
#### Variables
123+
124+
`HTTP_PORT`
125+
126+
Listening HTTP port inside container
127+
128+
`HTTPS_PORT`
129+
130+
Listening HTTPS port inside container
131+
132+
`REDIRECT_TO_HTTPS`
133+
134+
Boolean value true/false. If set to true, will redirect any HTTP traffic to HTTPS. Requires that HTTPS_PORT is set. Defaults to: false
135+
136+
`CERT_PATH`
137+
138+
Path inside container for user specified PEM certificate file. Example: '/path/to/cert'
139+
140+
If HTTPS_PORT is set and CERT_PATH not given, a self-signed certificate and key will be generated automatically.
141+
142+
`KEY_PATH`
143+
144+
Path inside container for user specified key file. Example: '/path/to/key'
145+
146+
if HTTPS_PORT is set and KEY_PATH not given, a self-signed certificate and key will be generated automatically.

conf/monit-services

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
set httpd port 2812 and
2+
use address localhost
3+
allow localhost
4+
5+
check process xo-server with pidfile /var/run/xo-server.pid
6+
depends on redis
7+
start program = "/usr/bin/forever start -a --pidFile /var/run/xo-server.pid --sourceDir /etc/xen-orchestra/packages/xo-server -l /var/log/xo-server.log dist/cli.mjs"
8+
stop program = "/usr/bin/forever stop /etc/xen-orchestra/packages/xo-server/dist/cli.mjs"
9+
10+
check process redis with pidfile /var/run/redis.pid
11+
start program = "/usr/bin/redis-server --bind 127.0.0.1 --port 6379 --pidfile /var/run/redis.pid --daemonize yes"
12+
stop program = "/usr/bin/redis-cli shutdown"
13+
14+
check process rpcbind matching "rpcbind"
15+
start program = "/usr/sbin/rpcbind"

conf/xo-server.toml.j2

+158
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
# Example XO-Server configuration.
2+
#
3+
# This file is automatically looking for at the following places:
4+
# - `$HOME/.config/xo-server/config.toml`
5+
# - `/etc/xo-server/config.toml`
6+
#
7+
# The first entries have priority.
8+
#
9+
# Note: paths are relative to the configuration file.
10+
11+
#=====================================================================
12+
13+
# HTTP proxy configuration used by xo-server to fetch resources on the Internet.
14+
#
15+
# See: https://github.com/TooTallNate/node-proxy-agent#maps-proxy-protocols-to-httpagent-implementations
16+
# httpProxy = 'http://jsmith:[email protected]:3128'
17+
18+
#=====================================================================
19+
20+
# It may be necessary to run XO-Server as a privileged user (e.g. `root`) for
21+
# instance to allow the HTTP server to listen on a
22+
# [privileged ports](http://www.w3.org/Daemon/User/Installation/PrivilegedPorts.html).
23+
#
24+
# To avoid security issues, XO-Server can drop its privileges by changing the
25+
# user and the group is running with.
26+
#
27+
# Note: XO-Server will change them just after reading the configuration.
28+
29+
# User to run XO-Server as.
30+
#
31+
# Note: The user can be specified using either its name or its numeric
32+
# identifier.
33+
#
34+
# Default: undefined
35+
#user = 'nobody'
36+
37+
# Group to run XO-Server as.
38+
#
39+
# Note: The group can be specified using either its name or its numeric
40+
# identifier.
41+
#
42+
# Default: undefined
43+
# group = 'nogroup'
44+
45+
#=====================================================================
46+
47+
# Directory containing the database of XO.
48+
# Currently used for logs.
49+
#
50+
# Default: '/var/lib/xo-server/data'
51+
#datadir = '/var/lib/xo-server/data'
52+
53+
#=====================================================================
54+
55+
# Configuration of the embedded HTTP server.
56+
[http]
57+
# If set to true, all HTTP traffic will be redirected to the first HTTPs
58+
# configuration.
59+
# redirectToHttps = true
60+
{% if env['REDIRECT_TO_HTTPS'] == 'true' and env['HTTPS_PORT'] %}
61+
redirectToHttps = true
62+
{% endif %}
63+
64+
65+
# Settings applied to cookies created by xo-server's embedded HTTP server.
66+
#
67+
# See https://www.npmjs.com/package/cookie#options-1
68+
[http.cookies]
69+
#sameSite = true
70+
#secure = true
71+
72+
# Basic HTTP.
73+
[[http.listen]]
74+
# Address on which the server is listening on.
75+
#
76+
# Sets it to 'localhost' for IP to listen only on the local host.
77+
#
78+
# Default: all IPv6 addresses if available, otherwise all IPv4 addresses.
79+
# hostname = 'localhost'
80+
81+
# Port on which the server is listening on.
82+
#
83+
# Default: undefined
84+
port = {{ env['HTTP_PORT'] }}
85+
86+
# Instead of `host` and `port` a path to a UNIX socket may be specified
87+
# (overrides `host` and `port`).
88+
#
89+
# Default: undefined
90+
# socket = './http.sock'
91+
92+
# # Basic HTTPS.
93+
# #
94+
# # You can find the list of possible options there
95+
# # https://nodejs.org/docs/latest/api/tls.html#tls.createServer
96+
# #
97+
# # The only difference is the presence of the certificate and the key.
98+
99+
{% if env['HTTPS_PORT'] %}
100+
[[http.listen]]
101+
port = {{ env['HTTPS_PORT'] }}
102+
103+
autoCert = true
104+
cert = {{ env['CERT_PATH'] }}
105+
key = {{ env['KEY_PATH'] }}
106+
{% endif %}
107+
108+
# List of files/directories which will be served.
109+
[http.mounts]
110+
#'/any/url' = '/path/to/directory'
111+
112+
# List of proxied URLs (HTTP & WebSockets).
113+
[http.proxies]
114+
#'/any/url' = 'http://localhost:54722'
115+
116+
#=====================================================================
117+
118+
# Connection to the Redis server.
119+
[redis]
120+
# Unix sockets can be used
121+
#
122+
# Default: undefined
123+
#socket = '/var/run/redis/redis.sock'
124+
125+
# Syntax: redis://[db[:password]@]hostname[:port][/db-number]
126+
#
127+
# Default: redis://localhost:6379/0
128+
#uri = 'redis://redis.company.lan/42'
129+
130+
# List of aliased commands.
131+
#
132+
# See http://redis.io/topics/security#disabling-of-specific-commands
133+
#renameCommands:
134+
# del = '3dda29ad-3015-44f9-b13b-fa570de92489'
135+
# srem = '3fd758c9-5610-4e9d-a058-dbf4cb6d8bf0'
136+
137+
#=====================================================================
138+
139+
# Configuration for remotes
140+
[remoteOptions]
141+
# Directory used to mount remotes
142+
#
143+
# Default: '/run/xo-server/mounts'
144+
#mountsDir = '/run/xo-server/mounts'
145+
146+
# Use sudo for mount with non-root user
147+
#
148+
# Default: false
149+
#useSudo = false
150+
151+
#=====================================================================
152+
153+
# Configuration for plugins
154+
[plugins]
155+
# Each configuration is passed to the dedicated plugin instance
156+
#
157+
# Syntax: [plugins.<pluginName>]
158+

docker-compose.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
version: '3'
2+
services:
3+
xen-orchestra:
4+
restart: unless-stopped
5+
image: ronivay/xen-orchestra:latest
6+
container_name: xen-orchestra
7+
stop_grace_period: 1m
8+
ports:
9+
- "80:80"
10+
#- "443:443"
11+
environment:
12+
- HTTP_PORT=80
13+
#- HTTPS_PORT=443
14+
15+
#redirect takes effect only if HTTPS_PORT is defined
16+
#- REDIRECT_TO_HTTPS=true
17+
18+
#if HTTPS_PORT is defined and CERT/KEY paths are empty, a self-signed certificate will be generated
19+
#- CERT_PATH='/cert.pem'
20+
#- KEY_PATH='/cert.key'
21+
# capabilities are needed for NFS mount
22+
cap_add:
23+
- SYS_ADMIN
24+
# additional setting required for apparmor enabled systems. also needed for NFS mount
25+
security_opt:
26+
- apparmor:unconfined
27+
volumes:
28+
- xo-data:/var/lib/xo-server
29+
- redis-data:/var/lib/redis
30+
# mount certificate files to container if HTTPS is set with cert/key paths
31+
#- ./temp-cert.pem:/temp-cert.pem
32+
#- ./temp-key.pem:/temp-key.pem
33+
# logging
34+
logging: &default_logging
35+
driver: "json-file"
36+
options:
37+
max-size: "1M"
38+
max-file: "2"
39+
40+
volumes:
41+
xo-data:
42+
redis-data:

healthcheck.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
/usr/bin/curl -s -I -m 3 http://127.0.0.1 >/dev/null
3+
/usr/bin/curl -s -k -L -I -m 3 http://127.0.0.1:${HTTP_PORT} >/dev/null
44

55
if [[ "$?" == "0" ]]; then
66
webcheck_retval="0"

0 commit comments

Comments
 (0)