From e2c6c4c1a020bfec3788cc7f2c2249070aafe122 Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Fri, 7 Jun 2019 13:32:02 -0700 Subject: [PATCH 1/4] Straightforward build without layer caching --- Dockerfile | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6099b3b175..eb58f8f1a5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,13 @@ FROM haskell:8.6 as build WORKDIR /build -RUN cabal new-update -# Build our upstream dependencies after copying in only enough to tell cabal -# what they are. This will make these layers cache better even as we change the -# code of semantic itself. -COPY semantic.cabal . -COPY cabal.project . -COPY semantic-core/semantic-core.cabal ./semantic-core/ -COPY vendor ./vendor -RUN cabal new-build --only-dependencies +RUN cabal new-update -# Once the dependencies are built, copy in the rest of the code and compile -# semantic itself. -COPY . /build -RUN cabal new-build semantic:exe:semantic +COPY . . +RUN cabal new-build --flags="release" semantic:exe:semantic # A fake `install` target until we can get `cabal new-install` to work -RUN cp $(find dist-newstyle -name semantic -type f -perm -u=x) /usr/local/bin/semantic +RUN cp $(find dist-newstyle/build/x86_64-linux -name semantic -type f -perm -u=x) /usr/local/bin/semantic # Create a fresh image containing only the compiled CLI program, so that the # image isn't bulked up by all of the extra build state. From c62a7accf5b3091f7a35bf89dc40e8e38d3d25ea Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Mon, 10 Jun 2019 13:18:08 -0700 Subject: [PATCH 2/4] OK, try layer caching again now that we don't submodule --- .dockerignore | 7 +++++++ Dockerfile | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index 94143827ed..957715c603 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,8 @@ Dockerfile +.licenses +.ghc.environment.x86_64-darwin-8.6.5 + +/bin +/dist-newstyle +/notices +/docs diff --git a/Dockerfile b/Dockerfile index eb58f8f1a5..067fc7a0a9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,14 @@ FROM haskell:8.6 as build WORKDIR /build -RUN cabal new-update +# Build and cache the dependencies first so we can cache these layers. +COPY semantic.cabal . +COPY semantic-core semantic-core +RUN cabal new-update hackage.haskell.org,HEAD +RUN cabal new-configure semantic semantic-core +RUN cabal new-build --only-dependencies +# Copy in and build the entire project COPY . . RUN cabal new-build --flags="release" semantic:exe:semantic From 5a9d649a7bbe59e95126c8e945d545574232b169 Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Mon, 10 Jun 2019 16:06:01 -0700 Subject: [PATCH 3/4] Script to make publishing docker image easier --- script/publish | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 script/publish diff --git a/script/publish b/script/publish new file mode 100755 index 0000000000..52d4b2fb34 --- /dev/null +++ b/script/publish @@ -0,0 +1,26 @@ +#!/bin/bash +#/ Usage: script/publish +#/ +#/ Build a docker image of the semantic CLI and publish to the GitHub Package Registry + +set -e +cd $(dirname "$0")/.. + +VERSION="0.6.0" +BUILD_SHA=$(git rev-parse HEAD 2>/dev/null) +DOCKER_IMAGE=docker.pkg.github.com/github/semantic/semantic + +# Build +docker build -t $DOCKER_IMAGE . + +# Make sure semantic is in the image. +docker run --rm $DOCKER_IMAGE --version + +# Requires that you've logged in to the GPR (e.g. `docker login docker.pkg.github.com`) +# https://help.github.com/en/articles/configuring-docker-for-use-with-github-package-registry +docker tag $DOCKER_IMAGE $DOCKER_IMAGE:latest +docker tag $DOCKER_IMAGE $DOCKER_IMAGE:$VERSION +docker tag $DOCKER_IMAGE $DOCKER_IMAGE:sha_$BUILD_SHA +docker push $DOCKER_IMAGE:latest +docker push $DOCKER_IMAGE:$VERSION +docker push $DOCKER_IMAGE:sha_$BUILD_SHA From 15f6889158dc3c67712da95830afe960f0dfc867 Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Mon, 10 Jun 2019 16:07:47 -0700 Subject: [PATCH 4/4] Do the latest tag last --- script/publish | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/publish b/script/publish index 52d4b2fb34..7cc20e5105 100755 --- a/script/publish +++ b/script/publish @@ -21,6 +21,6 @@ docker run --rm $DOCKER_IMAGE --version docker tag $DOCKER_IMAGE $DOCKER_IMAGE:latest docker tag $DOCKER_IMAGE $DOCKER_IMAGE:$VERSION docker tag $DOCKER_IMAGE $DOCKER_IMAGE:sha_$BUILD_SHA -docker push $DOCKER_IMAGE:latest -docker push $DOCKER_IMAGE:$VERSION docker push $DOCKER_IMAGE:sha_$BUILD_SHA +docker push $DOCKER_IMAGE:$VERSION +docker push $DOCKER_IMAGE:latest