2018-12-28 07:07:18 +03:00
|
|
|
SHELL := /bin/bash
|
|
|
|
|
2018-12-10 01:02:03 +03:00
|
|
|
# Build the project
|
|
|
|
.PHONY: back
|
|
|
|
back:
|
|
|
|
stack build --fast
|
|
|
|
|
|
|
|
# Run tests
|
|
|
|
.PHONY: back/test
|
|
|
|
back/test:
|
|
|
|
stack test --fast
|
|
|
|
|
|
|
|
# Download the official database
|
|
|
|
.PHONY: back/db
|
|
|
|
back/db:
|
|
|
|
rm -rf back/state
|
|
|
|
git clone --depth 1 https://github.com/aelve/guide-database.git
|
|
|
|
mv guide-database back/state
|
2019-06-19 16:54:00 +03:00
|
|
|
(cd back/state && gzip -d *.gz)
|
2018-12-10 01:02:03 +03:00
|
|
|
|
|
|
|
# Test that the official database can be loaded
|
|
|
|
.PHONY: back/test-db
|
|
|
|
back/test-db: back
|
|
|
|
if [ -d back/state ]; then mv back/state back/state-old; fi
|
|
|
|
git clone --depth 1 https://github.com/aelve/guide-database.git
|
|
|
|
mv guide-database back/state
|
2019-06-19 16:54:00 +03:00
|
|
|
(cd back/state && gzip -d *.gz)
|
2018-12-10 01:02:03 +03:00
|
|
|
(cd back/state && git branch -v && git status && ls)
|
2019-08-17 15:38:07 +03:00
|
|
|
stack exec --cwd back -- guide dry-run
|
2018-12-10 01:02:03 +03:00
|
|
|
rm -rf back/state
|
|
|
|
if [ -d back/state-old ]; then mv back/state-old back/state; fi
|
|
|
|
|
|
|
|
# Run the backend
|
|
|
|
.PHONY: back/run
|
|
|
|
back/run:
|
|
|
|
stack exec --cwd back -- guide
|
2018-12-28 07:07:18 +03:00
|
|
|
|
2019-08-23 10:49:44 +03:00
|
|
|
# Load AcidState base to Postgres and check equality.
|
|
|
|
# Postgres should be installed already.
|
|
|
|
# 'Guide' base should be created already and clear.
|
|
|
|
.PHONY: back/load-into-postgres
|
|
|
|
back/load-into-postgres:
|
|
|
|
stack exec --cwd back -- guide load-into-postgres
|
|
|
|
|
2018-12-28 07:07:18 +03:00
|
|
|
# Create a Docker image for the backend; will only work on Travis because
|
2019-06-26 11:35:52 +03:00
|
|
|
# the binary has to have been compiled on Ubuntu Xenial (the OS used in the
|
|
|
|
# Docker file).
|
|
|
|
#
|
|
|
|
# Assumes Guide has been built with Stack.
|
2018-12-28 07:07:18 +03:00
|
|
|
.PHONY: back/travis-docker
|
|
|
|
back/travis-docker:
|
|
|
|
rm -rf docker/back/files && mkdir docker/back/files
|
|
|
|
git clone --depth 1 https://github.com/aelve/guide-database.git \
|
|
|
|
docker/back/files/state
|
2019-06-19 16:54:00 +03:00
|
|
|
(cd docker/back/files/state && gzip -d *.gz)
|
2018-12-28 07:07:18 +03:00
|
|
|
rm -rf docker/back/files/state/.git
|
2019-06-26 11:35:52 +03:00
|
|
|
cp "$$(stack path --local-install-root)/bin/guide" docker/back/files/
|
2018-12-28 07:07:18 +03:00
|
|
|
cp -R back/{static,templates} docker/back/files/
|
|
|
|
docker build docker/back -t quay.io/aelve/guide:$(tag)
|
|
|
|
rm -rf docker/back/files
|
2019-04-24 18:25:12 +03:00
|
|
|
|
2019-10-25 22:15:48 +03:00
|
|
|
# Create a Docker image for the front
|
2019-04-24 18:25:12 +03:00
|
|
|
.PHONY: front/travis-docker
|
|
|
|
front/travis-docker:
|
|
|
|
rm -rf docker/front/files && mkdir docker/front/files
|
|
|
|
cp -R front/dist docker/front/files/
|
|
|
|
cd ./docker/front/files/dist/ && export NODE_ENV=production && npm install
|
2019-10-25 22:15:48 +03:00
|
|
|
if grep -q "Vue in development mode" docker/front/files/dist/src/main.js; then echo "The frontend has been built in development mode"; exit 1; fi
|
2019-04-24 18:25:12 +03:00
|
|
|
docker build docker/front -t quay.io/aelve/guide:$(tag)
|
|
|
|
rm -rf docker/front/files
|