From a59d521a962bb4d8743502ce49bb011eab9c8e3c Mon Sep 17 00:00:00 2001 From: Juan Facorro Date: Sun, 8 Oct 2017 00:22:12 +0200 Subject: [PATCH 1/3] Add prod rebar profile --- rebar.config | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rebar.config b/rebar.config index 2f4ed10..2817cbc 100644 --- a/rebar.config +++ b/rebar.config @@ -22,3 +22,5 @@ , {extended_start_script, true} ] }. + +{profiles, [{prod, [{relx, [{dev_mode, false}, {include_erts, true}]}]}]}. From 5504265e0908437779c164289376e0fb1bee9c55 Mon Sep 17 00:00:00 2001 From: Juan Facorro Date: Sun, 8 Oct 2017 02:10:17 +0200 Subject: [PATCH 2/3] Build release inside docker --- Dockerfile | 16 +++++----------- Makefile | 20 ++++++++++++++++++++ rebar.config | 11 ++++++++++- scripts/build | 11 +++++++++++ 4 files changed, 46 insertions(+), 12 deletions(-) create mode 100644 Makefile create mode 100755 scripts/build diff --git a/Dockerfile b/Dockerfile index 9bcd28e..de10818 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,7 @@ -FROM jfacorro/clojerl:armhf-alpine +FROM arm32v6/alpine:3.6 -# Install build deps -RUN apk add --no-cache --virtual .try-clojerl-build-deps git make \ - # Checkout - && git clone --depth 1 https://github.com/clojerl/try_clojerl try_clojerl \ - && cd try_clojerl \ - && rebar3 clojerl compile \ - && rebar3 release \ - # Clean deps - && apk del .try-clojerl-build-deps +RUN apk add --update ncurses openssl -ENTRYPOINT /try_clojerl/_build/default/rel/try_clojerl/bin/try_clojerl foreground +COPY _build/prod/rel/try_clojerl /opt/try_clojerl + +ENTRYPOINT /opt/try_clojerl/bin/try_clojerl foreground diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5e02317 --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +.PHONY: all + +BUILD_IMAGE = jfacorro/erlang:20.1.1-armhf-alpine +DOCKER_REPO = jfacorro/try_clojerl +DOCKER_TAG = $(shell git describe --tags 2>/dev/null || echo 0) + +all: + rebar3 clojerl compile + +release: all + rebar3 as prod release + +docker-build: + @ docker run -i \ + -v ${PWD}:/project \ + -w /project \ + ${BUILD_IMAGE} scripts/build + +docker: docker-build + @ docker build -t ${DOCKER_REPO}:${DOCKER_TAG} . diff --git a/rebar.config b/rebar.config index 2817cbc..38accfb 100644 --- a/rebar.config +++ b/rebar.config @@ -23,4 +23,13 @@ ] }. -{profiles, [{prod, [{relx, [{dev_mode, false}, {include_erts, true}]}]}]}. +{ profiles +, [ { prod + , [ {relx, [{dev_mode, false}, {include_erts, true}]} + , { provider_hooks + , [{post, [{compile, {clojerl, compile}}]}] + } + ] + } + ] +}. diff --git a/scripts/build b/scripts/build new file mode 100755 index 0000000..c1a716d --- /dev/null +++ b/scripts/build @@ -0,0 +1,11 @@ +#!/bin/sh + +# Install deps +apk add --update git make wget + +# Install rebar3 +wget https://s3.amazonaws.com/rebar3/rebar3 && chmod +x rebar3 +mv rebar3 /usr/local/bin/rebar3 + +# Build release +make release From b728433f932a418a23d67ec8f2f40b6ac7590307 Mon Sep 17 00:00:00 2001 From: Juan Facorro Date: Sun, 8 Oct 2017 14:58:16 +0200 Subject: [PATCH 3/3] Always get something out of git describe so we can tag the docker image with the SHA at least --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5e02317..d4c01b6 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ BUILD_IMAGE = jfacorro/erlang:20.1.1-armhf-alpine DOCKER_REPO = jfacorro/try_clojerl -DOCKER_TAG = $(shell git describe --tags 2>/dev/null || echo 0) +DOCKER_TAG = $(shell git describe --always 2>/dev/null || echo 0) all: rebar3 clojerl compile