From 65950110750c613e16ec51f252b99ad0e577e0c7 Mon Sep 17 00:00:00 2001 From: akloeckner Date: Mon, 10 May 2021 19:23:50 +0000 Subject: [PATCH] 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 Co-authored-by: Florian Brinker Reviewed-on: https://git.f-brinker.de/fbrinker/docker-tileboard/pulls/5 Co-authored-by: akloeckner Co-committed-by: akloeckner --- .drone.yml | 42 ++++++++++++++++++++++++++++++++++++- Dockerfile.nightly | 34 ++++++++++++++++++++++++++++++ README.md | 5 +++++ check-master-for-changes.sh | 13 ++++++++++++ 4 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 Dockerfile.nightly create mode 100755 check-master-for-changes.sh diff --git a/.drone.yml b/.drone.yml index da75f90..1641db8 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,7 +1,7 @@ --- kind: pipeline type: docker -name: production +name: Production steps: - name: Build Dockerfile @@ -20,6 +20,46 @@ steps: password: from_secret: docker_password +trigger: + branch: + - master + +--- +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: - master \ No newline at end of file diff --git a/Dockerfile.nightly b/Dockerfile.nightly new file mode 100644 index 0000000..d05e050 --- /dev/null +++ b/Dockerfile.nightly @@ -0,0 +1,34 @@ +## DEVELOPMENT IMAGE +FROM node:15-alpine AS dev + +# Install pre-requisites +RUN apk add --no-cache git python3 + +# 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 \ + && 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 \ No newline at end of file diff --git a/README.md b/README.md index 77903c5..d9b08ae 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,11 @@ Besides the latest version, you can listen to updates for a specific version: * fbrinker/tileboard:2.2 * fbrinker/tileboard:2.2.0 +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 Here is an example, using Docker-Compose: diff --git a/check-master-for-changes.sh b/check-master-for-changes.sh new file mode 100755 index 0000000..8f3c77d --- /dev/null +++ b/check-master-for-changes.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +commitdate=$(curl -sL "https://api.github.com/repos/resoai/TileBoard/commits/master" | jq -r ".commit.author.date") +commitdays=$(( ( $(date --utc +%s) - $(date --utc -d $commitdate +%s) ) / 86400 )) +echo "Last commit was $commitdays days ago." + +if [ $commitdays -lt 2 ] ; then + echo "There ARE recent changes in the repository." +else + echo "There are NO recent changes in the repository." + echo "Aborting pipeline." + exit 78 # drone.io exit code to stop but success the pipeline +fi \ No newline at end of file