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
|
name: Build and Push Docker Image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
paths:
|
||||||
|
- 'content/**'
|
||||||
|
- 'static/**'
|
||||||
|
- 'templates/**'
|
||||||
|
- 'themes/**'
|
||||||
|
- 'config.toml'
|
||||||
|
- 'docker/Dockerfile'
|
||||||
|
- 'docker/nginx.conf'
|
||||||
|
- '.forgejo/workflows/build.yml'
|
||||||
|
tags: ['v*']
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
container:
|
container:
|
||||||
image: catthehacker/ubuntu:act-latest
|
image: catthehacker/ubuntu:act-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: https://data.forgejo.org/actions/checkout@v4
|
- uses: https://data.forgejo.org/actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
|
|
@ -26,11 +38,21 @@ jobs:
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
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
|
- name: Build and push
|
||||||
uses: https://data.forgejo.org/docker/build-push-action@v5
|
uses: https://data.forgejo.org/docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: .docker/Dockerfile
|
file: docker/Dockerfile
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
push: true
|
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
|
## Production
|
||||||
|
|
||||||
This is the docker-compose file needed to host this webiste:
|
Pull and run the image with Docker Compose:
|
||||||
|
|
||||||
```
|
```yaml
|
||||||
services:
|
services:
|
||||||
website:
|
website:
|
||||||
image: forge.lvl0.xyz/lvl0/lvl0-website:latest
|
image: forge.lvl0.xyz/lvl0/lvl0-website:latest
|
||||||
|
|
@ -12,13 +12,17 @@ services:
|
||||||
ports:
|
ports:
|
||||||
- 5002:80
|
- 5002:80
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
networks: {}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The image is built and pushed automatically on every push to `main`.
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
Run zola:
|
Enter the nix-shell, then start the dev server:
|
||||||
|
|
||||||
```sh
|
```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