riju/Makefile

129 lines
3.2 KiB
Makefile

SHELL := bash
.SHELLFLAGS := -o pipefail -euc
export PATH := bin:$(PATH)
-include .env
export
BUILD := build/$(T)/$(L)
DEB := riju-$(T)-$(L).deb
S3_DEBS := s3://$(S3_BUCKET_BASE)-debs
S3_DEB := $(S3_DEBS)/debs/$(T)/$(L)/$(DEB)
S3_HASH := $(S3_DEBS)/hashes/$(T)/$(L)/riju-$(T)-$(L).sha1
.PHONY: help
help:
@echo "usage:"
@echo
@cat Makefile | \
grep -E '[.]PHONY|[#]##' | \
sed -E 's/[.]PHONY: */ make /' | \
sed -E 's/[#]## *(.+)/\n (\1)\n/'
### Build things locally
.PHONY: admin-image
admin-image:
docker build . -f docker/admin/Dockerfile -t riju-admin --pull
.PHONY: packaging-image
packaging-image:
docker build . -f docker/packaging/Dockerfile -t riju-packaging --pull
.PHONY: runtime-image
runtime-image:
docker build . -f docker/runtime/Dockerfile -t riju-runtime --pull
.PHONY: app-image
app-image:
docker build . -f docker/app/Dockerfile -t riju-app --pull
.PHONY: script
script:
@: $${L} $${T}
mkdir -p $(BUILD)
node src/packager/make-script --lang $(L) --type $(T) > $(BUILD)/build.bash
chmod +x $(BUILD)/build.bash
.PHONY: pkg
pkg:
@: $${L} $${T}
rm -rf $(BUILD)/src $(BUILD)/pkg
mkdir -p $(BUILD)/src $(BUILD)/pkg
cd $(BUILD)/src && pkg="$(PWD)/$(BUILD)/pkg" ../build.bash
fakeroot dpkg-deb --build $(BUILD)/pkg $(BUILD)/$(DEB)
### Run things inside Docker
.PHONY: admin-shell
admin-shell:
docker run -it --rm -v $(PWD):/src -v $(HOME)/.aws:/var/riju/.aws:ro -e AWS_REGION -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY riju-admin
.PHONY: packaging-shell
packaging-shell:
docker run -it --rm -v $(PWD):/src riju-packaging
.PHONY: runtime-shell
runtime-shell:
docker run -it --rm -v $(PWD):/src riju-runtime
### Fetch things from registries
.PHONY: fetch-packaging-image
fetch-packaging-image:
@: $${DOCKER_REPO_BASE}
docker pull $(DOCKER_REPO_BASE)-packaging
docker tag $(DOCKER_REPO_BASE)-packaging riju-packaging
.PHONY: fetch-runtime-image
fetch-runtime-image:
@: $${DOCKER_REPO_BASE}
docker pull $(DOCKER_REPO_BASE)-runtime
docker tag $(DOCKER_REPO_BASE)-runtime riju-runtime
.PHONY: fetch-app-image
fetch-app-image:
@: $${DOCKER_REPO_BASE}
docker pull $(DOCKER_REPO_BASE)-app
docker tag $(DOCKER_REPO_BASE)-app riju-app
.PHONY: fetch-pkg
fetch-pkg:
@: $${L} $${T} $${S3_BUCKET_BASE}
mkdir -p $(BUILD)
aws s3 cp $(S3_DEB) $(BUILD)/$(DEB)
### Publish things to registries
.PHONY: publish-packaging-image
publish-packaging-image:
@: $${DOCKER_REPO_BASE}
docker tag riju-packaging $(DOCKER_REPO_BASE)-packaging
docker push $(DOCKER_REPO_BASE)-packaging
.PHONY: publish-runtime-image
publish-runtime-image:
@: $${DOCKER_REPO_BASE}
docker tag riju-runtime $(DOCKER_REPO_BASE)-runtime
docker push $(DOCKER_REPO_BASE)-runtime
.PHONY: publish-app-image
publish-app-image:
@: $${DOCKER_REPO_BASE}
docker tag riju-app $(DOCKER_REPO_BASE)-app
docker push $(DOCKER_REPO_BASE)-app
.PHONY: publish-pkg
publish-pkg:
@: $${L} $${T} $${S3_BUCKET_BASE}
aws s3 cp <(dpkg-deb -f $(BUILD)/$(DEB) Riju-Script-Hash) $(S3_HASH)
aws s3 cp $(BUILD)/$(DEB) $(S3_DEB)
### Miscellaneous
.PHONY: dockerignore
dockerignore:
echo "# This file is generated by 'make dockerignore', do not edit." > .dockerignore
cat .gitignore | sed 's#^#**/#' >> .dockerignore