2018-10-25 21:51:47 +08:00
|
|
|
BIN := listmonk
|
2019-05-27 19:47:26 +08:00
|
|
|
STATIC := config.toml.sample schema.sql queries.sql public email-templates frontend/build:/frontend
|
2018-10-25 21:51:47 +08:00
|
|
|
|
|
|
|
HASH := $(shell git rev-parse --short HEAD)
|
|
|
|
COMMIT_DATE := $(shell git show -s --format=%ci ${HASH})
|
|
|
|
BUILD_DATE := $(shell date '+%Y-%m-%d %H:%M:%S')
|
|
|
|
VERSION := ${HASH} (${COMMIT_DATE})
|
|
|
|
|
2019-05-14 20:12:18 +08:00
|
|
|
.PHONY: build-frontend
|
|
|
|
build-frontend:
|
2019-05-27 19:47:26 +08:00
|
|
|
cd frontend && yarn install && yarn build
|
2019-01-09 19:13:13 +08:00
|
|
|
|
|
|
|
.PHONY: quickdev
|
|
|
|
quickdev:
|
2019-05-27 19:47:26 +08:00
|
|
|
@ if [ ! -d "frontend/node_modules" ]; then \
|
2019-01-09 19:13:13 +08:00
|
|
|
echo "Installing frontend deps"; \
|
2019-05-27 19:47:26 +08:00
|
|
|
cd frontend && yarn install; \
|
2019-01-09 19:13:13 +08:00
|
|
|
fi
|
|
|
|
|
2019-05-27 19:47:26 +08:00
|
|
|
@ if [ ! -d "frontend/build" ]; then \
|
2019-01-09 19:13:13 +08:00
|
|
|
echo "Creating build directory"; \
|
2019-05-27 19:47:26 +08:00
|
|
|
mkdir -p frontend/build; \
|
2019-01-09 19:13:13 +08:00
|
|
|
echo "Building frontend assets"; \
|
2019-05-27 19:47:26 +08:00
|
|
|
cd frontend && yarn build; \
|
2019-01-09 19:13:13 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
@ echo -e "\nBuilding go binary\n"
|
|
|
|
make build
|
|
|
|
|
|
|
|
@ echo -e "Editing database params inside config\n"
|
|
|
|
cp config.toml.sample config.toml
|
|
|
|
|
|
|
|
@ echo -n "Database user: "
|
|
|
|
@ read DBUSER; \
|
|
|
|
sed -i -e "s/user = \"listmonk\"/user = \"$${DBUSER}\"/g" config.toml
|
|
|
|
|
|
|
|
@ echo -n "Database password: "
|
|
|
|
@ read DBPASSWORD; \
|
|
|
|
sed -i -e "s/password = \"\"/password = \"$${DBPASSWORD}\"/g" config.toml
|
|
|
|
|
|
|
|
@ echo -n "Database name: "
|
|
|
|
@ read DBNAME; \
|
|
|
|
sed -i -e "s/database = \"listmonk\"/database = \"$${DBNAME}\"/g" config.toml; \
|
|
|
|
createdb $${DBNAME}
|
|
|
|
|
|
|
|
@ echo -e "Running installer\n"
|
|
|
|
./listmonk --install
|
|
|
|
|
|
|
|
.PHONY: build
|
2018-10-25 21:51:47 +08:00
|
|
|
build:
|
2019-01-03 19:18:47 +08:00
|
|
|
go build -o ${BIN} -ldflags="-s -w -X 'main.buildVersion=${VERSION}' -X 'main.buildDate=${BUILD_DATE}'"
|
|
|
|
stuffbin -a stuff -in ${BIN} -out ${BIN} ${STATIC}
|
|
|
|
|
2019-03-27 16:05:51 +08:00
|
|
|
.PHONY: run
|
|
|
|
run: build
|
|
|
|
./${BIN}
|
|
|
|
|
2019-01-09 19:13:13 +08:00
|
|
|
.PHONY: deps
|
2019-01-03 19:18:47 +08:00
|
|
|
deps:
|
|
|
|
go get -u github.com/knadh/stuffbin/...
|
2018-10-25 21:51:47 +08:00
|
|
|
|
2019-01-09 19:13:13 +08:00
|
|
|
.PHONY: test
|
2018-10-25 21:51:47 +08:00
|
|
|
test:
|
|
|
|
go test
|
|
|
|
|
2019-01-09 19:13:13 +08:00
|
|
|
.PHONY: clean
|
2018-10-25 21:51:47 +08:00
|
|
|
clean:
|
|
|
|
go clean
|
|
|
|
- rm -f ${BIN}
|