Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit c97f358

Browse files
authored
Merge pull request #117 from github/build-docker-image
Build (and publish) docker image for the semantic CLI
2 parents 23e8d3a + e7084c5 commit c97f358

File tree

3 files changed

+41
-12
lines changed

3 files changed

+41
-12
lines changed

.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
11
Dockerfile
2+
.licenses
3+
.ghc.environment.x86_64-darwin-8.6.5
4+
5+
/bin
6+
/dist-newstyle
7+
/notices
8+
/docs

Dockerfile

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
FROM haskell:8.6 as build
22
WORKDIR /build
3-
RUN cabal new-update
43

5-
# Build our upstream dependencies after copying in only enough to tell cabal
6-
# what they are. This will make these layers cache better even as we change the
7-
# code of semantic itself.
4+
# Build and cache the dependencies first so we can cache these layers.
85
COPY semantic.cabal .
9-
COPY cabal.project .
10-
COPY semantic-core/semantic-core.cabal ./semantic-core/
11-
COPY vendor ./vendor
6+
COPY semantic-core semantic-core
7+
RUN cabal new-update hackage.haskell.org,HEAD
8+
RUN cabal new-configure semantic semantic-core
129
RUN cabal new-build --only-dependencies
1310

14-
# Once the dependencies are built, copy in the rest of the code and compile
15-
# semantic itself.
16-
COPY . /build
17-
RUN cabal new-build semantic:exe:semantic
11+
# Copy in and build the entire project
12+
COPY . .
13+
RUN cabal new-build --flags="release" semantic:exe:semantic
1814

1915
# A fake `install` target until we can get `cabal new-install` to work
20-
RUN cp $(find dist-newstyle -name semantic -type f -perm -u=x) /usr/local/bin/semantic
16+
RUN cp $(find dist-newstyle/build/x86_64-linux -name semantic -type f -perm -u=x) /usr/local/bin/semantic
2117

2218
# Create a fresh image containing only the compiled CLI program, so that the
2319
# image isn't bulked up by all of the extra build state.

script/publish

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
#/ Usage: script/publish
3+
#/
4+
#/ Build a docker image of the semantic CLI and publish to the GitHub Package Registry
5+
6+
set -e
7+
cd $(dirname "$0")/..
8+
9+
VERSION="0.6.0"
10+
BUILD_SHA=$(git rev-parse HEAD 2>/dev/null)
11+
DOCKER_IMAGE=docker.pkg.github.com/github/semantic/semantic
12+
13+
# Build
14+
docker build -t $DOCKER_IMAGE .
15+
16+
# Make sure semantic is in the image.
17+
docker run --rm $DOCKER_IMAGE --version
18+
19+
# Requires that you've logged in to the GPR (e.g. `docker login docker.pkg.github.com`)
20+
# https://help.github.com/en/articles/configuring-docker-for-use-with-github-package-registry
21+
docker tag $DOCKER_IMAGE $DOCKER_IMAGE:latest
22+
docker tag $DOCKER_IMAGE $DOCKER_IMAGE:$VERSION
23+
docker tag $DOCKER_IMAGE $DOCKER_IMAGE:sha_$BUILD_SHA
24+
docker push $DOCKER_IMAGE:sha_$BUILD_SHA
25+
docker push $DOCKER_IMAGE:$VERSION
26+
docker push $DOCKER_IMAGE:latest

0 commit comments

Comments
 (0)