golang.org/x/build@v0.0.0-20240506185731-218518f32b70/cmd/relui/Makefile (about) 1 # Copyright 2021 The Go Authors. All rights reserved. 2 # Use of this source code is governed by a BSD-style 3 # license that can be found in the LICENSE file. 4 5 VERSION := $(shell ../coordinator/version.sh) 6 DOCKER_TAG := golang/relui:$(VERSION) 7 8 INTERNAL_PATH := ../../internal/relui 9 10 POSTGRES_DATA_DEV := "postgres-data-dev:/var/lib/postgresql/data" 11 POSTGRES_RUN_DEV := "postgres-run-dev:/var/run/postgresql" 12 POSTGRES_USER := "postgres" 13 POSTGRES_TEST := psql --username=$(POSTGRES_USER) -c "SELECT 1;" 14 15 DEV_CFG := ${HOME}/.local/share/relui 16 17 MODULE_ROOT := "$(shell readlink -f ../../)" 18 NODE_IMAGE_VERSION := "node:16.15.1-bullseye" 19 20 .PHONY: dev 21 dev: postgres-dev docker 22 docker run --rm --name=relui-dev -v $(POSTGRES_RUN_DEV) -e PGUSER=$(POSTGRES_USER) -e PGDATABASE=relui-dev -p 8080:8080 $(DOCKER_TAG) 23 24 .PHONY: postgres-dev 25 postgres-dev: $(DEV_CFG)/pgpass 26 docker exec postgres-dev $(POSTGRES_TEST) || \ 27 docker run --rm -d --name=postgres-dev \ 28 -p 127.0.0.1:5432:5432 \ 29 -v $(POSTGRES_DATA_DEV) \ 30 -v $(POSTGRES_RUN_DEV) \ 31 -v $(DEV_CFG)/pgpass:/run/secrets/pgpass \ 32 -e POSTGRES_PASSWORD_FILE=/run/secrets/pgpass \ 33 postgres:13 34 35 migrate: docker 36 docker run --rm --name=relui-dev-migrate -v $(POSTGRES_RUN_DEV) -e PGUSER=$(POSTGRES_USER) -e PGDATABASE=relui-dev $(DOCKER_TAG) --migrate-only 37 38 migrate-down-up: docker 39 docker run --rm --name=relui-dev-migrate -v $(POSTGRES_RUN_DEV) -e PGUSER=$(POSTGRES_USER) -e PGDATABASE=relui-dev $(DOCKER_TAG) --migrate-down-up 40 41 .PHONY: test 42 test: postgres-dev docker-test 43 docker run --rm --name=relui-test -v $(POSTGRES_RUN_DEV) -e PGUSER=$(POSTGRES_USER) -e PGDATABASE=relui-test golang/relui-test:$(VERSION) 44 45 DOCKER_IMAGE := golang/relui 46 IMAGE_PROD := gcr.io/symbolic-datum-552/relui 47 MUTABLE_VERSION := latest 48 49 .PHONY: docker 50 docker: 51 docker build -f Dockerfile -t $(DOCKER_IMAGE):$(VERSION) ../.. 52 53 .PHONY: docker-test 54 docker-test: 55 docker build -f Dockerfile.test -t golang/relui-test:$(VERSION) ../.. 56 57 .PHONY: docker-prod 58 docker-prod: docker 59 docker tag $(DOCKER_IMAGE):$(VERSION) $(IMAGE_PROD):$(VERSION) 60 docker tag $(DOCKER_IMAGE):$(VERSION) $(IMAGE_PROD):$(MUTABLE_VERSION) 61 62 .PHONY: push-prod 63 push-prod: docker-prod 64 docker push $(IMAGE_PROD):$(VERSION) 65 docker push $(IMAGE_PROD):$(MUTABLE_VERSION) 66 67 .PHONY: deploy-prod 68 deploy-prod: push-prod 69 go install golang.org/x/build/cmd/xb 70 xb --prod kubectl --namespace prod set image deployment/relui-deployment relui=$(IMAGE_PROD):$(VERSION) 71 72 node_modules/: package.json package-lock.json 73 docker run --rm \ 74 --volume $(MODULE_ROOT):/workspace \ 75 --workdir /workspace/cmd/relui \ 76 --env NODE_OPTIONS="--experimental-vm-modules --no-warnings" \ 77 $(NODE_IMAGE_VERSION) \ 78 npm install --no-update-notifier 79 80 .PHONY: lint 81 lint: node_modules/ 82 docker run --rm \ 83 --volume $(MODULE_ROOT):/workspace \ 84 --workdir /workspace/cmd/relui \ 85 --env NODE_OPTIONS="--experimental-vm-modules --no-warnings" \ 86 $(NODE_IMAGE_VERSION) \ 87 npm --no-update-notifier run lint:js 88 docker run --rm \ 89 --volume $(MODULE_ROOT):/workspace \ 90 --workdir /workspace/cmd/relui \ 91 --env NODE_OPTIONS="--experimental-vm-modules --no-warnings" \ 92 $(NODE_IMAGE_VERSION) \ 93 npm --no-update-notifier run lint:css