From 1b88465f3fd6c7639e089958d6d5f9d283d44587 Mon Sep 17 00:00:00 2001 From: Florian Brinker Date: Thu, 22 Apr 2021 22:27:46 +0200 Subject: [PATCH] Add Download to Dockerfile for more transparency --- .drone.yml | 7 +++---- Dockerfile | 11 +++++++++-- build.sh | 27 ++++++--------------------- 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/.drone.yml b/.drone.yml index ce25073..654a099 100644 --- a/.drone.yml +++ b/.drone.yml @@ -4,14 +4,13 @@ type: docker name: default steps: -- name: build +- name: Build Dockerfile image: alpine commands: - - apk update && apk add bash grep sed curl unzip jq - - chmod +x ./build.sh + - apk update && apk add bash curl grep jq sed - ./build.sh -- name: docker +- name: Build & Publish Image image: plugins/docker settings: repo: fbrinker/tileboard diff --git a/Dockerfile b/Dockerfile index 2979407..d89199f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,15 @@ FROM python:alpine LABEL maintainer="mail+docker@f-brinker.de" -# Insert Tileboard -COPY ./files/ /tileboard/ +# Install wget +RUN apk update \ + && apk add ca-certificates wget unzip \ + && update-ca-certificates + +# Download TileBoard +RUN wget -q -O release.zip "%RELEASE_URL%" \ + && unzip release.zip -d /tileboard/ \ + && rm release.zip # Start Server WORKDIR /tileboard diff --git a/build.sh b/build.sh index 696f499..a15ba23 100755 --- a/build.sh +++ b/build.sh @@ -9,13 +9,12 @@ getVersionFromLatestRelease() { echo "$version" } -downloadLatestRelease() { +getDownloadUrl() { 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} + echo "$url" } getLatestPublishedTag() { @@ -32,7 +31,7 @@ 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 + #exit 78 # drone.io exit code to stop but success the pipeline fi SEMVER=( ${LATEST_RELEASE//./ } ) @@ -42,21 +41,7 @@ PATCH=$LATEST_RELEASE echo "latest,$MAJOR,$MINOR,$PATCH" > .tags -downloadLatestRelease "files.zip" +RELEASE_URL=`getDownloadUrl` -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 \ No newline at end of file +echo "Writing $RELEASE_URL into Dockerfile..." +sed -i "s|%RELEASE_URL%|$RELEASE_URL|g" ./Dockerfile