Convert to systemd service

This commit is contained in:
Brad Treloar 2025-02-06 00:14:43 +10:30
parent 349775bffb
commit 58b11a152e
5 changed files with 28 additions and 14 deletions

View file

@ -1,4 +0,0 @@
#!/bin/bash
# Build/rebuild the image.
docker build --no-cache -t notes-server .

15
install.sh Executable file
View file

@ -0,0 +1,15 @@
#!/bin/bash
# Build the notes-server image.
docker build --no-cache -t notes-server .
# Run the notes-server image.
docker run -d \
--name notes-server \
-v "/var/www/html/notes/site:/usr/share/nginx/html" \
-p 42069:80 \
notes-server
# Install and enable the systemctl service.
cp notes.service /etc/systemd/system/notes.service
systemctl enable notes.service

13
notes.service Normal file
View file

@ -0,0 +1,13 @@
[Unit]
Description=Notes server
After=docker.service
Wants=network-online.target docker.socket
Requires=docker.socket
[Service]
ExecStart=/usr/bin/docker start -a notes-server
ExecStop=/usr/bin/docker stop -t 10 notes-server
Restart=always
[Install]
WantedBy=multi-user.target

View file

@ -1,7 +0,0 @@
#!/bin/bash
# Build/rebuild the image.
docker build --no-cache -t notes-server .
# Run the image, listening on port 8080.
docker run --mount type=bind,src=./site,dst=/usr/share/nginx/html -p 42069:80 -t notes-server

3
run.sh
View file

@ -1,3 +0,0 @@
#!/bin/bash
docker run --mount type=bind,src=./site,dst=/usr/share/nginx/html -p 42069:80 -t notes-server