Convert to docker compose

This commit is contained in:
Brad Treloar 2025-09-03 23:32:03 +09:30
parent 82348ddc7c
commit 86fc7ca259
5 changed files with 22 additions and 48 deletions

View file

@ -2,7 +2,7 @@
## Set up hugo and build HTML ## Set up hugo and build HTML
````bash ```bash
# Install hugo. # Install hugo.
sudo apt install hugo sudo apt install hugo
@ -11,27 +11,22 @@ cd hugo
hugo hugo
``` ```
## Build and run server ## Prepare and run server
```bash ```bash
# Set access credentials. # Set access credentials.
./passwd.sh username password ./passwd.sh username password
# Build/rebuild the image. # Run the service.
docker build --no-cache -t notes-server . docker compose up -d
```
# Run the image, listening on port 42069. ## Changing the login credentials
docker run -d \
--name notes-server \
-v "/var/www/html/notes/hugo/public:/usr/share/nginx/html" \
-p 42069:80 \
notes-server
````
## Auth credentials setup
```bash ```bash
# Overwrite the htpasswd file with new user credentials. # Overwrite the htpasswd file with new user credentials.
# (Rebuild the image to copy the new credentials.)
./passwd.sh username password ./passwd.sh username password
# (Rebuild the image to copy the new credentials.)
docker compose down && docker compose up -d --build
``` ```

13
docker-compose.yml Normal file
View file

@ -0,0 +1,13 @@
services:
server:
build:
context: docker
dockerfile: ./docker/Dockerfile
container_name: server
restart: always
volumes:
- ./hugo/public:/usr/share/nginx/html:ro
ports:
- "42069:80"

View file

@ -1,4 +0,0 @@
#!/bin/bash
docker container rm notes-server
docker build --no-cache -t notes-server .

View file

@ -1,21 +0,0 @@
#!/bin/bash
# Remove the existing container
systemctl stop notes.service
systemctl disable notes.service
docker container stop notes-server
docker container rm notes-server
# Build the notes-server image.
docker build --no-cache -t notes-server .
# Run the notes-server image.
docker run -d \
--name notes-server \
-v "${PWD}/../hugo/public:/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

View file

@ -1,9 +0,0 @@
#!/bin/bash
# Run the notes-server image.
docker run \
--name notes-server \
-v "${PWD}/../hugo/public:/usr/share/nginx/html" \
-p 42069:80 \
notes-server