Add local content
This commit is contained in:
75
content/posts/zola-website-deployment-with-drone-ci/index.md
Normal file
75
content/posts/zola-website-deployment-with-drone-ci/index.md
Normal file
@ -0,0 +1,75 @@
|
||||
+++
|
||||
title = "Zola website deployment with Drone CI"
|
||||
date = 2022-09-28
|
||||
|
||||
[taxonomies]
|
||||
categories = ["Linux"]
|
||||
|
||||
[extra]
|
||||
author = "Emil Miler"
|
||||
+++
|
||||
|
||||
NOTE: This article is outdated and superseded by [native Gitea Actions](@/posts/zola-deployment-with-gitea-actions-and-rsync/index.md).
|
||||
|
||||
Zola is my SSG of choice, as it it fast, powerful and packed in a single statically linked binary. Here is how I use with in conjunction with Drone CI for automatic building and deployment to my webserver.
|
||||
|
||||
<!-- more -->
|
||||
|
||||
I have written a [bachelor's thesis](https://git.microlab.space/em/bakalarka) on static site generators and implementing a sample website with Zola in particular. Where my thesis lacks, though, is in the automatic deployment, where I glued together some Git hooks and shell scripts. It works fairly well, but it does not provide much feedback or code validity checks.
|
||||
|
||||
## Pipeline
|
||||
|
||||
We start with a simple header in which we define the basics.
|
||||
|
||||
```yaml
|
||||
kind: pipeline
|
||||
name: default
|
||||
|
||||
steps:
|
||||
```
|
||||
|
||||
The Drone pipeline has two main parts -- build and deployment. Best way of building the source is by pulling the [official Zola container from ghcr](https://github.com/getzola/zola/pkgs/container/zola). Since the container does not have a shell, we need to use `entrypoint` and `command` options, instead of a set of shell commands.
|
||||
|
||||
```yaml
|
||||
- name: build
|
||||
image: ghcr.io/getzola/zola:v0.16.1
|
||||
entrypoint: [ "/bin/zola" ]
|
||||
command: [ "build" ]
|
||||
```
|
||||
|
||||
Deployment is done using [drone-rsync](https://plugins.drone.io/plugins/rsync) plugin, which handles connection to a remove webserver and can work with private keys via Drone secrets, which we configure later.
|
||||
|
||||
```yaml
|
||||
- name: deploy
|
||||
image: drillster/drone-rsync
|
||||
settings:
|
||||
hosts: [ "0x45.cz" ]
|
||||
user: drone
|
||||
source: public/*
|
||||
target: /srv/www/em.0x45.cz
|
||||
recursive: true
|
||||
delete: true
|
||||
environment:
|
||||
RSYNC_KEY:
|
||||
from_secret: rsync_key
|
||||
```
|
||||
|
||||
## Webserver configuration
|
||||
|
||||
The server needs a new user with write access to the website root directory.
|
||||
|
||||
```sh
|
||||
useradd drone
|
||||
mkdir -p /srv/www/em.0x45.cz
|
||||
chown drone:drone /srv/www/em.0x45.cz
|
||||
```
|
||||
|
||||
## SSH keys
|
||||
|
||||
Create a keypair for SSH connection from Drone to our deployment server.
|
||||
|
||||
```sh
|
||||
ssh-keygen -t ed25519
|
||||
```
|
||||
|
||||
Public key has to be added to `~/.ssh/authorized_keys` of *drone* user on our webserver. The private key has to be inserted to Drone as a secret. This can be easily done trough the web UI, or [by using commands](https://docs.drone.io/cli/secret/drone-secret-add/). The secret name has to match `from_secret` option, so in our case: `rsync_key`. Drone can then easily authenticate and push content to our webroot.
|
@ -0,0 +1,38 @@
|
||||
+++
|
||||
title = "Zola website deployment with Drone CI"
|
||||
date = 2022-09-28
|
||||
|
||||
[taxonomies]
|
||||
categories = ["Linux"]
|
||||
|
||||
[extra]
|
||||
author = "Emil Miler"
|
||||
+++
|
||||
|
||||
Zola is my SSG of choice, as it it fast, powerfull and packed in a single statically linked binary. Here is how I use with in conjuction with Drone CI for automatic building and deployment to my webserver.
|
||||
|
||||
<!-- more -->
|
||||
|
||||
I have written a [bechelor's thesis](https://git.microlab.space/em/bakalarka) on static site generators and implementing a sample website with Zola in particular. Where my thesis lacks, though, is in the automatic deployment, where I botched together some Git hooks and shell scripts. It works fairly well, but it does not provide much feedback or code validity checks.
|
||||
|
||||
## Pipeline
|
||||
|
||||
The Drone pipeline has two main parts -- building and deployment itself. I chose to download a fixed version of Zola insted of using pre-made Docker images, because they were acting out during my testing. As of today, prebuilt Zola binaries still don't work with [musl libc](https://musl.libc.org/), so a Glibc based image is needed, such as Debian instead of Alpine.
|
||||
|
||||
Deployment is done using [drone-rsync](https://plugins.drone.io/plugins/rsync) plugin, whcich handles connection to a remove webserver and handles private keys via Drone secrets.
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
## Webserver configuration
|
||||
|
||||
```
|
||||
create user
|
||||
create website directory
|
||||
check permissions
|
||||
```
|
||||
## SSH keys
|
||||
|
||||
```
|
||||
ssh-keygen -t rsa -b 4096
|
||||
```
|
Reference in New Issue
Block a user