Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(repo): allow starting & stopping nats server locally #19

Merged
merged 3 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
image: nats:2.10.16
ports: [4222:4222]
command: [--name=fuel-core-nats-server, --js]
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
pedronauck marked this conversation as resolved.
Show resolved Hide resolved

# Install pre-commit hooks
pre-commit install

Expand Down