documentation for cicd and dockerfiles how to use them and how to combine them
All checks were successful
Build and Deploy Documentation / build-and-deploy (push) Successful in 8s
All checks were successful
Build and Deploy Documentation / build-and-deploy (push) Successful in 8s
Signed-off-by: Basil Bruhn <basil.bruhn@psi.ch>
This commit is contained in:
54
docs/guides/cicd.md
Normal file
54
docs/guides/cicd.md
Normal file
@@ -0,0 +1,54 @@
|
||||
# CI / CD
|
||||
```
|
||||
name: Build and Deploy Documentation
|
||||
|
||||
# ON ist ein trigger
|
||||
# Kann auch ein Cronjob sein (man cron)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
# Job description - Was soll er tun?
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
# Auf welchem Runner soll er laufen
|
||||
# Werden angesteuert mit tags
|
||||
|
||||
runs-on: ubuntu-latest-intranet
|
||||
container:
|
||||
# Docker in Docker image welches für den job verwendet werden soll
|
||||
image: gitea.psi.ch/images/alpine-mkdocs
|
||||
# Job Schritte
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
# Actions sind hier zu finden: https://github.com/actions
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Zensical
|
||||
run: |
|
||||
/opt/python-env/bin/pip install zensical
|
||||
|
||||
- name: Build Zensical docs
|
||||
run: |
|
||||
export TZ="Europe/Zurich"
|
||||
/opt/python-env/bin/zensical build --clean
|
||||
|
||||
- name: Configure Git
|
||||
run: |
|
||||
git config --global user.name "Gitea Actions"
|
||||
git config --global user.email "actions@gitea.local"
|
||||
|
||||
- name: Push to gitea-pages branch
|
||||
run: |
|
||||
git checkout --orphan gitea-pages
|
||||
git reset --hard
|
||||
cp -r ./site/* .
|
||||
git add .
|
||||
git commit -m "Deploy Zensical site"
|
||||
git push -f https://${{ secrets.GITHUB_TOKEN }}@gitea.psi.ch/${{ github.repository }}.git gitea-pages
|
||||
|
||||
```
|
||||
49
docs/guides/docker.md
Normal file
49
docs/guides/docker.md
Normal file
@@ -0,0 +1,49 @@
|
||||
# Docker
|
||||
|
||||
## Dockerfiles
|
||||
```
|
||||
# Start with a minimal Python base image
|
||||
FROM python:3.12-alpine
|
||||
|
||||
# Install dependencies
|
||||
# Jeder Step (RUN befehl) generiert ein neuer image layer!
|
||||
|
||||
RUN apk add --no-cache git bash nodejs\
|
||||
&& pip install --no-cache-dir \
|
||||
mkdocs \
|
||||
mkdocs-material \
|
||||
mkdocs-mermaid2-plugin \
|
||||
mkdocs-git-revision-date-localized-plugin \
|
||||
mkdocs-macros-plugin
|
||||
# Set work directory
|
||||
# Environment variables -> Lookup :)
|
||||
WORKDIR /site
|
||||
|
||||
# Default command
|
||||
ENTRYPOINT ["mkdocs"]
|
||||
```
|
||||
|
||||
### Altenative
|
||||
|
||||
```
|
||||
FROM alpine
|
||||
|
||||
# 1. Install Python 3, pip and build tools (needed for packages with C extensions)
|
||||
RUN apk --no-cache add\
|
||||
python3 \
|
||||
py3-pip \
|
||||
git \
|
||||
nodejs
|
||||
|
||||
# 2. Install the Python packages
|
||||
RUN python3 -m venv /opt/python-env
|
||||
RUN /opt/python-env/bin/python3 -m pip install --upgrade pip
|
||||
|
||||
RUN /opt/python-env/bin/pip install --no-cache-dir \
|
||||
mkdocs-material \
|
||||
mkdocs-awesome-pages-plugin
|
||||
|
||||
# 3. (Optional) Clean up if you added any temporary files
|
||||
RUN rm -rf /var/cache/apk/*
|
||||
|
||||
```
|
||||
Reference in New Issue
Block a user