Compare commits

...
This repository has been archived on 2021-06-21. You can view files and clone it, but cannot push or open issues or pull requests.

21 Commits

Author SHA1 Message Date
dev-docker 36b39b251d Create a merged branch to deploy 2021-06-21 13:54:37 +00:00
Florian Brinker e89748164b
Merge pull request #5 from akloeckner/feat-arg
feat(RELEASE): allow overriding build.sh
2021-06-04 20:43:50 +02:00
dev-docker 7b8dea218f Create a merged branch to deploy 2021-05-21 06:51:22 +00:00
dev-docker 908898fd98 remove superfluous outputs 2021-05-21 06:51:04 +00:00
dev-docker f46f79bd4e feat(RELEASE): allow overriding build.sh
* add `ARG` for `RELEASE_URL`
* make `build.sh` prepare `.tags` even if tag exists
* add outputs to be used by github workflows
2021-05-20 20:19:36 +00:00
dev-docker 8d55a3741b pass ARG to DEV image 2021-05-20 07:20:48 +00:00
dev-docker e427f472eb debug output devplatform 2021-05-20 07:20:48 +00:00
dev-docker b14337ef0a add $DEVPLATFORM
this adds the above variable to allow building the nightly image on the (fast) native build platform
2021-05-20 07:20:48 +00:00
dev-docker 27d56a92cf add build-base for arm platforms
alpine type build package
2021-05-20 07:20:37 +00:00
dev-docker 540196b488 fix(DEV): add global node-sass
This fixes the case, where you bind-mount your own tileboard source directory into the dev container.

Apparently, the node-sass module is compiled for the specdific machine.
This seems to result in the `node-sass` executable not being found in the container, if the `node_modules` folder was compiled on a different machine (OS?).
By adding node-sass globally in the container, it can be found even with a bind-mounted `tileboard-source` directory.
2021-05-15 13:14:07 +00:00
Florian Brinker 632e04d300
Rename master to main 2021-05-11 21:28:26 +02:00
Florian Brinker 64532c2e07 Move to Github & Github Drone 2021-05-10 22:42:37 +02:00
Florian Brinker 62c33bbc73 Fix script condition 2021-05-10 22:42:30 +02:00
Florian Brinker 7acbe3d55e Fix date handling for ISO8601 dates 2021-05-10 22:03:02 +02:00
akloeckner 6595011075 feature: nightly and dev images (#5)
So, here we go with a PR for the nightly images. **They will need to have a nightly (at least) run of the pipeline.**

I have also included a script and modifications to `drone.yml`, which I believe should serve well as a check-for-changes. But I have no way to check this in your drone environment. ~~And I have not (yet) checked it locally, either. I just copied things over from my GitHub setup.~~ (Update: The script works for me locally.)

Could you have a look and let me know, what needs to be changed from your point of view?

(I don't know Gitea too well... If there's an option to let you write into this feature branch, I'll enable it.)

fixes #4

Co-authored-by: dev-docker <akloeckner@users.noreply.github.com>
Co-authored-by: Florian Brinker <mail+gitlab@f-brinker.de>
Reviewed-on: fbrinker/docker-tileboard#5
Co-authored-by: akloeckner <akloeckner@noreply.example.org>
Co-committed-by: akloeckner <akloeckner@noreply.example.org>
2021-05-10 19:23:50 +00:00
Florian Brinker 569622b11f prepare seperate development pipeline 2021-05-10 18:37:09 +02:00
Florian Brinker 5d14177f58 Change "target" label to "docker" 2021-05-10 18:23:41 +02:00
Florian Brinker 9aaa9acca9 Merge pull request 'fix: make build.sh not rely on tag being latest' (#6) from akloeckner/fbrinker-tileboard:feat-repos into master
Reviewed-on: fbrinker/docker-tileboard#6
2021-05-10 16:11:01 +00:00
Florian Brinker f3e64254f5 Merge branch 'master' into feat-repos 2021-05-10 16:10:24 +00:00
dev-docker 6aec325301 fix: make build.sh not rely on tag being latest
This introduces:
* an explicit check for the existence of the latest version tag
  * This way, we don't need to bother to have `nightly` or `dev` tags in place. The new check works by `curl` failing, if the target tag does not exist.
* more verbose output
  * This was just for debugging actually, but I believe it might help in the future.
* input parameters to the `build.sh` script
  * This allows for using the script also from other repos. I'd like to keep trying things without having to ask you for checking in Drone.io...
2021-05-10 15:17:20 +00:00
Florian Brinker 30d493b87a Add license 2021-05-09 21:45:13 +00:00
7 changed files with 158 additions and 30 deletions

View File

@ -1,7 +1,7 @@
---
kind: pipeline
type: docker
name: default
name: Production
steps:
- name: Build Dockerfile
@ -14,6 +14,7 @@ steps:
image: plugins/docker
settings:
repo: fbrinker/tileboard
dockerfile: Dockerfile
username:
from_secret: docker_username
password:
@ -21,4 +22,44 @@ steps:
trigger:
branch:
- master
- main
---
kind: pipeline
type: docker
name: Development
steps:
- name: Check for changes in master branch
image: alpine
commands:
- apk update && apk add bash curl grep jq sed
- ./check-master-for-changes.sh
- name: Build & Publish Development Image
image: plugins/docker
settings:
repo: fbrinker/tileboard
dockerfile: Dockerfile.nightly
target: dev
tags: dev
username:
from_secret: docker_username
password:
from_secret: docker_password
- name: Build & Publish Nightly Image
image: plugins/docker
settings:
repo: fbrinker/tileboard
dockerfile: Dockerfile.nightly
target: nightly
tags: nightly
username:
from_secret: docker_username
password:
from_secret: docker_password
trigger:
branch:
- main

View File

@ -7,11 +7,12 @@ RUN apk update \
&& update-ca-certificates
# Download TileBoard
RUN wget -q -O release.zip "%RELEASE_URL%" \
ARG RELEASE_URL
RUN wget -q -O release.zip "${RELEASE_URL:-%RELEASE_URL%}" \
&& unzip release.zip -d /tileboard/ \
&& rm release.zip
# Start Server
WORKDIR /tileboard
EXPOSE 8000
ENTRYPOINT python3 -m http.server
ENTRYPOINT python3 -m http.server

41
Dockerfile.nightly Normal file
View File

@ -0,0 +1,41 @@
## DEVELOPMENT IMAGE
ARG DEVPLATFORM=${TARGETPLATFORM:-linux/amd64}
FROM --platform=$DEVPLATFORM node:15-alpine AS dev
# Install pre-requisites
ARG DEVPLATFORM
RUN echo DEVPLATFORM: $DEVPLATFORM \
&& case $DEVPLATFORM in \
*arm*) apk add --no-cache git python3 build-base ;; \
*) apk add --no-cache git python3 ;; \
esac
# Fetch and build tileboard master branch
RUN mkdir /tileboard-source \
&& cd /tileboard-source/ \
&& git clone https://github.com/resoai/TileBoard . \
&& git checkout -b my-patch origin/master \
&& mkdir /tileboard \
&& ln -s /tileboard build \
&& yarn install \
&& npm install --global node-sass \
&& yarn run build
# Start Server
WORKDIR /tileboard
EXPOSE 8000
EXPOSE 8080
ENTRYPOINT ["/bin/sh", "-c", "yarn --cwd /tileboard-source run dev & python3 -m http.server"]
## NIGHTLY BUILD IMAGE
FROM python:alpine AS nightly
# Copy contents from dev image
COPY --from=dev /tileboard /tileboard
# Start Server
WORKDIR /tileboard
EXPOSE 8000
ENTRYPOINT python3 -m http.server

9
LICENSE.md Normal file
View File

@ -0,0 +1,9 @@
MIT License
Copyright (c)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,6 +1,6 @@
# 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)
[![Build Status](https://drone-github.f-brinker.de/api/badges/fbrinker/docker-tileboard/status.svg)](https://drone-github.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".
@ -9,10 +9,10 @@ It contains the sources and starts a simple Python3 webserver to serve TileBoard
### Contribute
You can open any new issues [here](https://git.f-brinker.de/fbrinker/docker-tileboard/issues).
You can open any new issues [here](https://github.com/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).
Have a look at the [Dockerfile](https://github.com/fbrinker/docker-tileboard).
## Usage
@ -21,11 +21,18 @@ You have to mount your `config.js` file into the `/tileboard` directory of the D
## 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
* `fbrinker/tileboard` *(same as :latest)*
* `fbrinker/tileboard:latest`
* `fbrinker/tileboard:2`
* `fbrinker/tileboard:2.2`
* `fbrinker/tileboard:2.2.0`
### Nightly/Dev-Builds
Additionally, there are `nightly` and `dev` builds as follows:
* `fbrinker/tileboard:nightly` contains a nightly build of TileBoard's `master` branch. Use it to have the most bleeding edge changes, which have not made it into a release yet.
* `fbrinker/tileboard:dev` bundles TileBoard's source code and runs `yarn run dev` inside the container. Use it to modify the source, check your changes into GitHub and propose a pull request to TileBoard. See the TileBoard [contribution page](https://github.com/resoai/TileBoard/blob/master/CONTRIBUTING.md) for details.
## Example

View File

@ -1,38 +1,37 @@
#!/usr/bin/env bash
getVersionFromLatestRelease() {
version=`curl -s "https://api.github.com/repos/resoai/TileBoard/releases/latest" \
repo="${1-resoai/TileBoard}"
version=`curl -s "https://api.github.com/repos/$repo/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" \
repo="${1-resoai/TileBoard}"
url=`curl -s "https://api.github.com/repos/$repo/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"
docker_tag_exists() {
repo="${1-fbrinker/tileboard}"
tag="${2-latest}"
curl --silent -f -lSL "https://hub.docker.com/v2/repositories/$repo/tags/$tag" > /dev/null 2>&1
}
LATEST_RELEASE=`getVersionFromLatestRelease`
LATEST_TAG=`getLatestPublishedTag`
source_repo="${1-resoai/TileBoard}"
docker_repo="${2-fbrinker/tileboard}"
echo "Source repository: $source_repo."
echo "Docker repository: $docker_repo."
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
LATEST_RELEASE=`getVersionFromLatestRelease $source_repo`
echo "Latest release is: $LATEST_RELEASE."
SEMVER=( ${LATEST_RELEASE//./ } )
MAJOR=${SEMVER[0]}
@ -42,6 +41,13 @@ PATCH=$LATEST_RELEASE
echo "latest,$MAJOR,$MINOR,$PATCH" > .tags
RELEASE_URL=`getDownloadUrl`
echo "URL of release is: $RELEASE_URL."
echo "::set-output name=release_url::$RELEASE_URL"
echo "Writing $RELEASE_URL into Dockerfile..."
if docker_tag_exists $docker_repo $LATEST_RELEASE; then
echo "Nothing to do. Latest release tag already exists."
exit 78 # drone.io exit code to stop but success the pipeline
fi
echo "Writing release URL into Dockerfile..."
sed -i "s|%RELEASE_URL%|$RELEASE_URL|g" ./Dockerfile

23
check-master-for-changes.sh Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env bash
docker_tag_exists() {
repo="${1-fbrinker/tileboard}"
tag="${2-nightly}"
curl --silent -f -lSL "https://hub.docker.com/v2/repositories/$repo/tags/$tag" > /dev/null 2>&1
}
commitdate=$(curl -sL "https://api.github.com/repos/resoai/TileBoard/commits/master" | jq -r ".commit.author.date" | sed 's/T/ /; s/Z//')
commitdays=$(( ( $(date --utc +%s) - $(date --utc -d "$commitdate" +%s) ) / 86400 ))
echo "Last commit was $commitdate and is $commitdays days ago."
if [ $commitdays -lt 2 ]; then
echo "Found recent commits in the repository."
echo "Continuing with pipeline..."
elif ! docker_tag_exists; then
echo "Missing an nightly build."
echo "Continuing with pipeline..."
else
echo "No recent commits found."
echo "Aborting pipeline."
exit 78 # drone.io exit code to stop but success the pipeline
fi