Skip to content

Commit

Permalink
build(dev env build makefile): added tmux dev env to makefile - makes…
Browse files Browse the repository at this point in the history
… a tmux session for local dev [2024-12-02]
  • Loading branch information
CHRISCARLON committed Dec 2, 2024
1 parent d404114 commit 0fc71c9
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ yarn-error.log*

# local env files
.env*.local
.env

# vercel
.vercel
Expand Down
55 changes: 52 additions & 3 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Get the current date
DATE := $(shell date +%Y-%m-%d)

# Import commit types from existing configuration
define COMMIT_TYPES
feat: A new feature
fix: A bug fix
Expand All @@ -16,10 +18,8 @@ endef
export COMMIT_TYPES

repo-update: git-add git-commit git-push

git-add:
git add .

git-commit:
@echo "Available commit types:"
@echo "$$COMMIT_TYPES" | sed 's/^/ /'
Expand All @@ -46,6 +46,55 @@ git-commit:
echo "Invalid commit type. Please use one of the available types."; \
exit 1; \
fi

git-push:
git push


# New commands for dev environment setup
.PHONY: dev-env dev-env-kill load-env docker-services backend frontend

# Load environment variables
load-env:
@if [ -f .env ]; then \
set -a; \
. .env; \
set +a; \
else \
echo "Error: .env file not found"; \
exit 1; \
fi

# Start Docker services
docker-services:
@echo "Starting Docker services..."
docker-compose up -d

# Start backend services
backend:
@echo "Starting backend services..."
cd gridwalk-backend && \
echo "$$AWS_PASS" | aws-vault exec gridw -- cargo run

# Start frontend services
frontend:
@echo "Starting frontend services..."
cd gridwalk-ui && \
npm run dev

# Main command to set up development environment
dev-env:
@echo "Setting up development environment..."
tmux new-session -d -s gridwalk
tmux rename-window -t gridwalk:0 'GRIDWALK DEV ENVIRONMENT'
tmux send-keys -t gridwalk:0 'docker-compose up -d' C-m
tmux send-keys -t gridwalk:0 'cd gridwalk-ui && npm run dev' C-m
tmux split-window -h -t gridwalk:0
tmux send-keys -t gridwalk:0.1 'cd gridwalk-backend && echo $$AWS_PASS | aws-vault exec gridw -- cargo run' C-m
tmux select-window -t gridwalk:0
tmux attach-session -t gridwalk

# Kill the development environment
dev-env-kill:
@echo "Shutting down development environment..."
tmux kill-session -t gridwalk 2>/dev/null || true
docker-compose down

0 comments on commit 0fc71c9

Please sign in to comment.