diff --git a/DOCKER.md b/DOCKER.md index 192cb17..52c5cea 100644 --- a/DOCKER.md +++ b/DOCKER.md @@ -21,7 +21,7 @@ Development environment configuration with: - PostgreSQL 18 database - Redis 8 for caching and sessions (with separate test database) - Rails web application with automatic database preparation -- JavaScript and CSS build watchers (using profiles) +- JavaScript and CSS build watchers - Test service for isolated test runs - Health checks for all services - Volume mounts for development @@ -102,11 +102,10 @@ defaults (`.env.production` and `streamsource:latest`). - **Dependencies**: Waits for DB and Redis health - **Automatic database setup**: Runs migrations on startup -### JavaScript/CSS Watchers (Optional) +### JavaScript/CSS Watchers - **js service**: Watches and rebuilds JavaScript - **css service**: Watches and rebuilds CSS -- **Profile**: `assets` (manual start) -- **Usage**: `docker compose --profile assets up js css` +- **Default**: Included in `docker compose up -d` ## Test Environment @@ -175,9 +174,9 @@ docker compose exec web yarn build # Build CSS docker compose exec web yarn build:css -# Watch mode (using separate services) -docker compose --profile assets up js -docker compose --profile assets up css +# Watch mode (separate services) +docker compose up -d js +docker compose up -d css # Install new JavaScript packages docker compose exec web yarn add @@ -382,9 +381,8 @@ The Dockerfile uses a multi-stage build: ### Service Profiles -Docker Compose uses profiles to manage optional services: -- Default profile: web, db, redis -- `donotstart` profile: js, css (build watchers) +Docker Compose uses profiles for the test runner only: +- Default services: web, db, redis, js, css - Test profile: Separate test runner ### Database Initialization diff --git a/GETTING_STARTED.md b/GETTING_STARTED.md index e07edcb..a8e9a9a 100644 --- a/GETTING_STARTED.md +++ b/GETTING_STARTED.md @@ -191,12 +191,12 @@ make assets-dev # Compile assets for development # Diagnose common problems make doctor -# Clean up and rebuild -make clean +# Rebuild (keeps build cache) make rebuild -# Deep clean (removes everything) -make clean-all +# Deep clean (removes containers, volumes, local images, build cache) +make clean +make rebuild ``` ### Database Problems diff --git a/Makefile b/Makefile index 22c69b8..ae2f5e4 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # StreamSource # Usage: make [command] -.PHONY: help up down stop restart shell test migrate seed setup reset logs lint lint-fix lint-ruby lint-js security quality pre-commit pre-commit-install rebuild browse rake yarn +.PHONY: help up down stop restart shell test migrate seed setup reset logs lint lint-fix lint-ruby lint-js security quality pre-commit pre-commit-install rebuild clean browse rake yarn STREAMSOURCE_ENV ?= dev APP_URL ?= http://localhost:3001/admin @@ -9,15 +9,13 @@ APP_URL ?= http://localhost:3001/admin ifeq ($(STREAMSOURCE_ENV),prod) COMPOSE_FILES := -f docker-compose.yml -f docker-compose.prod.yml UP_TARGETS := web -UP_PROFILE := else COMPOSE_FILES := UP_TARGETS := web js css -UP_PROFILE := --profile assets endif COMPOSE := docker compose $(COMPOSE_FILES) -COMPOSE_UP := $(COMPOSE) $(UP_PROFILE) +COMPOSE_UP := $(COMPOSE) COMPOSE_EXEC_FLAGS ?= COMPOSE_EXEC := $(COMPOSE) exec $(COMPOSE_EXEC_FLAGS) @@ -47,6 +45,7 @@ help: @echo " pre-commit-install - Install pre-commit hooks (commit + pre-push)" @echo " yarn - Build JS/CSS assets" @echo " rebuild - Clean and rebuild containers" + @echo " clean - Remove containers, volumes, images, and build cache" @echo " migrate - Run migrations" @echo " seed - Seed the database" @echo " setup - Create, migrate, and seed the database" @@ -137,9 +136,13 @@ yarn: rebuild: $(COMPOSE) down --remove-orphans - $(COMPOSE) build --no-cache + $(COMPOSE) build $(COMPOSE_UP) up -d $(UP_TARGETS) +clean: + $(COMPOSE) down --remove-orphans --volumes --rmi local + docker builder prune -f + migrate: $(COMPOSE_EXEC) web bin/rails db:migrate diff --git a/QUICK_REFERENCE.md b/QUICK_REFERENCE.md index 74383dc..7152b27 100644 --- a/QUICK_REFERENCE.md +++ b/QUICK_REFERENCE.md @@ -25,8 +25,8 @@ docker compose exec web yarn build docker compose exec web yarn build:css # Watch assets (separate services) -docker compose --profile donotstart up js -docker compose --profile donotstart up css +docker compose up -d js +docker compose up -d css # Stop all services docker compose down @@ -400,4 +400,4 @@ docker compose exec web bin/rails initializers # View stats docker compose exec web bin/rails stats -``` \ No newline at end of file +``` diff --git a/docker-compose.yml b/docker-compose.yml index db8ab25..29d51d5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -48,12 +48,12 @@ services: js: build: . - command: yarn build --watch + command: yarn build --watch=forever volumes: - .:/rails:cached working_dir: /rails - profiles: - - assets + stdin_open: true + tty: true css: build: . @@ -61,8 +61,8 @@ services: volumes: - .:/rails:cached working_dir: /rails - profiles: - - assets + stdin_open: true + tty: true test: build: