From 1f146f000879d1d8df7aa75d0029b2d7dbd85f49 Mon Sep 17 00:00:00 2001 From: Graham Garner Date: Thu, 19 Dec 2019 10:06:24 +0200 Subject: [PATCH] Added Python container --- .templates/python/Dockerfile | 9 +++++++++ .templates/python/directoryfix.sh | 10 ++++++++++ .templates/python/service.yml | 7 +++++++ README.md | 3 +-- menu.sh | 3 ++- scripts/update.sh | 14 ++++++++++++++ 6 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 .templates/python/Dockerfile create mode 100755 .templates/python/directoryfix.sh create mode 100644 .templates/python/service.yml diff --git a/.templates/python/Dockerfile b/.templates/python/Dockerfile new file mode 100644 index 00000000..f06fda81 --- /dev/null +++ b/.templates/python/Dockerfile @@ -0,0 +1,9 @@ +FROM python:3 + +WORKDIR /usr/src/app + +COPY requirements.txt ./ + +RUN pip install --no-cache-dir -r requirements.txt + +CMD [ "python", "./app.py" ] \ No newline at end of file diff --git a/.templates/python/directoryfix.sh b/.templates/python/directoryfix.sh new file mode 100755 index 00000000..437d4b45 --- /dev/null +++ b/.templates/python/directoryfix.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Directoryfix for python + +if [ ! -d ./volumes/python/app ]; then + sudo mkdir -p ./volumes/python/app + sudo chown -R pi:pi ./volumes/python + echo 'print("hello world")' >./volumes/python/app/app.py + +fi diff --git a/.templates/python/service.yml b/.templates/python/service.yml new file mode 100644 index 00000000..bcae7877 --- /dev/null +++ b/.templates/python/service.yml @@ -0,0 +1,7 @@ + python: + container_name: python + build: ./services/python/. + restart: unless-stopped + network_mode: host + volumes: + - ./volumes/python/app:/usr/src/app diff --git a/README.md b/README.md index 0b1bf6ed..b59ba57e 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ IOTstack is a builder for docker-compose to easily make and maintain IoT stacks The bulk of the README has moved to the Wiki. Please check it out [here](https://github.com/gcgarner/IOTstack/wiki) +* 2019-12-19 Added python container, tweaked update script * 2019-12-12 modified zigbee2mqtt template file * 2019-12-12 Added Function to add custom containers to the stack * 2019-12-12 PR cmskedgell: Added Homebridge @@ -26,7 +27,6 @@ The bulk of the README has moved to the Wiki. Please check it out [here](https:/ * Node-RED: serial port. New template adds privileged which allows acces to serial devices * EspurinoHub: is available for testing see wiki entry - *** ## Highlighted topics @@ -42,7 +42,6 @@ The bulk of the README has moved to the Wiki. Please check it out [here](https:/ * reverse proxy is now next on the list, I cant keep up with the ports * Detection of arhcitecture for seperate stack options for amd64, armhf, i386 * autocleanup of backups on cloud -* python container * Gitea (in testing branch) * OwnCloud diff --git a/menu.sh b/menu.sh index 99e53179..6c11d62f 100755 --- a/menu.sh +++ b/menu.sh @@ -27,11 +27,12 @@ declare -A cont_array=( [nginx]="NGINX by linuxserver" [diyhue]="diyHue" [homebridge]="Homebridge" + [python]="Python 3" ) declare -a armhf_keys=("portainer" "nodered" "influxdb" "grafana" "mosquitto" "telegraf" "mariadb" "postgres" "adminer" "openhab" "zigbee2mqtt" "pihole" "plex" "tasmoadmin" "rtl_433" "espruinohub" - "motioneye" "webthings_gateway" "blynk_server" "nextcloud" "diyhue" "homebridge") + "motioneye" "webthings_gateway" "blynk_server" "nextcloud" "diyhue" "homebridge" "python") sys_arch=$(uname -m) diff --git a/scripts/update.sh b/scripts/update.sh index e8e56b80..ff796b07 100755 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -1 +1,15 @@ +#!/bin/bash + +echo "Stopping containers" +docker-compose down + +echo "Downloading latest images from docker hub ... this can take a long time" docker-compose pull + +echo "Building images if needed" +docker-compose build + +echo "Starting stack up again" +docker-compose up -d + +echo "Consider running prune-images to free up space"