From 4d0eb005b5b0f3d9619eaf233df2b33da2c560b4 Mon Sep 17 00:00:00 2001 From: Zygimantas <5236121+Zygimantass@users.noreply.github.com> Date: Mon, 26 Feb 2024 12:20:25 -0500 Subject: [PATCH] fix: don't build on entrypoint --- Makefile | 18 ++- contrib/images/slinky.local.Dockerfile | 2 + contrib/nomad/slinky.nomad | 191 +++++++++++++++++++++++++ 3 files changed, 210 insertions(+), 1 deletion(-) create mode 100644 contrib/nomad/slinky.nomad diff --git a/Makefile b/Makefile index 0395192f0..768e02697 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,9 @@ GENESIS_TMP ?= $(HOMEDIR)/config/genesis_tmp.json COVER_FILE ?= cover.out BENCHMARK_ITERS ?= 10 +LEVANT_VAR_FILE:=$(shell mktemp -d)/levant.yaml +NOMAD_FILE_SLINKY:=contrib/nomad/slinky.nomad + ############################################################################### ### build ### ############################################################################### @@ -127,7 +130,7 @@ $(BUILD_DIR)/: mkdir -p $(BUILD_DIR)/ # build-configs builds a slinky simulation application binary in the build folder (/test/.slinkyd) -build-configs: build-test-app +build-configs: ./build/slinkyd init validator --chain-id skip-1 --home $(HOMEDIR) ./build/slinkyd keys add validator --home $(HOMEDIR) --keyring-backend test ./build/slinkyd genesis add-genesis-account validator 10000000000000000000000000stake --home $(HOMEDIR) --keyring-backend test @@ -262,3 +265,16 @@ format: @find . -name '*.go' -type f -not -path "*.git*" -not -path "*mocks*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' -not -name '*.pulsar.go' -not -name '*.gw.go' | xargs go run golang.org/x/tools/cmd/goimports -w -local github.com/skip-mev/slinky .PHONY: format + +############################################################################### +### dev-deploy ### +############################################################################### + +deploy-dev: + touch ${LEVANT_VAR_FILE} + yq e -i '.sidecar_image |= "${SIDECAR_IMAGE}"' ${LEVANT_VAR_FILE} + yq e -i '.chain_image |= "${CHAIN_IMAGE}"' ${LEVANT_VAR_FILE} + levant deploy -force-count -var-file=${LEVANT_VAR_FILE} ${NOMAD_FILE_SLINKY} + +.PHONY: deploy-dev + diff --git a/contrib/images/slinky.local.Dockerfile b/contrib/images/slinky.local.Dockerfile index 26ac6fed4..c4a4828da 100644 --- a/contrib/images/slinky.local.Dockerfile +++ b/contrib/images/slinky.local.Dockerfile @@ -9,6 +9,8 @@ RUN go mod download COPY . . +RUN make build-test-app + RUN apt-get update && apt-get install jq -y && apt-get install ca-certificates -y ## Prepare the final clear binary diff --git a/contrib/nomad/slinky.nomad b/contrib/nomad/slinky.nomad new file mode 100644 index 000000000..23ee18074 --- /dev/null +++ b/contrib/nomad/slinky.nomad @@ -0,0 +1,191 @@ +job "slinky-dev" { + type = "service" + datacenters = ["skip-nomad-aws-us-east-2"] + region = "global" + + namespace = "slinky-dev" + + group "sidecar" { + count = 1 + + network { + mode = "bridge" + } + + service { + name = "slinky-sidecar-dev-http-service" + port = "8080" + + connect { + sidecar_service {} + } + + tags = [ + "traefik.enable=true", + "traefik.consulcatalog.connect=true", + "traefik.http.routers.slinky-sidecar-dev-http-service.rule=Host(`slinky-sidecar-dev-http.skip-internal.money`)", + "traefik.http.routers.slinky-sidecar-dev-http-service.entrypoints=internal", + ] + } + + service { + name = "slinky-sidecar-dev-metrics-service" + port = "8002" + + connect { + sidecar_service {} + } + + tags = [ + "metrics", + "logs.promtail=true", + "traefik.enable=true", + "traefik.consulcatalog.connect=true", + "traefik.http.routers.slinky-sidecar-dev-metrics-service.rule=Host(`slinky-sidecar-dev-metrics.skip-internal.money`)", + "traefik.http.routers.slinky-sidecar-dev-metrics-service.entrypoints=internal", + ] + } + + service { + name = "slinky-sidecar-dev-pprof-service" + port = "6060" + + connect { + sidecar_service {} + } + + tags = [ + "traefik.enable=true", + "traefik.consulcatalog.connect=true", + "traefik.http.routers.slinky-sidecar-dev-pprof-service.rule=Host(`slinky-sidecar-dev-pprof.skip-internal.money`)", + "traefik.http.routers.slinky-sidecar-dev-pprof-service.entrypoints=internal", + ] + } + + task "sidecar" { + driver = "docker" + + config { + image = "[[ .sidecar_image ]]" + } + + resources { + cpu = 500 + memory = 256 + } + } + + } + + group "chain" { + count = 1 + + network { + mode = "bridge" + } + + service { + name = "slinky-simapp-dev-rpc-service" + port = "26657" + + tags = [ + "traefik.enable=true", + "traefik.consulcatalog.connect=true", + "traefik.http.routers.slinky-simapp-dev-rpc-service.rule=Host(`slinky-simapp-dev-rpc.skip-internal.money`)", + "traefik.http.routers.slinky-simapp-dev-rpc-service.entrypoints=internal", + ] + + connect { + sidecar_service { + proxy { + upstreams { + destination_name = "slinky-sidecar-dev-http-service" + local_bind_port = 8080 + } + } + } + } + } + + service { + name = "slinky-simapp-dev-lcd-service" + port = "1317" + + tags = [ + "traefik.enable=true", + "traefik.consulcatalog.connect=true", + "traefik.http.routers.slinky-simapp-dev-lcd-service.rule=Host(`slinky-simapp-dev-lcd.skip-internal.money`)", + "traefik.http.routers.slinky-simapp-dev-lcd-service.entrypoints=internal", + ] + } + + service { + name = "slinky-simapp-dev-app-metrics-service" + port = "8001" + + tags = [ + "metrics", + "logs.promtail=true", + "traefik.enable=true", + "traefik.consulcatalog.connect=true", + "traefik.http.routers.slinky-simapp-dev-app-metrics-service.rule=Host(`slinky-simapp-dev-app-metrics.skip-internal.money`)", + "traefik.http.routers.slinky-simapp-dev-app-metrics-service.entrypoints=internal", + ] + } + + volume "data" { + type = "csi" + read_only = false + source = "slinky-simapp-dev-node-volume" + access_mode = "single-node-writer" + attachment_mode = "file-system" + } + + task "init" { + driver = "docker" + + config { + image = "[[ .chain_image ]]" + entrypoint = ["sh", "-c", "/tmp/init.sh"] + volumes = ["local/tmp/data:/src/slinky/tests/.slinkyd", "local/tmp/init.sh:/tmp/init.sh"] + } + + template { + data = <