graphql-engine/server/Makefile

81 lines
2.7 KiB
Makefile
Raw Normal View History

2018-06-27 16:11:32 +03:00
project := graphql-engine
registry := hasura
VERSION ?= $(shell ../scripts/get-version.sh)
export VERSION
nproc := $(shell nproc)
2018-06-27 16:11:32 +03:00
# TODO: needs to be replaced with something like yq
stack_resolver := $(shell awk '/^resolver:/ {print $$2;}' stack.yaml)
packager_ver := 20190326
pg_dump_ver := 11
project_dir := $(shell pwd)
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
build:
stack build --fast --ghc-options '-j$(nproc)'
exec: build
stack exec graphql-engine -- serve
exec-local-console: build-local-console
stack exec graphql-engine -- serve --enable-console --console-assets-dir ../console/static/dist
2018-06-27 16:11:32 +03:00
image: $(project).cabal
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
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
# assumes this is built in circleci
ci-binary:
mkdir -p packaging/build/rootfs
stack $(STACK_FLAGS) build $(BUILD_FLAGS)
2018-07-10 13:01:02 +03:00
mkdir -p $(build_output)
cp $(build_dir)/$(project)/$(project) $(build_output)
# cp "$(build_dir)/$(project)-test/$(project)-test" $(build_output)
echo "$(VERSION)" > $(build_output)/version.txt
ci-test:
$(build_output)/graphql-engine-test --database-url=$(DATABASE_URL)
# 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)
cp /usr/lib/postgresql/$(pg_dump_ver)/bin/pg_dump packaging/build/rootfs/bin/pg_dump
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)
2018-07-10 13:01:02 +03:00
ci-load-image:
docker load -i $(build_output)/image.tar
2018-07-17 20:00:26 +03:00
push:
docker push $(registry)/$(project):$(VERSION)
2018-06-27 16:11:32 +03:00
2018-07-17 20:00:26 +03:00
push-latest:
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/
.PHONY: 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