2020-01-18 01:07:15 +03:00
|
|
|
|
SHELL := /bin/bash
|
|
|
|
|
|
|
|
|
|
VERSION ?= $(shell ../scripts/get-version.sh)
|
2019-04-11 07:11:48 +03:00
|
|
|
|
export VERSION
|
2018-06-27 16:11:32 +03:00
|
|
|
|
|
2020-01-18 01:07:15 +03:00
|
|
|
|
registry := hasura
|
2021-02-23 20:37:27 +03:00
|
|
|
|
# This packager version is built using the packeger.df in the packaging folder:
|
|
|
|
|
# docker build -t "hasura/graphql-engine-packager:20210218" -f packager.df .
|
|
|
|
|
packager_ver := 20210218
|
2020-12-01 15:21:45 +03:00
|
|
|
|
pg_dump_ver := 13
|
2018-07-10 13:01:02 +03:00
|
|
|
|
build_output := /build/_server_output
|
2021-09-29 07:55:08 +03:00
|
|
|
|
docs_output := /build/_server_output/docs.tar.gz
|
2018-07-10 13:01:02 +03:00
|
|
|
|
|
2020-01-18 01:07:15 +03:00
|
|
|
|
# Getting access to the built products with the `cabal v2-*` commands is really awkward; see
|
|
|
|
|
# <https://www.haskell.org/cabal/users-guide/nix-local-build.html#where-are-my-build-products> for a
|
|
|
|
|
# little more context. Ideally, we could use `cabal v2-install` for this, but `v2-install` does
|
|
|
|
|
# strange and complicated things, and I could not get it to work.
|
|
|
|
|
#
|
|
|
|
|
# This glob is a pretty heavy hammer designed to work regardless of `cabal-install` version (see the
|
|
|
|
|
# aforementioned link for why that’s tricky). If `cabal v2-*` ever gets a better way to do this,
|
|
|
|
|
# please replace this with something less hacky.
|
2021-08-11 07:18:40 +03:00
|
|
|
|
executables_glob := ../dist-newstyle/build/*/*/graphql-engine-*/**/opt/build/{graphql-engine/graphql-engine,graphql-engine-tests/graphql-engine-tests}
|
2020-01-18 01:07:15 +03:00
|
|
|
|
|
2018-07-03 20:10:13 +03:00
|
|
|
|
# assumes this is built in circleci
|
2020-01-18 01:07:15 +03:00
|
|
|
|
ci-build:
|
|
|
|
|
## configure
|
2021-09-16 20:20:00 +03:00
|
|
|
|
cabal v2-update --project-file=cabal.project.ci
|
2020-01-18 01:07:15 +03:00
|
|
|
|
## build
|
2021-09-16 20:20:00 +03:00
|
|
|
|
cabal v2-build --project-file=cabal.project.ci
|
2020-01-18 01:07:15 +03:00
|
|
|
|
## install
|
|
|
|
|
mkdir -p '$(build_output)'
|
|
|
|
|
echo '$(VERSION)' > '$(build_output)/version.txt'
|
|
|
|
|
shopt -s failglob globstar && cp $(executables_glob) '$(build_output)/'
|
2018-07-03 20:10:13 +03:00
|
|
|
|
|
2021-09-24 20:01:40 +03:00
|
|
|
|
# assumes this is built in circleci
|
|
|
|
|
ci-docs:
|
|
|
|
|
# build
|
|
|
|
|
cabal haddock
|
|
|
|
|
# copy
|
|
|
|
|
cd ../dist-newstyle/build/*/*/graphql-engine-*/**/doc/html/graphql-engine/ && tar czf $(docs_output) *
|
|
|
|
|
|
2018-07-03 20:10:13 +03:00
|
|
|
|
# assumes this is built in circleci
|
|
|
|
|
ci-image:
|
2020-01-18 01:07:15 +03:00
|
|
|
|
mkdir -p packaging/build/rootfs
|
2021-02-23 20:37:27 +03:00
|
|
|
|
cp '$(build_output)/graphql-engine' packaging/build/rootfs
|
|
|
|
|
strip --strip-unneeded packaging/build/rootfs/graphql-engine
|
|
|
|
|
cp '/usr/lib/postgresql/$(pg_dump_ver)/bin/pg_dump' packaging/build/rootfs/pg_dump
|
|
|
|
|
upx packaging/build/rootfs/graphql-engine
|
2020-01-18 01:07:15 +03:00
|
|
|
|
docker build -t '$(registry)/graphql-engine:$(VERSION)' packaging/build/
|
2018-07-03 20:10:13 +03:00
|
|
|
|
|
2018-07-10 13:01:02 +03:00
|
|
|
|
ci-save-image:
|
2020-01-18 01:07:15 +03:00
|
|
|
|
docker save -o '$(build_output)/image.tar' '$(registry)/graphql-engine:$(VERSION)'
|
2018-07-10 13:01:02 +03:00
|
|
|
|
ci-load-image:
|
2020-01-18 01:07:15 +03:00
|
|
|
|
docker load -i '$(build_output)/image.tar'
|
2018-07-03 20:10:13 +03:00
|
|
|
|
|
2018-07-17 20:00:26 +03:00
|
|
|
|
push:
|
2020-01-18 01:07:15 +03:00
|
|
|
|
docker push '$(registry)/graphql-engine:$(VERSION)'
|
2018-06-27 16:11:32 +03:00
|
|
|
|
|
2018-07-17 20:00:26 +03:00
|
|
|
|
push-latest:
|
2020-01-18 01:07:15 +03:00
|
|
|
|
docker tag '$(registry)/graphql-engine:$(VERSION)' '$(registry)/graphql-engine:latest'
|
|
|
|
|
docker push '$(registry)/graphql-engine:latest'
|
2018-07-17 20:00:26 +03:00
|
|
|
|
|
2018-06-27 16:11:32 +03:00
|
|
|
|
packager: packaging/packager.df
|
2020-01-18 01:07:15 +03:00
|
|
|
|
docker build -t '$(registry)/graphql-engine-packager:$(packager_ver)' -f packaging/packager.df ./packaging/
|
2018-07-02 16:56:10 +03:00
|
|
|
|
|
2020-01-18 01:07:15 +03:00
|
|
|
|
.PHONY: ci-build ci-image ci-save-image ci-load-image push push-latest packager
|