Skip to content

Commit

Permalink
build(repo): allow starting & stopping nats server locally
Browse files Browse the repository at this point in the history
  • Loading branch information
Jurshsmith committed Jun 12, 2024
1 parent d9824f2 commit 2a8857a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
20 changes: 18 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,23 @@
TARGET ?= aarch64-apple-darwin
PACKAGE ?= fuel-core-nats

.PHONY: all build run clean lint fmt help test doc
.PHONY: all build run clean lint fmt help setup start-nats stop-nats test doc

all: build

install:
cargo fetch

setup:
check-commands:
@for cmd in $(COMMANDS); do \
if ! command -v $$cmd >/dev/null 2>&1; then \
echo >&2 "$$cmd is not installed. Please install $$cmd and try again.."; \
exit 1; \
fi \
done

setup: COMMANDS=rustup pre-commit
setup: check-commands
./scripts/setup.sh

# ------------------------------------------------------------
Expand All @@ -32,6 +41,13 @@ dev-watch:
build: install
cargo build --release --target "$(TARGET)" --package "$(PACKAGE)"

start-nats: CMDS=docker-compose
start-nats: check-commands
docker-compose -f docker/docker-compose.yml up

stop-nats:
docker-compose -f docker/docker-compose.yml down

run:
cargo run --release

Expand Down
1 change: 1 addition & 0 deletions docker/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
7 changes: 7 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: "3.9"

services:
nats:
container_name: fuel-core-nats-server
image: nats:2.10.16
ports: [4222:4222]
13 changes: 0 additions & 13 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
#!/bin/bash

# Check if a command exists using which
check_command() {
if ! which "$1" >/dev/null 2>&1; then
echo "$1 is not installed. Please install $1 and try again."
exit 1
fi
}

# Check if Rust is installed
check_command rustup
# Check if pre-commit is installed
check_command pre-commit

# Install pre-commit hooks
pre-commit install

Expand Down

0 comments on commit 2a8857a

Please sign in to comment.