Add CI/build workflows, Dockerfile, nginx config, update README
This commit is contained in:
parent
682b3c2182
commit
44023d8ad2
5 changed files with 93 additions and 7 deletions
|
|
@ -1,13 +1,25 @@
|
|||
name: Build and Push Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- 'content/**'
|
||||
- 'static/**'
|
||||
- 'templates/**'
|
||||
- 'themes/**'
|
||||
- 'config.toml'
|
||||
- 'docker/Dockerfile'
|
||||
- 'docker/nginx.conf'
|
||||
- '.forgejo/workflows/build.yml'
|
||||
tags: ['v*']
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: catthehacker/ubuntu:act-latest
|
||||
|
||||
steps:
|
||||
- uses: https://data.forgejo.org/actions/checkout@v4
|
||||
with:
|
||||
|
|
@ -26,11 +38,21 @@ jobs:
|
|||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||
|
||||
- name: Determine tags
|
||||
id: meta
|
||||
run: |
|
||||
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
|
||||
TAG="${{ github.ref_name }}"
|
||||
echo "tags=forge.lvl0.xyz/lvl0/lvl0-website:${TAG},forge.lvl0.xyz/lvl0/lvl0-website:latest" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "tags=forge.lvl0.xyz/lvl0/lvl0-website:latest" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Build and push
|
||||
uses: https://data.forgejo.org/docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: .docker/Dockerfile
|
||||
file: docker/Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: forge.lvl0.xyz/lvl0/lvl0-website:latest
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
|
|
|
|||
29
.forgejo/workflows/ci.yml
Normal file
29
.forgejo/workflows/ci.yml
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: catthehacker/ubuntu:act-latest
|
||||
|
||||
steps:
|
||||
- uses: https://data.forgejo.org/actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Install Zola
|
||||
run: |
|
||||
curl -sL https://github.com/getzola/zola/releases/download/v0.21.0/zola-v0.21.0-x86_64-unknown-linux-gnu.tar.gz \
|
||||
| tar xz -C /usr/local/bin
|
||||
|
||||
- name: Build
|
||||
run: zola build
|
||||
|
||||
- name: Check links
|
||||
run: zola check --skip-external-links
|
||||
14
README.md
14
README.md
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
## Production
|
||||
|
||||
This is the docker-compose file needed to host this webiste:
|
||||
Pull and run the image with Docker Compose:
|
||||
|
||||
```
|
||||
```yaml
|
||||
services:
|
||||
website:
|
||||
image: forge.lvl0.xyz/lvl0/lvl0-website:latest
|
||||
|
|
@ -12,13 +12,17 @@ services:
|
|||
ports:
|
||||
- 5002:80
|
||||
restart: unless-stopped
|
||||
networks: {}
|
||||
```
|
||||
|
||||
The image is built and pushed automatically on every push to `main`.
|
||||
|
||||
## Development
|
||||
|
||||
Run zola:
|
||||
Enter the nix-shell, then start the dev server:
|
||||
|
||||
```sh
|
||||
zola serve
|
||||
nix-shell
|
||||
dev-up
|
||||
```
|
||||
|
||||
Site will be available at `http://localhost:1111` with live reload.
|
||||
|
|
|
|||
16
docker/Dockerfile
Normal file
16
docker/Dockerfile
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
FROM catthehacker/ubuntu:act-latest AS builder
|
||||
ARG TARGETARCH
|
||||
WORKDIR /site
|
||||
RUN case "$TARGETARCH" in \
|
||||
amd64) ARCH="x86_64-unknown-linux-gnu" ;; \
|
||||
arm64) ARCH="aarch64-unknown-linux-gnu" ;; \
|
||||
*) echo "Unsupported architecture: $TARGETARCH" && exit 1 ;; \
|
||||
esac && \
|
||||
curl -sL "https://github.com/getzola/zola/releases/download/v0.21.0/zola-v0.21.0-${ARCH}.tar.gz" \
|
||||
| tar xz -C /usr/local/bin
|
||||
COPY . .
|
||||
RUN zola build
|
||||
|
||||
FROM nginx:alpine
|
||||
COPY --from=builder /site/public /usr/share/nginx/html
|
||||
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
15
docker/nginx.conf
Normal file
15
docker/nginx.conf
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
server {
|
||||
listen 80;
|
||||
server_name lvl0.xyz;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
|
||||
location ~* \.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue