-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
73 lines (54 loc) · 1.73 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!make
include .dev.env
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
# Templ parameters
TEMPLCMD=templ
# Application name
APPNAME=gocms
ADMINAPPNAME=gocms-admin
# Directories
SRC=./cmd/gocms
ADMINSRC=./cmd/gocms_admin
OUT=./tmp
# Targets
all: build test
# Migrations for DB
prepare_env:
cp -r migrations tests/system_tests/helpers/
# ==== Development ====
install-tools:
go install github.com/a-h/templ/cmd/[email protected]
go install github.com/pressly/goose/v3/cmd/[email protected]
go install github.com/cosmtrek/[email protected]
start-devdb:
docker compose -f docker/mariadb.yml up -d
run-migrations:
GOOSE_DRIVER=mysql GOOSE_DBSTRING="${MARIADB_USER}:${MARIADB_ROOT_PASSWORD}@tcp(${MARIADB_ADDRESS}:${MARIADB_PORT})/${MARIADB_DATABASE}" goose -dir ./migrations up
build:
$(TEMPLCMD) generate
$(GOBUILD) -ldflags="-s -w" -v -o $(OUT)/$(APPNAME) $(SRC)/*.go
$(GOBUILD) -ldflags="-s -w" -v -o $(OUT)/$(ADMINAPPNAME) $(ADMINSRC)/*.go
run:
# $(GOBUILD) -o $(OUT)/$(APPNAME) $(SRC)/*.go
# $(OUT)/$(APPNAME)
DATABASE_HOST=localhost DATABASE_PORT=3306 DATABASE_USER=root DATABASE_PASSWORD=my-secret-pw DATABASE_NAME=cms_db IMAGE_DIRECTORY="./media" CONFIG_FILE_PATH="settings/gocms_config.toml" $(OUT)/$(ADMINAPPNAME)
# ==== Docker Containers ====
run-containers:
docker build -t emarifer/gocms:0.1 docker/
docker compose -f docker/docker-compose.yml up
start-admin-container:
$(OUT)/$(ADMINAPPNAME) --config docker/gocms_config.toml
# Testing
test: prepare_env
$(GOTEST) -v ./...
clean:
$(GOCLEAN)
rm -rf $(OUT)
.PHONY: all build test clean
# Why does make think the target is up to date?. SEE:
# https://stackoverflow.com/questions/3931741/why-does-make-think-the-target-is-up-to-date