A peer-to-peer stack for code collaboration
Create and upload docker image for radicle daemon. (#455)
Julian Arni9c9e28cf5bad
diff --git a/README.md b/README.mdindex 2ff68fe..9a3515e 100644--- a/README.md+++ b/README.md@@ -56,7 +56,7 @@ start up an IPFS test network and the Raicle daemon.docker-compose -f test/docker-compose.yaml up -d ipfs-test-networkRAD_IPFS_API_URL=http://localhost:19301 stack exec -- \- radicle-daemon --machine-config /tmp/radicle-machines.json+ rad-daemon-radicle --machine-config /tmp/radicle-machines.jsonIf you use `docker-compose up` for the first time you will also need toinitialize the IPFS test network withdiff --git a/cloudbuild.yaml b/cloudbuild.yamlindex 10101c4..db4e845 100644--- a/cloudbuild.yaml+++ b/cloudbuild.yaml@@ -107,6 +107,35 @@ steps:env: ["STACK_ROOT=/workspace/.stack"]args: ["stack", "exec", "--", "weeder", "--match"]+ - id: "Build rad-daemon-radicle image"+ waitFor:+ - "Test"+ name: $_BUILD_IMAGE+ entrypoint: bash+ env:+ - COMMIT_SHA=$COMMIT_SHA+ - BRANCH_NAME=$BRANCH_NAME+ args:+ - "-c"+ - |+ set -euxo pipefail++ ./images/rad-daemon-radicle/ci-copy-bin.sh++ image_name="eu.gcr.io/opensourcecoin/rad-daemon-radicle"+ short_sha=$(echo "$COMMIT_SHA" | head --bytes=7)+ # Looks like this: b2018.12.06-a76a52f+ tag="b$(date +%Y.%m.%d)-${short_sha}"+ docker build \+ --tag "$image_name" \+ --cache-from "$image_name" \+ ./images/rad-daemon-radicle+ if [ "$BRANCH_NAME" == "master" ]; then+ docker tag "$image_name" "$image_name:$tag"+ docker push "$image_name"+ docker push "$image_name:$tag"+ fi+- id: "Build reference document"waitFor:- "Build"diff --git a/exe/Daemon.hs b/exe/Daemon.hsindex d3611ce..ac4f01b 100644--- a/exe/Daemon.hs+++ b/exe/Daemon.hs@@ -1,4 +1,4 @@--- | The radicle-daemon; a long-running background process which+-- | The radicle daemon; a long-running background process which-- materialises the state of remote IPFS machines on the user's PC, and-- writes to those IPFS machines the user is an owner of.--@@ -51,7 +51,7 @@ cliInfo = doinfo (opts defaultMachineConfigFile <**> helper)( fullDesc<> progDesc "Run the radicle daemon"- <> header "radicle-daemon"+ <> header "rad-daemon-radicle")opts :: FilePath -> Parser Optsdiff --git a/images/rad-daemon-radicle/.dockerignore b/images/rad-daemon-radicle/.dockerignorenew file mode 100644index 0000000..720e3c1--- /dev/null+++ b/images/rad-daemon-radicle/.dockerignore@@ -0,0 +1,2 @@+*+!/bindiff --git a/images/rad-daemon-radicle/.gitignore b/images/rad-daemon-radicle/.gitignorenew file mode 100644index 0000000..5e56e04--- /dev/null+++ b/images/rad-daemon-radicle/.gitignore@@ -0,0 +1 @@+/bindiff --git a/images/rad-daemon-radicle/Dockerfile b/images/rad-daemon-radicle/Dockerfilenew file mode 100644index 0000000..8a4a6ee--- /dev/null+++ b/images/rad-daemon-radicle/Dockerfile@@ -0,0 +1,16 @@+FROM debian:stretch+# The distribution must be the same one the binary is build with to+# ensure binary compatibility. We use the `haskell` images on CI and+# `fpco/stack-build` with when building with `stack build --docker`.++RUN apt-get -qq update && \+ apt-get install -y libgmp10 && \+ rm -rf /var/lib/apt/lists/*++ADD ./ /++# Executing the binary ensures that all linked libraries are present+RUN rad-daemon-radicle --help >/dev/null++EXPOSE 8000+CMD ["/bin/rad-daemon-radicle"]diff --git a/images/rad-daemon-radicle/build.sh b/images/rad-daemon-radicle/build.shnew file mode 100755index 0000000..20e1c80--- /dev/null+++ b/images/rad-daemon-radicle/build.sh@@ -0,0 +1,15 @@+#!/bin/bash++set -eo pipefail++image_root=$(dirname $0)++echo "Building rad-daemon-radicle in container"+stack build --docker :rad-daemon-radicle++bin_path=$(stack exec --docker -- which rad-daemon-radicle)++mkdir -p "$image_root/bin"+cp -a "$bin_path" "$image_root/bin"++docker build -t eu.gcr.io/opensourcecoin/rad-daemon-radicle $image_rootdiff --git a/images/rad-daemon-radicle/ci-copy-bin.sh b/images/rad-daemon-radicle/ci-copy-bin.shnew file mode 100755index 0000000..6078d4a--- /dev/null+++ b/images/rad-daemon-radicle/ci-copy-bin.sh@@ -0,0 +1,14 @@+#!/bin/bash++set -eo pipefail++image_root=$(dirname $BASH_SOURCE)++if [ "$STACK_DOCKER" = "1" ]; then+ bin_path=$(stack exec --docker -- which rad-daemon-radicle)+else+ bin_path=$(stack exec -- which rad-daemon-radicle)+fi++mkdir -p "$image_root/bin"+cp -a "$bin_path" "$image_root/bin"diff --git a/nix/shell.nix b/nix/shell.nixindex af35b22..8eccd5e 100644--- a/nix/shell.nix+++ b/nix/shell.nix@@ -29,7 +29,7 @@ stdenv.mkDerivation {alias mkdocs="pushd $PWD/docs && make html && popd"alias sb="stack build --fast"alias se="stack exec"- alias sbd="stack build --fast radicle:exe:radicle-daemon"+ alias sbd="stack build --fast radicle:exe:rad-daemon-radicle"alias sbrad="stack build --fast radicle:exe:radicle"alias st="stack test --fast"alias sts="stack test --fast radicle:spec"