Add containers scripts

This commit is contained in:
Mo 2022-08-05 14:02:12 +02:00
parent 373883bc53
commit d6a4e6a462
4 changed files with 102 additions and 0 deletions

27
containers/gitea.fish Executable file
View file

@ -0,0 +1,27 @@
#!/usr/bin/fish
set -l container_name gitea
set -l gitea_data_dir ~/volumes/gitea/data
mkdir -p $gitea_data_dir
buildah rm builder &>/dev/null
buildah from --pull --name builder docker.io/gitea/gitea:latest
buildah run builder -- apk --no-cache --update add asciidoctor
if systemctl --user is-enabled container-$container_name
systemctl --user disable --now container-$container_name
end
if podman image exists $container_name
podman rmi $container_name
end
buildah commit --rm builder $container_name
podman-default-create \
$container_name \
--network traefik \
-p 2222:22 \
-v $gitea_data_dir:/data:Z \
localhost/$container_name:latest

11
containers/nginx.fish Executable file
View file

@ -0,0 +1,11 @@
#!/usr/bin/fish
set -l container_name nginx
podman-default-create \
$container_name \
--network traefik \
-v ~/volumes/$container_name/sites:/volumes/sites:z,ro \
-v ~/sync/volumes/$container_name/conf.d:/etc/nginx/conf.d:Z,ro \
--label "io.containers.autoupdate=registry" \
docker.io/library/nginx:alpine

23
containers/traefik.fish Executable file
View file

@ -0,0 +1,23 @@
#!/usr/bin/fish
set -l container_name traefik
set -l logs_dir ~/volumes/$container_name/logs
set -l certs_dir ~/volumes/$container_name/certs
mkdir -p $logs_dir
mkdir -p $certs_dir
if not podman network exists traefik
podman network create traefik
end
podman-default-create \
$container_name \
--network traefik \
-p 8000:80 \
-p 4430:443 \
-v ~/sync/volumes/$container_name:/etc/traefik:Z,ro \
-v $logs_dir:/volumes/logs:Z \
-v $certs_dir:/volumes/certs:Z \
--label "io.containers.autoupdate=registry" \
docker.io/library/traefik:latest

41
containers/webhook.fish Executable file
View file

@ -0,0 +1,41 @@
#!/usr/bin/fish
set -l container_name webhook
set -l repo_dir ~/code/webhook
buildah rm compiler &>/dev/null
buildah from --pull --name compiler docker.io/library/golang:alpine
buildah copy compiler $repo_dir /src
buildah config --workingdir /src -e GOOS=linux -e GOARCH=amd64 compiler
buildah run compiler -- go build -o /main
buildah rm builder &>/dev/null
buildah from --name builder docker.io/library/alpine:latest
buildah copy --from compiler builder /main /webhook/main
buildah rm compiler
buildah copy builder $repo_dir/secrets.json /webhook
buildah copy builder $HOME/bin/hugo /usr/local/bin/hugo
buildah run builder -- apk --no-cache --update add git git-lfs
buildah run builder -- git lfs install
buildah config --workingdir /webhook -e GIN_MODE=release -e GIN_PORT=80 builder
buildah config --cmd /webhook/main builder
if systemctl --user is-enabled container-$container_name
systemctl --user disable --now container-$container_name
end
if podman image exists $container_name
podman rmi $container_name
end
buildah commit --rm builder $container_name
podman-default-create \
$container_name \
--network traefik \
-v ~/volumes/nginx/sites:/volumes/sites:z \
-v ~/volumes/webhook/repos:/volumes/repos:Z \
localhost/$container_name:latest