Browse Source

updated Readme. dockerfiles,runsh and oether fixes

master
teoowod 3 months ago
parent
commit
bb1b9315aa
4 changed files with 23 additions and 41 deletions
  1. 8
    8
      README.md
  2. 1
    24
      after-dark-k3s-hugo.yaml
  3. 9
    7
      dockerfiles/hugo/Dockerfile
  4. 5
    2
      dockerfiles/hugo/run.sh

+ 8
- 8
README.md View File

@@ -41,7 +41,7 @@ Continue reading for an overview of the deployment and basic usage.

This is a Multi-tier deployment for after dark in order to run on k3s or other kubernetes cluster in a microservices way. Currently is meant to run on a single node cluster but you can still test a few things (see below) on a multinode cluster. Your site is being built by hugo and served by a separate nginx web server which is exposed as a service inside your cluster. Combined with a traefik ingress host rule it can be faced against the web abstracting its backend. The deployment is consisted of the following manifests:

* ``after-dark-k3s-hugo.yaml`` deploys a pod using two containers. First, an ephemeral initialization tasked with downloading After Dark from [source repo](https://git.habd.as/comfusion/after-dark) and, finally, the actual hugo container which kicks in and installs the site. When done it runs [`hugo server`](https://gohugo.io/commands/hugo_server/) in _watch mode_ so [Hugo](https://gohugo.io/) rebuilds After Dark site as files change.
* ``after-dark-k3s-hugo.yaml`` deploys a pod containing hugo that will first begin with downloading After Dark from [source repo](https://git.habd.as/comfusion/after-dark), install it and finally kick hugo in watch mode. This means that our pod will serve as our builder since [Hugo](https://gohugo.io/) rebuilds After Dark site as files change.
* ``after-dark-nginx.yaml`` deploys an [nginx](https://www.nginx.com/) web server that serves the content of the rendered site. As file changes occur Hugo will rebuild the After Dark site and nginx will pick up the changes.
* ``after-dark-service.yaml`` exposes nginx to a [NodePort](https://kubernetes.io/docs/concepts/services-networking/service/#nodeport) so we can actually reach the site from a browser.

@@ -64,14 +64,14 @@ AD_POD=$(kubectl get pods -l app=after-dark-hugo -o jsonpath='{.items[0].metadat
* Create a new post

```sh
kubectl exec $AD_POD -- hugo new post/new-post.md
kubectl exec $AD_POD -- hugo -c flying-toasters/content/post new new-post.md
```

* Apply custom styling

```sh
kubectl exec $AD_POD -- mkdir assets
kubectl exec $AD_POD -- mkdir assets/css
kubectl exec $AD_POD -- mkdir flying-toasters/assets
kubectl exec $AD_POD -- mkdir flying-toasters/assets/css
kubectl cp custom.css $AD_POD:/after-dark/flying-toasters/assets/css/
```

@@ -92,13 +92,13 @@ $ kubectl exec $AD_POD -- hugo -d /output
* Edit your posts

```sh
kubectl exec -it $AD_POD -- vi content/post/my-post.md
kubectl exec -it $AD_POD -- vi flying-toasters/content/post/new-post.md
```

or write your post locally then push it to your pod.
```sh
kubectl cp hello-world.md $AD_POD:content/post
kubectl cp hello-world.md $AD_POD:flying-toasters/content/post
```

Make sure you've got your [front matter](https://gohugo.io/content-management/front-matter/) right.
@@ -106,13 +106,13 @@ Make sure you've got your [front matter](https://gohugo.io/content-management/fr
* Edit Hugo's config.toml

```sh
kubectl exec -it $AD_POD -- vi config.toml
kubectl exec -it $AD_POD -- vi flying-toasters/config.toml
```

* Backup your posts. Create a backup folder locally on your host then

```sh
kubectl cp $AD_POD:content/post backup/
kubectl cp $AD_POD:flying-toasters/content/post backup/
```

* Check the stream of logs for troubleshooting

+ 1
- 24
after-dark-k3s-hugo.yaml View File

@@ -17,7 +17,7 @@ spec:
tier: backend
spec:
containers:
- image: tkalpakid/after-dark-themed-hugo-64-v2 #use this image for hugo configmap tkalpakid/after-dark-hugo-64-conf
- image: tkalpakid/ad8
name: after-dark-hugo-container
ports:
- containerPort: 1313
@@ -27,31 +27,8 @@ spec:
volumeMounts:
- name: rendered-site
mountPath: /output
- name: repo
mountPath: /after-dark
# uncomment below if you want to use configmap for hugo config
# - name: hugo-config
# mountPath: /config.toml
# subPath: config.toml
initContainers:
- name: init-repo
image: alpine/git
command:
- git
- "clone"
- "https://git.habd.as/teowood/after-dark.git"
- "/after-dark/."
volumeMounts:
- name: repo
mountPath: /after-dark
volumes:
- name: repo
emptyDir: {}
- name: rendered-site
hostPath:
path: /rendered-site
type: DirectoryOrCreate
# uncomment below if you want to use configmap for hugo config
# - name: hugo-config
# configMap:
# name: config-toml

+ 9
- 7
dockerfiles/hugo/Dockerfile View File

@@ -2,11 +2,13 @@
FROM alpine:latest

LABEL description="Docker container for building static sites with the Hugo static site generator."
LABEL maintainer="Johannes Mitlmeier <dev.jojomi@yahoo.com>"

# config
ENV HUGO_VERSION=0.55.5
#ENV HUGO_TYPE=
ENV HUGO_TYPE=_extended
ENV HUGO_VERSION=0.53
ENV HUGO_TYPE=
ENV HUGO_WATCH=true
#ENV HUGO_TYPE=_extended

COPY ./run.sh /run.sh
ENV HUGO_ID=hugo${HUGO_TYPE}_${HUGO_VERSION}
@@ -24,11 +26,11 @@ RUN apk add --update git asciidoctor libc6-compat libstdc++ \
&& apk add --no-cache ca-certificates \
&& chmod 0777 /run.sh

# VOLUME /src
#VOLUME /after-dark/flying-toasters
VOLUME /src
VOLUME /output

WORKDIR /after-dark/flying-toasters
WORKDIR /after-dark
CMD ["/run.sh"]

#EXPOSE 1313
EXPOSE 1313

+ 5
- 2
dockerfiles/hugo/run.sh View File

@@ -11,7 +11,11 @@ echo "ARGS" $@

HUGO=/usr/local/sbin/hugo
echo "Hugo path: $HUGO"
/after-dark/bin/install .

git clone https://git.habd.as/comfusion/after-dark.git .
./bin/install
kill $(ps aux | awk '/[h]ugo.*1313/ {print $1}')

while [ true ]
do
if [[ $HUGO_WATCH != 'false' ]]; then
@@ -28,4 +32,3 @@ do
echo "Sleeping for $HUGO_REFRESH_TIME seconds..."
sleep $SLEEP
done


Loading…
Cancel
Save