Browse Source

feat: create compose file and setup script

master
bucde 3 years ago
parent
commit
7aaf0fa26f
2 changed files with 99 additions and 0 deletions
  1. +15
    -0
      docker-compose.yml
  2. +84
    -0
      setup

+ 15
- 0
docker-compose.yml View File

@ -0,0 +1,15 @@
version: "3.2"
services:
portainer:
container_name: ${PORTAINER_CONTAINER_NAME:-portainer}
image: portainer/portainer-ce:${PORTAINER_VERSION:-latest}
restart: always
ports:
- ${PORTAINER_HOST_IP_ADDRESS:-127.0.0.1}:${PORTAINER_HOST_PORT:-9000}:9000
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- data:/data
volumes:
data:

+ 84
- 0
setup View File

@ -0,0 +1,84 @@
#!/bin/bash
echo "####################################################################"
echo "# docker_portainer_setup_script #"
echo "# Dennis Buchhorn - bucde@b-eit.de #"
echo "####################################################################"
echo "# WARNING: password is plain text input! #"
echo "# #"
echo "# Config will be saved in 'config' file. #"
echo "# (everything in plain text, even the password) #"
#echo "# #"
echo "####################################################################"
echo ""
DATE=$(date +'%y%m%d%H%M%S')
CONFIG_EXISTS="false"
USE_EXISTING_CONFIG=""
DELETE_CONFIG=""
PORTAINER_PROJECT_NAME="portainer_${DATE}"
PORTAINER_PROJECT_NAME_SUFFIX=""
PORTAINER_CONTAINER_NAME="${PORTAINER_PROJECT_NAME}_db"
PORTAINER_VERSION=""
PORTAINER_HOST_IP_ADDRESS=""
PORTAINER_HOST_PORT=""
read -p "Enter portainer project name suffix (leave empty for none): " PORTAINER_PROJECT_NAME_SUFFIX
if [ -n "$PORTAINER_PROJECT_NAME_SUFFIX" ]; then
PORTAINER_PROJECT_NAME="${PORTAINER_PROJECT_NAME}_${PORTAINER_PROJECT_NAME_SUFFIX}"
PORTAINER_CONTAINER_NAME="${PORTAINER_CONTAINER_NAME}_${PORTAINER_PROJECT_NAME_SUFFIX}"
fi
rm -f .env
touch .env
echo "COMPOSE_PROJECT_NAME="$PORTAINER_PROJECT_NAME >> .env
echo "PORTAINER_CONTAINER_NAME="$PORTAINER_CONTAINER_NAME >> .env
if [ -f "config" ]; then
CONFIG_EXISTS="true"
read -p "Config file 'config' already exists! Would you like to use this? (y/n)" USE_EXISTING_CONFIG
fi
if [ $CONFIG_EXISTS == "false" ] || [ $USE_EXISTING_CONFIG == "n" ]; then
read -p "Enter portainer version which should be used: " PORTAINER_VERSION
read -p "Enter host (vm) ip address on which portainer should be accessible: " PORTAINER_HOST_IP_ADDRESS
read -p "Enter host (vm) port on which portainer should be accessible: " PORTAINER_HOST_PORT
rm -f config
touch config
echo "PORTAINER_VERSION="$PORTAINER_VERSION >> config
echo "PORTAINER_HOST_IP_ADDRESS="$PORTAINER_HOST_IP_ADDRESS >> config
echo "PORTAINER_HOST_PORT="$PORTAINER_HOST_PORT >> config
echo "Config file 'config' created!"
else
echo "Use existing config file 'config'!"
fi
cat "config" >> ".env"
read -p "Should the config file 'config' be deleted after creating the container? (y/n)" DELETE_CONFIG
docker-compose up -d
echo -n "Wait until portainer is ready ..."
while [[ "$(curl -fLs -w ''%{http_code}'' $PORTAINER_HOST_IP_ADDRESS:$PORTAINER_HOST_PORT -o /dev/null)" != "200" ]] ; do
echo -n "."
sleep 1
done
echo -e "\nPortainer is ready!"
if [ $DELETE_CONFIG == "y" ]; then
rm -f config
echo "Config file 'config' deleted!"
fi
rm -f .env
echo "Done!"

Loading…
Cancel
Save