74 lines
2.1 KiB
Makefile
74 lines
2.1 KiB
Makefile
.PHONY: docker migration dev clean test build-prepare build-js build-css build-font build-go copy-templates watch-js watch-css watch-templates watch
|
|
|
|
DB_USER=test
|
|
DB_PASS=test
|
|
DB_DSN_DEV=postgres://$(DB_USER):$(DB_PASS)@127.0.0.1:5432/dev?sslmode=disable
|
|
DB_DSN_TEST=postgres://$(DB_USER):$(DB_PASS)@127.0.0.1:5432/test?sslmode=disable
|
|
|
|
MIGRATION=migrate -url '$(DB_DSN_DEV)'
|
|
MIGRATION_SCHEMA=./sql/migration
|
|
MIGRATION_TEST_DATA=./sql/dev
|
|
|
|
DOCKER_COMPOSE_FILE=./docker/docker-compose.yml
|
|
DOCKER_COMPOSE=docker-compose -f $(DOCKER_COMPOSE_FILE)
|
|
|
|
build-prepare:
|
|
mkdir -p ./build/public/js
|
|
mkdir -p ./build/public/css
|
|
mkdir -p ./build/templates
|
|
mkdir -p ./build/public/img/movies
|
|
|
|
build-js: build-prepare
|
|
node node_modules/.bin/browserify src/public/js/app.js -o build/public/js/app.js
|
|
|
|
build-css: build-prepare
|
|
node ./node_modules/.bin/lessc --include-path=./node_modules src/public/less/app.less build/public/css/app.css
|
|
|
|
build-font: build-prepare
|
|
node ./node_modules/.bin/fontify
|
|
|
|
build-go: build-prepare
|
|
go build -o ./build/canape src/main.go
|
|
|
|
copy-templates: build-prepare
|
|
cp -r ./src/templates/* ./build/templates
|
|
|
|
build: build-js build-css build-font copy-templates build-go
|
|
|
|
watch-js: build-prepare
|
|
node ./node_modules/.bin/nodemon -e js -w src/public/js/app.js -x 'make build-js' &
|
|
|
|
watch-css: build-prepare
|
|
node ./node_modules/.bin/nodemon -e less -w src/public/less/app.less -x 'make build-css' &
|
|
|
|
watch-templates: build-prepare
|
|
node ./node_modules/.bin/nodemon -e tmpl -w src/templates -x 'make copy-templates' &
|
|
|
|
watch-go: build-prepare
|
|
CONFIG_FILE="./config.yml" fresh -c fresh.conf
|
|
|
|
watch: watch-js watch-css watch-templates watch-go
|
|
|
|
docker:
|
|
$(DOCKER_COMPOSE) up -d
|
|
sleep 4
|
|
|
|
migration-tool:
|
|
go get -v github.com/mattes/migrate
|
|
|
|
migration-schema: docker migration-tool
|
|
$(MIGRATION) -path $(MIGRATION_SCHEMA) up
|
|
|
|
migration-dev-data: docker migration-schema
|
|
$(MIGRATION) -path $(MIGRATION_TEST_DATA) up
|
|
|
|
dev: docker migration watch
|
|
|
|
clean:
|
|
-rm -r ./build
|
|
$(DOCKER_COMPOSE) stop
|
|
$(DOCKER_COMPOSE) rm --force -v
|
|
|
|
test: docker
|
|
POSTGRES_DSN="$(DB_DSN_TEST)" go test -v -p=1 ./...
|