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