2018-06-27 16:11:32 +03:00
|
|
|
project := graphql-engine
|
|
|
|
registry := hasura
|
2018-07-02 16:56:10 +03:00
|
|
|
version := $(shell ../scripts/get-version.sh)
|
2018-06-27 16:11:32 +03:00
|
|
|
|
2018-07-02 16:56:10 +03:00
|
|
|
stack_resolver := lts-11.15
|
2018-07-03 20:10:13 +03:00
|
|
|
packager_ver := 1.1
|
|
|
|
project_dir := $(shell pwd)
|
|
|
|
build_dir := $(project_dir)/$(shell stack --system-ghc path --dist-dir)/build
|
2018-06-27 16:11:32 +03:00
|
|
|
|
2018-07-10 13:01:02 +03:00
|
|
|
build_output := /build/_server_output
|
|
|
|
|
2018-06-27 16:11:32 +03:00
|
|
|
image: $(project).cabal
|
2018-07-02 16:56:10 +03:00
|
|
|
docker build -t "$(registry)/$(project):$(version)" \
|
|
|
|
-f packaging/Dockerfile \
|
|
|
|
--build-arg build_flags=--fast \
|
|
|
|
--build-arg project=$(project) \
|
|
|
|
--build-arg stack_resolver=$(stack_resolver) \
|
|
|
|
--build-arg packager_version=$(packager_ver) \
|
|
|
|
.
|
2018-06-27 16:11:32 +03:00
|
|
|
|
|
|
|
release-image: $(project).cabal
|
2018-07-02 16:56:10 +03:00
|
|
|
docker build -t "$(registry)/$(project):$(version)" \
|
|
|
|
-f packaging/Dockerfile \
|
|
|
|
--build-arg project=$(project) \
|
|
|
|
--build-arg stack_resolver=$(stack_resolver) \
|
|
|
|
--build-arg packager_version=$(packager_ver) \
|
|
|
|
.
|
2018-06-27 16:11:32 +03:00
|
|
|
|
2018-07-03 20:10:13 +03:00
|
|
|
# assumes this is built in circleci
|
2018-07-11 10:13:07 +03:00
|
|
|
ci-binary-and-test: $(project).cabal
|
2018-07-03 20:10:13 +03:00
|
|
|
mkdir -p packaging/build/rootfs
|
2018-07-11 10:13:07 +03:00
|
|
|
stack test --coverage --test-arguments --database-url=$(DATABASE_URL)
|
2018-07-10 13:01:02 +03:00
|
|
|
mkdir -p $(build_output)
|
|
|
|
cp $(build_dir)/$(project)/$(project) $(build_output)
|
|
|
|
echo "$(version)" > $(build_output)/version.txt
|
2018-07-03 20:10:13 +03:00
|
|
|
|
|
|
|
# assumes this is built in circleci
|
|
|
|
ci-image:
|
|
|
|
docker create -v /root/ --name dummy alpine:3.4 /bin/true
|
|
|
|
docker cp $(build_dir)/$(project)/$(project) dummy:/root/
|
|
|
|
docker run --rm --volumes-from dummy $(registry)/graphql-engine-packager:$(packager_ver) /build.sh $(project) | tar -x -C packaging/build/rootfs
|
|
|
|
strip --strip-unneeded packaging/build/rootfs/bin/$(project)
|
|
|
|
upx packaging/build/rootfs/bin/$(project)
|
|
|
|
docker build -t $(registry)/$(project):$(version) packaging/build/
|
|
|
|
|
2018-07-10 13:01:02 +03:00
|
|
|
ci-save-image:
|
|
|
|
docker save -o $(build_output)/image.tar $(registry)/$(project):$(version)
|
|
|
|
|
|
|
|
ci-load-image:
|
|
|
|
docker load -i $(build_output)/image.tar
|
2018-07-03 20:10:13 +03:00
|
|
|
|
2018-06-27 16:11:32 +03:00
|
|
|
push: $(project).cabal
|
2018-07-02 16:56:10 +03:00
|
|
|
docker push $(registry)/$(project):$(version)
|
2018-06-27 16:11:32 +03:00
|
|
|
|
|
|
|
packager: packaging/packager.df
|
|
|
|
docker build -t "$(registry)/graphql-engine-packager:$(packager_ver)" -f packaging/packager.df ./packaging/
|
2018-07-02 16:56:10 +03:00
|
|
|
|
2018-07-11 10:13:07 +03:00
|
|
|
.PHONY: image release-image push packager ci-binary-and-test ci-image ci-save-image ci-load-image
|