Skip to content

Commit 2af822f

Browse files
committed
Added makefile
1 parent 084357f commit 2af822f

File tree

5 files changed

+48
-2
lines changed

5 files changed

+48
-2
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
*node_modules
44
*.pyc
55
go-iris/vendor
6+
haskell-spock/build/rootfs

haskell-spock/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ RUN stack install text
1313
COPY . /usr/src/app
1414
RUN pwd
1515
RUN stack build --fast
16-
CMD stack exec haskell-spock-exe
16+
CMD stack exec haskell-spock

haskell-spock/Makefile

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Check that given variables are set and all have non-empty values,
2+
# die with an error otherwise.
3+
#
4+
# Params:
5+
# 1. Variable name(s) to test.
6+
# 2. (optional) Error message to print.
7+
check_defined = \
8+
$(strip $(foreach 1,$1, \
9+
$(call __check_defined,$1,$(strip $(value 2)))))
10+
__check_defined = \
11+
$(if $(value $1),, \
12+
$(error $1$(if $2, ($2)) is not set))
13+
14+
project := haskell-spock
15+
registry := hasura
16+
packager_ver := 1.0
17+
18+
project_dir := $(shell pwd)
19+
build_dir := $(project_dir)/$(shell stack --docker path --dist-dir)/build
20+
version := $(shell grep -oP '^version:\s*\K.*' $(project).cabal)
21+
22+
build-dir: $(project).cabal
23+
@:$(call check_defined, IMAGE_VERSION IMAGE_REPO STACK_FLAGS)
24+
stack $(STACK_FLAGS) build $(BUILD_FLAGS)
25+
mkdir -p build/rootfs
26+
docker run --rm -v $(build_dir)/$(project)/$(project):/root/$(project) $(registry)/notif-packager:$(packager_ver) /build.sh $(project) | tar -x -C build/rootfs
27+
28+
image: $(project).cabal
29+
@:$(call check_defined, IMAGE_VERSION IMAGE_REPO STACK_FLAGS)
30+
make build-dir STACK_FLAGS=$(STACK_FLAGS) IMAGE_REPO=$(IMAGE_REPO) IMAGE_VERSION=$(IMAGE_VERSION)
31+
docker build -t $(IMAGE_REPO)/$(project):$(IMAGE_VERSION) build/
32+
33+
release-image: $(project).cabal
34+
@:$(call check_defined, IMAGE_VERSION IMAGE_REPO STACK_FLAGS)
35+
make build-dir STACK_FLAGS=$(STACK_FLAGS) IMAGE_REPO=$(IMAGE_REPO) IMAGE_VERSION=$(IMAGE_VERSION)
36+
upx --best build/rootfs/bin/$(project)
37+
docker build -t $(IMAGE_REPO)/$(project):$(IMAGE_VERSION) build/
38+
39+
push: $(project).cabal
40+
@:$(call check_defined, IMAGE_VERSION IMAGE_REPO)
41+
docker push $(IMAGE_REPO)/$(project):$(IMAGE_VERSION)

haskell-spock/build/Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM scratch
2+
COPY rootfs/ /
3+
4+
CMD naarad

haskell-spock/haskell-spock.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ library
2020
build-depends: base >= 4.7 && < 5
2121
default-language: Haskell2010
2222

23-
executable haskell-spock-exe
23+
executable haskell-spock
2424
hs-source-dirs: app
2525
main-is: Main.hs
2626
ghc-options: -threaded -rtsopts -with-rtsopts=-N

0 commit comments

Comments
 (0)