From 0bdcdfa673c71b39a6b9cdbfd27a705195a74d19 Mon Sep 17 00:00:00 2001 From: Florian Brinker Date: Sat, 20 Mar 2021 18:28:40 +0100 Subject: [PATCH] Recreate container build and tagging --- .drone.yml | 7 +++++++ .gitignore | 3 +++ Dockerfile | 13 ++++--------- build.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 9 deletions(-) create mode 100644 .gitignore create mode 100644 build.sh diff --git a/.drone.yml b/.drone.yml index b8008f5..6f2a4e2 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,8 +1,15 @@ --- kind: pipeline +type: docker name: default steps: +- name: build + image: alpine + commands: + - apk update && apk add bash grep sed curl unzip + - ./build.sh + - name: docker image: plugins/docker settings: 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 index 6760485..2979407 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,10 @@ FROM python:alpine +LABEL maintainer="mail+docker@f-brinker.de" -MAINTAINER Florian Brinker "mail+docker@f-brinker.de" - -# Install Git -RUN apk update && \ - apk add --no-cache bash git - -# Clone Tileboard -RUN git clone https://github.com/resoai/TileBoard.git /tileboard +# Insert Tileboard +COPY ./files/ /tileboard/ # Start Server WORKDIR /tileboard EXPOSE 8000 -ENTRYPOINT python3 -m http.server +ENTRYPOINT python3 -m http.server \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..13c3035 --- /dev/null +++ b/build.sh @@ -0,0 +1,49 @@ +#!/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" +} + +downloadLatestRelease() { + URL=`curl -s "https://api.github.com/repos/resoai/TileBoard/releases/latest" \ + | grep "browser_download_url" \ + | cut -d '"' -f 4` + echo "Url: $URL" + + curl -sL -o $1 ${URL} +} + +LATEST=`getVersionFromLatestRelease` +SEMVER=( ${LATEST//./ } ) + +MAJOR=${SEMVER[0]} +MINOR=${SEMVER[0]}.${SEMVER[1]} +PATCH=$LATEST + +echo "test,$MAJOR,$MINOR,$PATCH" > .tags + +downloadLatestRelease "files.zip" + +if [ ! -f "./files.zip" ]; then + echo "Download ./files.zip does not exist" + exit 1 +fi + +unzip files.zip -d files + +if [ ! -d "./files" ]; then + echo "Directory ./files does not exist" + exit 1 +fi + +if [ ! -f "./files/index.html" ]; then + echo "File ./files/index.html does not exist" + exit 1 +fi + +exit 1 \ No newline at end of file