Skip to content
Snippets Groups Projects
Commit 0a092d44 authored by Michiel de Jong's avatar Michiel de Jong
Browse files

remove wordpress-subdir image

parent 6e4fc5c2
No related branches found
No related tags found
No related merge requests found
......@@ -12,12 +12,12 @@ There is currently no similar side-kick for updating `/data/server-wide/postfix/
The `scripts/setup.sh` takes care of setting up etcd, enabling and starting the haproxy and postfix service (as well as one haproxy backend, to serve the default site), and the haproxy-confd side-kick to listen for changes in the backends configuration in etcd, so that new backends are automatically added to the haproxy config as soon as their IP address is written into etcd.
## HAProxy backends: nginx, wordpress, wordpress-subdir
## HAProxy backends: nginx, wordpress
A per-user process is a haproxy backend for a specific domain name. At the time of writing we have three applications available: nginx, wordpress, and wordpress-subdir.
A per-user process is a haproxy backend for a specific domain name. At the time of writing we have two applications available: nginx and wordpress.
You will notice there are also some other units in the `unit-files/` folder of this repo, like the gitpuller and mysql ones. Whenever you start a wordpress or a wordpress-subdir unit, it requires a mysql service.
Whenever you start a wordpress-subdir or an nginx unit, it wants a gitpuller unit. In all three cases, an -importer unit and a -discovery unit are required.
You will notice there are also some other units in the `unit-files/` folder of this repo, like the gitpuller and mysql ones. Whenever you start a wordpress unit, it requires a mysql service.
Whenever you start an nginx unit, it wants a gitpuller unit. In all three cases, an -importer unit and a -discovery unit are required.
This works through a
[`Requires=` directive](https://github.com/indiehosters/indiehosters/blob/0.1.0/unit-files/nginx@.service#L6-L7) which systemd interprets, so that if you start one service, its dependencies are also started (you can see that in `systemctl list-units`).
......
#!/bin/bash
if [ ! -d "/data/per-user/$USER/wordpress-subdir/data" ]; then
cd /data/per-user/$USER/
tar xvzf /data/indiehosters/blueprints/wordpress.tgz
fi
cat /data/per-user/$USER/mysql/.env | sed s/MYSQL_PASS/DB_PASS/ > /data/per-user/$USER/wordpress-subdir/.env
if [ ! -e "/data/per-user/$USER/wordpress-subdir/data/www-content/index.html" ]; then
if [ -e "/data/per-user/$USER/wordpress-subdir/data/GITURL" ]; then
git clone `cat /data/per-user/$USER/wordpress-subdir/data/GITURL` /data/per-user/$USER/wordpress-subdir/data/www-content
cd /data/per-user/$USER/wordpress-subdir/data/www-content && git checkout master
else
mkdir -p /data/per-user/$USER/wordpress-subdir/data/www-content
echo Hello $USER > /data/per-user/$USER/wordpress-subdir/data/www-content/index.html
fi
fi
......@@ -19,7 +19,6 @@ docker pull indiehosters/postfix-forwarder
docker pull indiehosters/nginx
docker pull indiehosters/mysql
docker pull indiehosters/wordpress
docker pull indiehosters/wordpress-subdir
# Install unit-files
cp /data/indiehosters/unit-files/* /etc/systemd/system
......
[Unit]
Description=%p for %i etcd registration
# Requirements
Requires=etcd.service
Requires=wordpress-subdir@%i.service
# Dependency ordering
After=etcd.service
After=wordpress-subdir@%i.service
# Dependency binding
BindsTo=wordpress-subdir@%i.service
[Service]
# Start
## Test whether service is accessible and then register useful information
ExecStart=/bin/bash -c ' \
sleep 3; \
while true; do \
app=`echo %p | cut -d"-" -f1,2`; \
ip=`docker inspect --format \'{{.NetworkSettings.IPAddress}}\' $app-%i`; \
curl -f $ip; \
if [ $? -eq 0 ]; then \
etcdctl set /services/$app/%i \'{"ip":"\'$ip\'", "port":"80"}\' --ttl 60; \
else \
etcdctl rm /services/$app/%i; \
fi; \
sleep 50; \
done'
# Stop
ExecStop=/bin/bash -ceux ' \
app=`echo %p | cut -d"-" -f1`; \
/usr/bin/etcdctl rm /services/$app/%i
[Path]
PathExists=/data/per-user/%i/wordpress-subdir/data/GITURL
[Unit]
Description= git puller
[Service]
Type=oneshot
RemainAfterExit=yes
Environment=USER=%i
Environment=APP=wordpress-subdir
ExecStart=/data/indiehosters/importers/gitpuller.sh
[Unit]
Description=Run git puller every 10 minutes
[Timer]
OnUnitActiveSec=10min
[Install]
WantedBy=timers.target
[Unit]
Description=wordpress-subdir importer
# Dependency ordering
After=mysql-importer@%i.service
Before=wordpress-subdir@%i.service
[Service]
Type=oneshot
RemainAfterExit=yes
Environment=USER=%i
ExecStart=/data/indiehosters/importers/wordpress-subdir.sh
[Install]
WantedBy=wordpress-subdir@%i.service
[Unit]
Description=%p-%i
# Requirements
Requires=docker.service
Requires=etcd.service
Requires=mysql@%i.service
Requires=%p-importer@%i.service
Requires=%p-discovery@%i.service
Wants=%p-gitpuller@%i.service
# Dependency ordering
After=docker.service
After=mysql@%i.service
After=%p-importer@%i.service
Before=%p-discovery@%i.service
[Service]
Restart=always
ExecStartPre=-/usr/bin/docker kill %p-%i
ExecStartPre=-/usr/bin/docker rm %p-%i
ExecStart=/usr/bin/docker run \
--name %p-%i \
--link mysql-%i:db \
-v /data/per-user/%i/%p/data/wp-content:/wordpress/wp-content \
-v /data/per-user/%i/%p/data/.htaccess:/wordpress/.htaccess \
-v /data/per-user/%i/%p/data/www-content:/app \
--env-file /data/per-user/%i/%p/.env \
indiehosters/wordpress-subdir
ExecReload=/usr/bin/docker restart %p-%i
ExecStop=/usr/bin/docker stop %p-%i
[Install]
WantedBy=multi-user.target
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment