make container persistent

This commit is contained in:
2025-12-07 16:53:33 +06:00
parent b6f1a545fe
commit b46968519e
3 changed files with 80 additions and 35 deletions

28
serve.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/bin/sh
WEB_CONTAINER="gentoo_binhost_server"
WEB_PORT="8080"
echo "Checking Web Server..."
if ! podman container exists "$WEB_CONTAINER"; then
echo "Starting Nginx binhost server on port $WEB_PORT..."
podman run -d \
--name "$WEB_CONTAINER" \
--restart always \
-p "$WEB_PORT":80 \
-v binpkgs:/usr/share/nginx/html:ro \
nginx:alpine \
/bin/sh -c '
echo "server {
listen 80;
root /usr/share/nginx/html;
location / {
autoindex on;
}
}" > /etc/nginx/conf.d/default.conf && nginx -g "daemon off;"'
else
podman start "$WEB_CONTAINER" >/dev/null 2>&1
echo "Server is running at http://localhost:$WEB_PORT"
fi