zz
This commit is contained in:
13
binhost.sh
13
binhost.sh
@@ -9,6 +9,7 @@ CTX="${WORK_DIR}/ctx"
|
|||||||
IMAGE="docker.io/gentoo/stage3:amd64-desktop-openrc"
|
IMAGE="docker.io/gentoo/stage3:amd64-desktop-openrc"
|
||||||
CONTAINER_NAME="gentoo_builder"
|
CONTAINER_NAME="gentoo_builder"
|
||||||
PROFILE="default/linux/amd64/23.0/desktop"
|
PROFILE="default/linux/amd64/23.0/desktop"
|
||||||
|
LOG_FILE="/var/log/gentoo_build.log" # inside container
|
||||||
|
|
||||||
if [[ ! -d "$REPO/.git" ]]; then
|
if [[ ! -d "$REPO/.git" ]]; then
|
||||||
git clone "$REPO_URL" "$REPO"
|
git clone "$REPO_URL" "$REPO"
|
||||||
@@ -92,7 +93,8 @@ podman cp "$CTX/var/lib/portage/world" "$CONTAINER_NAME":/var/lib/portage/world
|
|||||||
|
|
||||||
echo "Starting Builder..."
|
echo "Starting Builder..."
|
||||||
|
|
||||||
podman exec -i "$CONTAINER_NAME" /bin/bash <<EOF
|
cat <<EOF | podman exec -i "$CONTAINER_NAME" sh -c "cat > /usr/local/bin/run_job.sh"
|
||||||
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
source /etc/profile
|
source /etc/profile
|
||||||
|
|
||||||
@@ -115,7 +117,14 @@ emerge --verbose --usepkg --buildpkg \
|
|||||||
echo "Cleaning up.."
|
echo "Cleaning up.."
|
||||||
emerge --depclean
|
emerge --depclean
|
||||||
emaint binhost --fix
|
emaint binhost --fix
|
||||||
|
echo "[$(date)] Build Finished successfully."
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo "Build complete."
|
echo "Triggering build in background..."
|
||||||
|
|
||||||
|
podman exec -d "$CONTAINER_NAME" bash -c "chmod +x /usr/local/bin/run_job.sh && /usr/local/bin/run_job.sh > $LOG_FILE 2>&1"
|
||||||
|
|
||||||
|
echo "Build is running in the background."
|
||||||
|
echo "To view progress, run:"
|
||||||
|
echo " podman exec -it $CONTAINER_NAME tail -f $LOG_FILE"
|
||||||
|
|
||||||
|
|||||||
17
serve.sh
17
serve.sh
@@ -2,17 +2,17 @@
|
|||||||
|
|
||||||
WEB_CONTAINER="gentoo_binhost_server"
|
WEB_CONTAINER="gentoo_binhost_server"
|
||||||
WEB_PORT="8080"
|
WEB_PORT="8080"
|
||||||
|
VOLUME_NAME="binpkgs"
|
||||||
|
|
||||||
echo "Checking Web Server..."
|
podman volume inspect "$VOLUME_NAME" >/dev/null 2>&1 || podman volume create "$VOLUME_NAME"
|
||||||
|
|
||||||
if ! podman container exists "$WEB_CONTAINER"; then
|
if ! podman container exists "$WEB_CONTAINER"; then
|
||||||
echo "Starting Nginx binhost server on port $WEB_PORT..."
|
echo "Creating Nginx binhost server on port $WEB_PORT..."
|
||||||
|
|
||||||
podman run -d \
|
podman run -d \
|
||||||
--name "$WEB_CONTAINER" \
|
--name "$WEB_CONTAINER" \
|
||||||
--restart always \
|
--restart always \
|
||||||
-p "$WEB_PORT":80 \
|
-p "$WEB_PORT":80 \
|
||||||
-v binpkgs:/usr/share/nginx/html:ro \
|
-v "$VOLUME_NAME":/usr/share/nginx/html:ro \
|
||||||
nginx:alpine \
|
nginx:alpine \
|
||||||
/bin/sh -c '
|
/bin/sh -c '
|
||||||
echo "server {
|
echo "server {
|
||||||
@@ -23,6 +23,11 @@ if ! podman container exists "$WEB_CONTAINER"; then
|
|||||||
}
|
}
|
||||||
}" > /etc/nginx/conf.d/default.conf && nginx -g "daemon off;"'
|
}" > /etc/nginx/conf.d/default.conf && nginx -g "daemon off;"'
|
||||||
else
|
else
|
||||||
podman start "$WEB_CONTAINER" >/dev/null 2>&1
|
if [ "$(podman container inspect -f '{{.State.Running}}' "$WEB_CONTAINER")" != "true" ]; then
|
||||||
echo "Server is running at http://localhost:$WEB_PORT"
|
echo "Starting existing server..."
|
||||||
|
podman start "$WEB_CONTAINER"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Binhost serving at http://localhost:$WEB_PORT"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user