Tidy up manual build process

This commit is contained in:
David Stotijn 2020-11-01 19:01:07 +01:00
parent 81fbfe4cb3
commit f6789fa245
5 changed files with 25 additions and 29 deletions

View file

@ -1,4 +1,3 @@
**/rice-box.go
/admin/.env /admin/.env
/admin/.next /admin/.next
/admin/dist /admin/dist

View file

@ -2,11 +2,6 @@ env:
- GO111MODULE=on - GO111MODULE=on
- CGO_ENABLED=1 - CGO_ENABLED=1
before:
hooks:
- make clean
- make embed
builds: builds:
- id: hetty-darwin-amd64 - id: hetty-darwin-amd64
main: ./cmd/hetty main: ./cmd/hetty

View file

@ -9,6 +9,7 @@ COPY go.mod go.sum ./
RUN go mod download RUN go mod download
COPY cmd ./cmd COPY cmd ./cmd
COPY pkg ./pkg COPY pkg ./pkg
RUN rm -f cmd/hetty/rice-box.go
RUN go build ./cmd/hetty RUN go build ./cmd/hetty
FROM node:${NODE_VERSION}-alpine AS node-builder FROM node:${NODE_VERSION}-alpine AS node-builder

View file

@ -1,35 +1,26 @@
PACKAGE_NAME := github.com/dstotijn/hetty PACKAGE_NAME := github.com/dstotijn/hetty
GOLANG_CROSS_VERSION ?= v1.15.2 GOLANG_CROSS_VERSION ?= v1.15.2
setup:
go mod download
go generate ./...
.PHONY: setup
embed:
go install github.com/GeertJohan/go.rice/rice
cd cmd/hetty && rice embed-go
.PHONY: embed .PHONY: embed
embed:
NEXT_TELEMETRY_DISABLED=1 cd admin && yarn install && yarn run export
cd cmd/hetty && rice embed-go
build: embed
env CGO_ENABLED=1 go build ./cmd/hetty
.PHONY: build .PHONY: build
build: embed
CGO_ENABLED=1 go build ./cmd/hetty
clean: .PHONY: release-dry-run
rm -rf cmd/hetty/rice-box.go release-dry-run: embed
.PHONY: clean
release-dry-run:
@docker run \ @docker run \
--rm \ --rm \
-v `pwd`:/go/src/$(PACKAGE_NAME) \ -v `pwd`:/go/src/$(PACKAGE_NAME) \
-v `pwd`/admin/dist:/go/src/$(PACKAGE_NAME)/admin/dist \
-w /go/src/$(PACKAGE_NAME) \ -w /go/src/$(PACKAGE_NAME) \
troian/golang-cross:${GOLANG_CROSS_VERSION} \ troian/golang-cross:${GOLANG_CROSS_VERSION} \
--rm-dist --skip-validate --skip-publish --rm-dist --skip-validate --skip-publish
.PHONY: release-dry-run
release: .PHONY: release
release: embed
@if [ ! -f ".release-env" ]; then \ @if [ ! -f ".release-env" ]; then \
echo "\033[91mFile \`.release-env\` is missing.\033[0m";\ echo "\033[91mFile \`.release-env\` is missing.\033[0m";\
exit 1;\ exit 1;\
@ -37,9 +28,7 @@ release:
@docker run \ @docker run \
--rm \ --rm \
-v `pwd`:/go/src/$(PACKAGE_NAME) \ -v `pwd`:/go/src/$(PACKAGE_NAME) \
-v `pwd`/admin/dist:/go/src/$(PACKAGE_NAME)/admin/dist \
-w /go/src/$(PACKAGE_NAME) \ -w /go/src/$(PACKAGE_NAME) \
--env-file .release-env \ --env-file .release-env \
troian/golang-cross:${GOLANG_CROSS_VERSION} \ troian/golang-cross:${GOLANG_CROSS_VERSION} \
release --rm-dist release --rm-dist
.PHONY: release

View file

@ -37,11 +37,23 @@ and web based admin interface.
### Build from source ### Build from source
#### Prerequisites
- [Go](https://golang.org/)
- [Yarn](https://yarnpkg.com/)
- [go.rice](https://github.com/GeertJohan/go.rice)
Hetty depends on SQLite (via [mattn/go-sqlite3](https://github.com/mattn/go-sqlite3)) Hetty depends on SQLite (via [mattn/go-sqlite3](https://github.com/mattn/go-sqlite3))
and needs `cgo` to compile. and needs `cgo` to compile. Additionally, the static resources for the admin interface
(Next.js) need to be generated via [Yarn](https://yarnpkg.com/) and embedded in
a `.go` file with [go.rice](https://github.com/GeertJohan/go.rice) beforehand.
Clone the repository and use the `build` make target to create a binary:
``` ```
$ GO111MODULE=auto CGO_ENABLED=1 go get -u github.com/dstotijn/hetty/cmd/hetty $ git clone git@github.com:dstotijn/hetty.git
$ cd hetty
$ make build
``` ```
### Docker ### Docker