2018-06-27 16:11:32 +03:00
|
|
|
project := graphql-engine
|
|
|
|
registry := hasura
|
2019-04-11 07:11:48 +03:00
|
|
|
VERSION ?= $(shell ../scripts/get-version.sh)
|
|
|
|
export VERSION
|
|
|
|
nproc := $(shell nproc)
|
2018-06-27 16:11:32 +03:00
|
|
|
|
2018-08-08 10:40:13 +03:00
|
|
|
# TODO: needs to be replaced with something like yq
|
2019-02-19 09:50:54 +03:00
|
|
|
stack_resolver := $(shell awk '/^resolver:/ {print $$2;}' stack.yaml)
|
2019-09-24 13:22:50 +03:00
|
|
|
packager_ver := 20190923
|
2019-10-26 20:03:54 +03:00
|
|
|
pg_dump_ver := 12
|
2018-07-03 20:10:13 +03:00
|
|
|
project_dir := $(shell pwd)
|
2018-07-26 08:47:21 +03:00
|
|
|
build_dir := $(project_dir)/$(shell stack 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
|
|
|
|
|
2019-04-11 07:11:48 +03:00
|
|
|
build:
|
|
|
|
stack build --fast --ghc-options '-j$(nproc)'
|
|
|
|
|
|
|
|
exec: build
|
|
|
|
stack exec graphql-engine -- serve
|
|
|
|
|
|
|
|
exec-local-console: build-local-console
|
2019-05-16 10:45:29 +03:00
|
|
|
stack exec graphql-engine -- serve --enable-console --console-assets-dir ../console/static/dist
|
2018-11-23 16:02:46 +03:00
|
|
|
|
2018-06-27 16:11:32 +03:00
|
|
|
image: $(project).cabal
|
2019-04-11 07:11:48 +03:00
|
|
|
docker build -t "$(registry)/$(project):$(VERSION)" \
|
2018-07-02 16:56:10 +03:00
|
|
|
-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
|
|
|
|
2019-06-27 09:28:26 +03:00
|
|
|
local-image:
|
2019-07-11 08:37:06 +03:00
|
|
|
$(eval build_dir_docker := $(project_dir)/$(shell stack --docker path --dist-dir)/build)
|
2019-06-27 09:28:26 +03:00
|
|
|
stack docker pull
|
|
|
|
stack --docker build --fast
|
|
|
|
mkdir -p packaging/build/rootfs
|
|
|
|
docker run --rm -v "$(build_dir_docker)/$(project)/$(project):/root/$(project)" \
|
|
|
|
$(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-06-27 16:11:32 +03:00
|
|
|
release-image: $(project).cabal
|
2019-04-11 07:11:48 +03:00
|
|
|
docker build -t "$(registry)/$(project):$(VERSION)" \
|
2018-07-02 16:56:10 +03:00
|
|
|
-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-26 08:47:21 +03:00
|
|
|
ci-binary:
|
2018-07-03 20:10:13 +03:00
|
|
|
mkdir -p packaging/build/rootfs
|
2019-11-29 08:14:26 +03:00
|
|
|
# --no-terminal for a cleaner output in circleci
|
|
|
|
stack $(STACK_FLAGS) build --no-terminal --test --no-run-tests --ghc-options=-Werror $(BUILD_FLAGS)
|
2018-07-10 13:01:02 +03:00
|
|
|
mkdir -p $(build_output)
|
2019-10-21 19:01:05 +03:00
|
|
|
cp $(build_dir)/$(project)/$(project) $(build_dir)/graphql-engine-tests/graphql-engine-tests $(build_output)
|
2019-04-11 07:11:48 +03:00
|
|
|
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)
|
2019-04-30 11:34:08 +03:00
|
|
|
cp /usr/lib/postgresql/$(pg_dump_ver)/bin/pg_dump packaging/build/rootfs/bin/pg_dump
|
2018-07-03 20:10:13 +03:00
|
|
|
upx packaging/build/rootfs/bin/$(project)
|
2019-04-11 07:11:48 +03:00
|
|
|
docker build -t $(registry)/$(project):$(VERSION) packaging/build/
|
2018-07-03 20:10:13 +03:00
|
|
|
|
2018-07-10 13:01:02 +03:00
|
|
|
ci-save-image:
|
2019-04-11 07:11:48 +03:00
|
|
|
docker save -o $(build_output)/image.tar $(registry)/$(project):$(VERSION)
|
2018-07-10 13:01:02 +03:00
|
|
|
|
|
|
|
ci-load-image:
|
|
|
|
docker load -i $(build_output)/image.tar
|
2018-07-03 20:10:13 +03:00
|
|
|
|
2018-07-17 20:00:26 +03:00
|
|
|
push:
|
2019-04-11 07:11:48 +03:00
|
|
|
docker push $(registry)/$(project):$(VERSION)
|
2018-06-27 16:11:32 +03:00
|
|
|
|
2018-07-17 20:00:26 +03:00
|
|
|
push-latest:
|
2019-04-11 07:11:48 +03:00
|
|
|
docker tag $(registry)/$(project):$(VERSION) $(registry)/$(project):latest
|
2018-07-17 20:00:26 +03:00
|
|
|
docker push $(registry)/$(project):latest
|
|
|
|
|
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
|
|
|
|
2019-06-27 09:28:26 +03:00
|
|
|
.PHONY: image local-image release-image push packager ci-binary-and-test ci-image ci-save-image ci-load-image build exec build-local-console exec-local-console
|