| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- APP := miniflux
- DOCKER_IMAGE := miniflux/miniflux
- VERSION := $(shell git describe --tags --exact-match 2>/dev/null)
- DOCKER_TAG := $(or $(VERSION),dev)
- LD_FLAGS := "-s -w -X 'miniflux.app/v2/internal/version.Version=$(VERSION)'"
- DB_URL := postgres://postgres:postgres@localhost/miniflux_test?sslmode=disable
- DOCKER_PLATFORM := amd64
- export PGPASSWORD := postgres
- .PHONY: \
- miniflux \
- miniflux-no-pie \
- linux-amd64 \
- linux-arm64 \
- linux-armv7 \
- linux-armv6 \
- linux-armv5 \
- linux-riscv64 \
- darwin-amd64 \
- darwin-arm64 \
- freebsd-amd64 \
- freebsd-arm64 \
- openbsd-amd64 \
- build \
- run \
- clean \
- add-string \
- test \
- lint \
- integration-test \
- clean-integration-test \
- docker-image \
- docker-image-distroless \
- docker-images \
- rpm \
- debian \
- debian-packages
- miniflux:
- @ go build -buildmode=pie -ldflags=$(LD_FLAGS) -o $(APP)
- miniflux-no-pie:
- @ go build -ldflags=$(LD_FLAGS) -o $(APP)
- linux-amd64:
- @ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags=$(LD_FLAGS) -o $(APP)-$@
- @ sha256sum $(APP)-$@ > $(APP)-$@.sha256
- linux-arm64:
- @ CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags=$(LD_FLAGS) -o $(APP)-$@
- @ sha256sum $(APP)-$@ > $(APP)-$@.sha256
- linux-armv7:
- @ CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -ldflags=$(LD_FLAGS) -o $(APP)-$@
- @ sha256sum $(APP)-$@ > $(APP)-$@.sha256
- linux-armv6:
- @ CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -ldflags=$(LD_FLAGS) -o $(APP)-$@
- @ sha256sum $(APP)-$@ > $(APP)-$@.sha256
- linux-armv5:
- @ CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=5 go build -ldflags=$(LD_FLAGS) -o $(APP)-$@
- @ sha256sum $(APP)-$@ > $(APP)-$@.sha256
- linux-riscv64:
- @ CGO_ENABLED=0 GOOS=linux GOARCH=riscv64 go build -ldflags=$(LD_FLAGS) -o $(APP)-$@
- @ sha256sum $(APP)-$@ > $(APP)-$@.sha256
- darwin-amd64:
- @ CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags=$(LD_FLAGS) -o $(APP)-$@
- @ sha256sum $(APP)-$@ > $(APP)-$@.sha256
- darwin-arm64:
- @ CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags=$(LD_FLAGS) -o $(APP)-$@
- @ sha256sum $(APP)-$@ > $(APP)-$@.sha256
- freebsd-amd64:
- @ CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags=$(LD_FLAGS) -o $(APP)-$@
- @ sha256sum $(APP)-$@ > $(APP)-$@.sha256
- freebsd-arm64:
- @ CGO_ENABLED=0 GOOS=freebsd GOARCH=arm64 go build -ldflags=$(LD_FLAGS) -o $(APP)-$@
- @ sha256sum $(APP)-$@ > $(APP)-$@.sha256
- openbsd-amd64:
- @ CGO_ENABLED=0 GOOS=openbsd GOARCH=amd64 go build -ldflags=$(LD_FLAGS) -o $(APP)-$@
- @ sha256sum $(APP)-$@ > $(APP)-$@.sha256
- build: linux-amd64 linux-arm64 linux-armv7 linux-armv6 linux-armv5 linux-riscv64 darwin-amd64 darwin-arm64 freebsd-amd64 freebsd-arm64 openbsd-amd64
- run: miniflux
- @ LOG_DATE_TIME=1 LOG_LEVEL=debug RUN_MIGRATIONS=1 CREATE_ADMIN=1 ADMIN_USERNAME=admin ADMIN_PASSWORD=test123 ./$(APP)
- clean:
- @ rm -f $(APP)-* $(APP) $(APP)*.rpm $(APP)*.deb
- add-string:
- $(if $(KEY),,$(error KEY is required, e.g. make add-string KEY=page.example.title VAL="Example"))
- $(if $(VAL),,$(error VAL is required, e.g. make add-string KEY=page.example.title VAL="Example"))
- cd internal/locale/translations && \
- for file in *.json; do \
- jq --indent 4 --arg key "$(KEY)" --arg val "$(VAL)" \
- '. + {($$key): $$val} | to_entries | sort_by(.key) | from_entries' "$$file" > tmp && \
- mv tmp "$$file"; \
- done
- test:
- go test -cover -race -count=1 ./...
- lint:
- go vet ./...
- gofmt -d -e .
- golangci-lint run
- integration-test: miniflux
- psql -U postgres -c 'drop database if exists miniflux_test;'
- psql -U postgres -c 'create database miniflux_test;'
- DATABASE_URL=$(DB_URL) ./$(APP) -migrate
- TEST_DATABASE_URL=$(DB_URL) go test -v -count=1 ./internal/storage
- TEST_DATABASE_URL=$(DB_URL) go test -v -count=1 ./internal/api
- clean-integration-test:
- @ psql -U postgres -c 'drop database if exists miniflux_test;'
- docker-image:
- docker build --pull -t $(DOCKER_IMAGE):$(DOCKER_TAG) -f packaging/docker/alpine/Dockerfile .
- docker-image-distroless:
- docker build --pull -t $(DOCKER_IMAGE):$(DOCKER_TAG)-distroless -f packaging/docker/distroless/Dockerfile .
- docker-images:
- $(if $(VERSION),,$(error VERSION is required to push images, e.g. make docker-images VERSION=2.3.0))
- docker buildx build \
- --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/riscv64 \
- --file packaging/docker/alpine/Dockerfile \
- --tag $(DOCKER_IMAGE):$(VERSION) \
- --push .
- rpm: clean
- @ docker build \
- -t miniflux-rpm-builder \
- -f packaging/rpm/Dockerfile \
- .
- @ docker run --rm \
- -v $(CURDIR):/root/rpmbuild/RPMS/x86_64 miniflux-rpm-builder \
- rpmbuild -bb --define "_miniflux_version $(VERSION)" /root/rpmbuild/SPECS/miniflux.spec
- debian:
- @ docker buildx build --load \
- --platform linux/$(DOCKER_PLATFORM) \
- -t miniflux-deb-builder \
- -f packaging/debian/Dockerfile \
- .
- @ docker run --rm --platform linux/$(DOCKER_PLATFORM) \
- -v $(CURDIR):/pkg miniflux-deb-builder
- debian-packages: clean
- $(MAKE) debian DOCKER_PLATFORM=amd64
- $(MAKE) debian DOCKER_PLATFORM=arm64
- $(MAKE) debian DOCKER_PLATFORM=arm/v7
- $(MAKE) debian DOCKER_PLATFORM=riscv64
|