docker: converted it to a compose file and removed run.sh

This commit is contained in:
Kaley, Fischer 2024-04-07 20:57:03 +02:00
parent ac9927528e
commit 3d2cad2213
6 changed files with 26 additions and 174 deletions

View file

@ -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) <br /> 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

23
docker-compose.yml Normal file
View file

@ -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

View file

@ -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 "$@"

45
run.sh
View file

@ -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

3
srv/pve/.envs Normal file
View file

@ -0,0 +1,3 @@
ADMIN_PASSWORD=nyaowo
RELAY_HOST=10.40.50.4
PVE_ENTERPRISE=no