From 284b9762f04cec56a07b7fbb45366620a7707ae4 Mon Sep 17 00:00:00 2001 From: riomoo Date: Tue, 3 Feb 2026 23:59:43 -0500 Subject: [PATCH] readme and bashscript moving --- Containerfile | 2 +- README.md | 13 +++- .../building-only/build-labeled-container.sh | 77 +++++++++++++++++++ .../{ => building-only}/build-release.sh | 0 .../{ => building-only}/package-release.sh | 0 scripts-bash/{ => comic-scripts}/cbt.sh | 0 .../{ => comic-scripts}/comic-page-number.sh | 0 .../make-cbz-imagemagick.sh | 0 scripts-bash/{ => comic-scripts}/test-cbt.sh | 0 scripts-bash/run-gb-container/run-docker.sh | 46 +++++++++++ .../run-podman.sh} | 0 11 files changed, 135 insertions(+), 3 deletions(-) create mode 100755 scripts-bash/building-only/build-labeled-container.sh rename scripts-bash/{ => building-only}/build-release.sh (100%) rename scripts-bash/{ => building-only}/package-release.sh (100%) rename scripts-bash/{ => comic-scripts}/cbt.sh (100%) rename scripts-bash/{ => comic-scripts}/comic-page-number.sh (100%) rename scripts-bash/{ => comic-scripts}/make-cbz-imagemagick.sh (100%) rename scripts-bash/{ => comic-scripts}/test-cbt.sh (100%) create mode 100755 scripts-bash/run-gb-container/run-docker.sh rename scripts-bash/{run.sh => run-gb-container/run-podman.sh} (100%) diff --git a/Containerfile b/Containerfile index 0e3bbb9..7a3c8c8 100644 --- a/Containerfile +++ b/Containerfile @@ -29,7 +29,7 @@ RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build \ RUN upx --best --ultra-brute bin/main RUN chmod +x bin/main -FROM cgr.dev/chainguard/static:latest +FROM git.jester-designs.com/riomoo/alisterbase:1.0.0 WORKDIR /app diff --git a/README.md b/README.md index f57ffc8..971e4b0 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,16 @@ Then open http://localhost:8080 in your browser. ```bash git clone https://codeberg.org/riomoo/gopherbook.git cd gopherbook -./scripts-bash/run.sh +./scripts-bash/run-gb-container/run-podman.sh +``` + +or + +## If you want to use this with docker: +```bash +git clone https://codeberg.org/riomoo/gopherbook.git +cd gopherbook +./scripts-bash/run-gb-container/run-docker.sh ``` Then open http://localhost:12010 in your browser. @@ -198,7 +207,7 @@ Please open an issue first for bigger changes. ## If you'd like to know about the new mascot Vinny -- Check the [Wiki](/riomoo/gopherbook/wiki/Meet-Vinny.md)! +- Check the [Wiki](../../wiki)! ## Thanks / Credits diff --git a/scripts-bash/building-only/build-labeled-container.sh b/scripts-bash/building-only/build-labeled-container.sh new file mode 100755 index 0000000..eb33841 --- /dev/null +++ b/scripts-bash/building-only/build-labeled-container.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +IMAGE_NAME="localhost/gopherbook:latest" +CONTAINER_NAME="gopherbook" +VERSION="1.3.000" +BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") +VCS_REF=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown") + +echo "Building new image: $IMAGE_NAME..." +podman build --force-rm -t "${IMAGE_NAME}-temp" \ + --format oci \ + -f Containerfile . + +if [ $? -ne 0 ]; then + echo "Image build failed. Exiting script." + exit 1 +fi + +# Ensure directories exist with correct permissions +mkdir -p ./library ./cache ./etc ./watch + +if podman container exists "$CONTAINER_NAME"; then + echo "Container '$CONTAINER_NAME' already exists. Stopping and removing it..." + podman stop "$CONTAINER_NAME" + podman rm "$CONTAINER_NAME" +fi + +echo "Creating final image with labels in config (no layer)..." + +# Use buildah to modify the image config directly +buildah from --name working-container "${IMAGE_NAME}-temp" + +# Add labels directly to the config (doesn't create a layer!) +buildah config \ + --label "org.opencontainers.image.title=Gopherbook" \ + --label "org.opencontainers.image.description=Gopherbook Minimal Image" \ + --label "org.opencontainers.image.version=${VERSION}" \ + --label "org.opencontainers.image.created=${BUILD_DATE}" \ + --label "org.opencontainers.image.revision=${VCS_REF}" \ + --label "org.opencontainers.image.authors=Alister " \ + --label "org.opencontainers.image.vendor=Jester Designs" \ + --label "org.opencontainers.image.licenses=PIL" \ + --label "com.jesterdesigns.image.type=base-image" \ + --label "com.jesterdesigns.image.purpose=static-binary-runtime" \ + working-container + +# Commit the container to the final image name +buildah commit --format oci working-container "$IMAGE_NAME" + +# Cleanup +buildah rm working-container +podman rmi "${IMAGE_NAME}-temp" + +echo "Starting new container from image: $IMAGE_NAME..." +# IMPROVED: Better memory settings and limits +podman run -d --name "$CONTAINER_NAME" \ + --memory=512m \ + --restart unless-stopped \ + -p 12010:8080 \ + -v ./library:/app/library \ + -v ./cache:/app/cache \ + -v ./etc:/app/etc \ + -v ./watch:/app/watch \ + "$IMAGE_NAME" + +if [ $? -ne 0 ]; then + echo "Failed to start new container. Exiting script." + exit 1 +fi + +echo "Cleaning up old images..." +podman image prune --force + +echo "Update and cleanup complete!" +echo "Container is running with memory limit: 512MB" +echo "Go memory limit (GOMEMLIMIT): 512MiB" +echo "Aggressive GC enabled (GOGC=50)" diff --git a/scripts-bash/build-release.sh b/scripts-bash/building-only/build-release.sh similarity index 100% rename from scripts-bash/build-release.sh rename to scripts-bash/building-only/build-release.sh diff --git a/scripts-bash/package-release.sh b/scripts-bash/building-only/package-release.sh similarity index 100% rename from scripts-bash/package-release.sh rename to scripts-bash/building-only/package-release.sh diff --git a/scripts-bash/cbt.sh b/scripts-bash/comic-scripts/cbt.sh similarity index 100% rename from scripts-bash/cbt.sh rename to scripts-bash/comic-scripts/cbt.sh diff --git a/scripts-bash/comic-page-number.sh b/scripts-bash/comic-scripts/comic-page-number.sh similarity index 100% rename from scripts-bash/comic-page-number.sh rename to scripts-bash/comic-scripts/comic-page-number.sh diff --git a/scripts-bash/make-cbz-imagemagick.sh b/scripts-bash/comic-scripts/make-cbz-imagemagick.sh similarity index 100% rename from scripts-bash/make-cbz-imagemagick.sh rename to scripts-bash/comic-scripts/make-cbz-imagemagick.sh diff --git a/scripts-bash/test-cbt.sh b/scripts-bash/comic-scripts/test-cbt.sh similarity index 100% rename from scripts-bash/test-cbt.sh rename to scripts-bash/comic-scripts/test-cbt.sh diff --git a/scripts-bash/run-gb-container/run-docker.sh b/scripts-bash/run-gb-container/run-docker.sh new file mode 100755 index 0000000..99e7a55 --- /dev/null +++ b/scripts-bash/run-gb-container/run-docker.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +IMAGE_NAME="localhost/gopherbook:latest" +CONTAINER_NAME="gopherbook" + +echo "Building new image: $IMAGE_NAME..." +docker build --force-rm -t "$IMAGE_NAME" . + +if [ $? -ne 0 ]; then + echo "Image build failed. Exiting script." + exit 1 +fi + +# Ensure directories exist with correct permissions +mkdir -p ./library ./cache ./etc ./watch + +if docker container exists "$CONTAINER_NAME"; then + echo "Container '$CONTAINER_NAME' already exists. Stopping and removing it..." + docker stop "$CONTAINER_NAME" + docker rm "$CONTAINER_NAME" +fi + +echo "Starting new container from image: $IMAGE_NAME..." +# IMPROVED: Better memory settings and limits +docker run -d --name "$CONTAINER_NAME" \ + --memory=512m \ + --restart unless-stopped \ + -p 12010:8080 \ + -v ./library:/app/library \ + -v ./cache:/app/cache \ + -v ./etc:/app/etc \ + -v ./watch:/app/watch \ + "$IMAGE_NAME" + +if [ $? -ne 0 ]; then + echo "Failed to start new container. Exiting script." + exit 1 +fi + +echo "Cleaning up old images..." +docker image prune --force + +echo "Update and cleanup complete!" +echo "Container is running with memory limit: 512MB" +echo "Go memory limit (GOMEMLIMIT): 512MiB" +echo "Aggressive GC enabled (GOGC=50)" diff --git a/scripts-bash/run.sh b/scripts-bash/run-gb-container/run-podman.sh similarity index 100% rename from scripts-bash/run.sh rename to scripts-bash/run-gb-container/run-podman.sh