Add service, update, and README files
This commit is contained in:
parent
a65286dccf
commit
520eb68dcf
14
Makefile
14
Makefile
@ -1,3 +1,17 @@
|
||||
# -----------------------------------------------------------------------------
|
||||
# Install the service file.
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
install:
|
||||
cp loki-server.service /lib/systemd/system/
|
||||
systemctl daemon-reload
|
||||
systemctl enable loki-server
|
||||
|
||||
uninstall:
|
||||
systemctl disable loki-server
|
||||
rm /lib/systemd/system/loki-server.service
|
||||
systemctl daemon-reload
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# The container registry to use.
|
||||
# -----------------------------------------------------------------------------
|
||||
|
55
README.rst
Normal file
55
README.rst
Normal file
@ -0,0 +1,55 @@
|
||||
Loki
|
||||
====
|
||||
|
||||
Docker files for my server, Loki.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
The following command will install the service file, reload systemd, and enable
|
||||
the service
|
||||
|
||||
::
|
||||
|
||||
make install
|
||||
|
||||
Uninstall with
|
||||
|
||||
::
|
||||
|
||||
make uninstall
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
To start the service run
|
||||
|
||||
::
|
||||
|
||||
service loki-server start
|
||||
|
||||
To stop run
|
||||
|
||||
::
|
||||
|
||||
service loki-server stop
|
||||
|
||||
To restart
|
||||
|
||||
::
|
||||
|
||||
service loki-server restart
|
||||
|
||||
Note that ``docker-compose`` might have issues with HTTP timeout so you may
|
||||
have to increase the ``COMPOSE_HTTP_TIMEOUT`` environment variable. ``300``
|
||||
should be enough.
|
||||
|
||||
Updating
|
||||
--------
|
||||
|
||||
To update the images and restart run (``WARNING: THIS WILL REMOVE ALL UNUSED
|
||||
DOCKER IMAGES``)
|
||||
|
||||
::
|
||||
|
||||
./update.sh
|
14
loki-server.service
Normal file
14
loki-server.service
Normal file
@ -0,0 +1,14 @@
|
||||
[Unit]
|
||||
Description=Dockerised web server
|
||||
Require=docker.service
|
||||
After=docker.service
|
||||
|
||||
[Service]
|
||||
WorkingDirectory=/root/Dockerfiles
|
||||
ExecStart=/usr/bin/docker-compose up
|
||||
ExecStop=/usr/bin/docker-compose down
|
||||
Restart=always
|
||||
TimeoutStopSec=10min
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
55
update.sh
Executable file
55
update.sh
Executable file
@ -0,0 +1,55 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
CYAN='\033[01;36m'
|
||||
RED='\033[01;31m'
|
||||
NC='\033[00m'
|
||||
|
||||
SCRIPT=$(readlink -f $0)
|
||||
DIRNAME=$(dirname $SCRIPT)
|
||||
|
||||
SLEEP_TIME=600
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Pull updated images.
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
echo -e "${CYAN}[${SCRIPT}] Pull updated images${NC}"
|
||||
|
||||
make -C $DIRNAME pull-all
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Restart the containers.
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
echo -e "${CYAN}[${SCRIPT}] Restart the containers${NC}"
|
||||
|
||||
COMPOSE_HTTP_TIMEOUT=300 service loki-server restart
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Wait for containers to start.
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
echo -e "${CYAN}[${SCRIPT}] Wait ${SLEEP_TIME}s for containers to start${NC}"
|
||||
|
||||
sleep $SLEEP_TIME
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Remove unused images.
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
ACTIVE=$(systemctl status loki-server.service | grep "active (running)" -c)
|
||||
|
||||
if [[ $ACTIVE == 1 ]]
|
||||
then
|
||||
|
||||
echo -e "${CYAN}[${SCRIPT}] Remove unused images${NC}"
|
||||
|
||||
yes | docker image prune -a
|
||||
|
||||
else
|
||||
|
||||
echo -e "${RED}[${SCRIPT}] Problem with service activation${NC}"
|
||||
|
||||
fi
|
Reference in New Issue
Block a user