From 3d2cad2213404b6c6d17fbb8a7420364331b261a Mon Sep 17 00:00:00 2001 From: DRAGONTOS Date: Sun, 7 Apr 2024 20:57:03 +0200 Subject: [PATCH] docker: converted it to a compose file and removed run.sh --- README.md | 60 ------------------------------- docker-compose.yml | 23 ++++++++++++ entrypoint.sh | 69 ------------------------------------ Dockerfile => pve/Dockerfile | 0 run.sh | 45 ----------------------- srv/pve/.envs | 3 ++ 6 files changed, 26 insertions(+), 174 deletions(-) create mode 100644 docker-compose.yml delete mode 100644 entrypoint.sh rename Dockerfile => pve/Dockerfile (100%) delete mode 100755 run.sh create mode 100644 srv/pve/.envs diff --git a/README.md b/README.md index 85088ec..8b13789 100644 --- a/README.md +++ b/README.md @@ -1,61 +1 @@ -> [!WARNING] -> **Maybe something is not working, use this image with caution, bad things can happens. YHBW** - -# Proxmox VE on a Docker container -Proxmox Virtual Environment on a Docker container - -## Known limits -* **Postfix is not working** -* (and maybe many other things) - -## How to run -`./run.sh` ;-) -What does [run.sh](run.sh) do: -* set docker ENV vars if they are set in the script or in the `.envs` file -* set shell script vars if they are set in the script or in the `.shell-vars` file (see [example](#environment-variables)) -* check if datastore exists; if not, it exit prior tu run the container (maybe in future i'll make it more smart, see [To DO](#to-do) section) -* run the container - -or -`docker run -d --name pve neomediatech/pve` - -## Environment Variables -| Name | Description | Default | -| ------------------- | --------------------------------------------------------------- | --------------- | -| ADMIN_PASSWORD | Password to access PVE web interface (mandatory) | (none) | -| RELAY_HOST | Hostname to use to relay email from Postfix (NOT WORKING!) | | -| PVE_ENTERPRISE | If set to "yes", enterprise repository will be retained | no | -| ENABLE_PVE_FIREWALL | If set to "no", PVE firewall service will be disabled | yes | - -Set vars in `run.sh` script and/or set them in `.envs` file. -Example `.envs` file: -``` -ADMIN_PASSWORD=myrealsecretpassword -RELAY_HOST=10.40.50.4 -``` -## run.sh script shell vars -| Name | Description | Default -| ------------------- | --------------------------------------------------------------- | --------------- -| INTERACTIVE | Run the container in "interactive mode" (run it in foreground)
CTRL+C will end the container | no -| NAME | Proxmox VE name | pve -| BASE_PATH | Path where to store PVE configurations, users, etc... | /srv/pve - -`.shell-vars` example file: -``` -NAME="myserver-pve" -BASE_PATH="/srv/pve" -INTERACTIVE="no" -``` -## Mountpoints/volumes -Put your docker bindmount in the script [run.sh](run.sh) or in the `.volumes` file -`.volumes` example file: -``` -${BASE_PATH}/data/logs:/var/log -${BASE_PATH}/data/pve_cluster:/var/lib/pve-cluster -${BASE_PATH}/data/pve_manager:/var/lib/pve-manager -${BASE_PATH}/data/bin:/srv/bin -``` - -## To DO -- [ ] Make Postfix working, to send emails diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..8b661dc --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,23 @@ +services: + pveowo: + image: neomediatech/pve:latest + #build: ./minecraft-docker + #command: ["java", "-Xmx2048M", "-jar", "server.jar", "true"] + privileged: true + env_file: + - .env + devices: + - "/dev/kvm" + - "/dev/fuse" + #OPTIONS="$OPTIONS --privileged --device /dev/fuse --device=/dev/kvm --add-host $NAME:127.0.0.1" + extra_hosts: + - "pveowo:127.0.0.1" + volumes: + - "./data:/root/minecraft" + - "./data/logs:/var/log" + - "./data/pve_cluster:/var/lib/pve-cluster" + - "./data/pve_manager:/var/lib/pve-manager" + - "./data/bin:/srv/bin" + ports: + - "8006:8006" + restart: always diff --git a/entrypoint.sh b/entrypoint.sh deleted file mode 100644 index 06141f7..0000000 --- a/entrypoint.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash -set -eo pipefail -shopt -s nullglob - -# logging functions -pve_log() { - local type="$1"; shift - printf '%s [%s] [Entrypoint]: %s\n' "$(date --rfc-3339=seconds)" "$type" "$*" -} -pve_note() { - pve_log Note "$@" -} -pve_warn() { - pve_log Warn "$@" >&2 -} -pve_error() { - pve_log ERROR "$@" >&2 - exit 1 -} - -# Verify that the minimally required password settings are set for new databases. -docker_verify_minimum_env() { - if [ -z "$ADMIN_PASSWORD" ]; then - pve_error $'Password option is not specified\n\tYou need to specify an ADMIN_PASSWORD' - fi -} - -docker_setup_pve() { - #Set pve user - echo "root:$ADMIN_PASSWORD"|chpasswd -} - -RELAY_HOST=${RELAY_HOST:-ext.home.local} -sed -i "s/RELAY_HOST/$RELAY_HOST/" /etc/postfix/main.cf -PVE_ENTERPRISE=${PVE_ENTERPRISE:-no} -if [ "$PVE_ENTERPRISE" != "yes" ]; then - rm -f /etc/apt/sources.list.d/pve-enterprise.list -fi - -docker_verify_minimum_env - -# Start api first in background -#echo -n "Starting Proxmox VE API..." -#/usr/lib/x86_64-linux-gnu/proxmox-backup/proxmox-backup-api & -#while true; do -# if [ ! -f /run/proxmox-backup/api.pid ]; then -# echo -n "..." -# sleep 3 -# else -# break -# fi -#done -#echo "OK" - -docker_setup_pve - -if [ ! -d /var/log/pveproxy ]; then - mkdir -p /var/log/pveproxy - chmod 777 /var/log/pveproxy -fi - -if [ -n "$ENABLE_PVE_FIREWALL" -a "$ENABLE_PVE_FIREWALL" == "no" ]; then - systemctl mask pve-firewall.service -fi - -echo "Running PVE..." -exec "$@" -#exec gosu backup /usr/lib/x86_64-linux-gnu/proxmox-backup/proxmox-backup-proxy "$@" - diff --git a/Dockerfile b/pve/Dockerfile similarity index 100% rename from Dockerfile rename to pve/Dockerfile diff --git a/run.sh b/run.sh deleted file mode 100755 index 6c7b6f7..0000000 --- a/run.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash -# shell vars set here will be overridden by same shell vars set in $BASE_PATH/.shell-vars file -BASE_PATH="/srv/pve" -IMAGE="neomediatech/pve:latest" -#IMAGE="pve" -NAME="pve" -VOLUMES="" # volumes set here will be added to volumes found in $BASE_PATH/.volumes file (if it exists) -PORTS="-p 8006:8006" -OPTIONS="" -OPTIONS="$OPTIONS --privileged --device /dev/fuse --device=/dev/kvm --add-host $NAME:127.0.0.1" -OPTIONS="$OPTIONS --tmpfs /tmp --tmpfs /run --tmpfs /run/lock --cgroupns private" -ENVS="" # vars set here will override same vars in $BASE_PATH/.env file -ENTRYPOINT="" -#ENTRYPOINT="--entrypoint /bin/bash" -INTERACTIVE="no" - -if [ -f $BASE_PATH/.shell-vars ]; then - source $BASE_PATH/.shell-vars -fi - -if [ -f $BASE_PATH/.volumes ]; then - for VOLUME in $(cat $BASE_PATH/.volumes); do - VOLUMES="$VOLUMES -v $(eval "echo $VOLUME")" - done -fi - -if [ -f $BASE_PATH/.env ]; then - ENVS="--env-file $BASE_PATH/.env $ENVS" -fi - -if [ "$INTERACTIVE" == "yes" ]; then - RUN_OPTIONS="-it" -else - RUN_OPTIONS="-d" -fi - -echo "Stopping existing Proxmox VE instances..." -docker stop $NAME 2>/dev/null -echo "Deleting old Proxmox VE instances..." -docker rm $NAME 2>/dev/null -echo "Pulling new version of Proxmox VE Docker image..." -docker pull $IMAGE 2>/dev/null -echo "Starting Proxmox VE..." -docker run $RUN_OPTIONS $PORTS --name $NAME --hostname $NAME $OPTIONS $VOLUMES $ENVS $ENTRYPOINT $IMAGE - diff --git a/srv/pve/.envs b/srv/pve/.envs new file mode 100644 index 0000000..0ab53b6 --- /dev/null +++ b/srv/pve/.envs @@ -0,0 +1,3 @@ +ADMIN_PASSWORD=nyaowo +RELAY_HOST=10.40.50.4 +PVE_ENTERPRISE=no