1
1
mirror of https://github.com/github/semantic.git synced 2025-01-04 21:47:07 +03:00

Merge pull request #117 from github/build-docker-image

Build (and publish) docker image for the semantic CLI
This commit is contained in:
Timothy Clem 2019-06-11 15:19:31 -07:00 committed by GitHub
commit c97f3582bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 12 deletions

View File

@ -1 +1,8 @@
Dockerfile
.licenses
.ghc.environment.x86_64-darwin-8.6.5
/bin
/dist-newstyle
/notices
/docs

View File

@ -1,23 +1,19 @@
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.
# Build and cache the dependencies first so we can cache these layers.
COPY semantic.cabal .
COPY cabal.project .
COPY semantic-core/semantic-core.cabal ./semantic-core/
COPY vendor ./vendor
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
# 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 in and build the entire project
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.

26
script/publish Executable file
View File

@ -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:sha_$BUILD_SHA
docker push $DOCKER_IMAGE:$VERSION
docker push $DOCKER_IMAGE:latest