| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A Rails web application that implements a simple counter and sends count updates to other app instances via AWS SQS, all running in a LocalStack development environment within devcontainers.
simple-app-localstack/ ├── .devcontainer/ # VS Code devcontainer configuration │ └── devcontainer.json # Container setup with Rails, AWS CLI, Terraform ├── app/ # Rails application │ ├── Gemfile # Ruby dependencies │ ├── config/ # Rails configuration │ └── ... # Standard Rails structure ├── infrastructure/ # Terraform configuration │ ├── main.tf # Provider and LocalStack configuration │ ├── sqs.tf # SQS queue definitions │ └── outputs.tf # Terraform outputs ├── scripts/ # Setup and utility scripts │ └── setup.sh # Development environment setup ├── app-docker-images/ # Dockerfiles for app images (dev/prod) └── README.md # This file
Once the devcontainer is running:
Start the Rails server:
cd /workspace/app
rails serverAccess the application: http://localhost:3000
Access LocalStack: http://localhost:4566
Monitor SQS queues:
aws --endpoint-url=http://localstack:4566 sqs list-queuesThe devcontainer automatically sets up these environment variables:
AWS_DEFAULT_REGION=us-east-1
AWS_ACCESS_KEY_ID=test
AWS_SECRET_ACCESS_KEY=test
LOCALSTACK_ENDPOINT=http://localstack:4566
COUNTER_QUEUE_URL=http://localstack:4566/000000000000/counter-queue
REDIS_URL=redis://redis:6379/0Infrastructure is defined in the infrastructure/ directory:
After setting up the basic structure, you'll want to:
Generate Rails components:
rails generate controller Counter index
rails generate model CounterEvent count:integer message:textImplement the counter logic:
Add views and styling:
rails server # Start the Rails server
rails console # Rails console
rails generate --help # See available generators
rails db:migrate # Run database migrationscd infrastructure
terraform plan # Preview changes
terraform apply # Apply changes
terraform destroy # Destroy infrastructure# List SQS queues
aws --endpoint-url=http://localstack:4566 sqs list-queues
# Send a test message
aws --endpoint-url=http://localstack:4566 sqs send-message \
--queue-url http://localstack:4566/000000000000/counter-queue \
--message-body "Test message"
# Receive messages
aws --endpoint-url=http://localstack:4566 sqs receive-message \
--queue-url http://localstack:4566/000000000000/counter-queue./scripts/start-supporting-services.sh # starts Redis and registry via docker run
./scripts/registry-bridge.sh status # show registry status and list images
## 🧰 Devcontainer image and developer tooling
This repository now builds the devcontainer from a Dockerfile (`.devcontainer/Dockerfile`) so we can bake developer tools into the image.
- Tools installed in the devcontainer image:
- `redis-cli` (provided by `redis-tools`) — quick Redis checks and troubleshooting
- `jq` — JSON CLI processor
- `http` (HTTPie) — friendlier HTTP client than curl for quick API calls
### Rebuild the devcontainer
After pulling the repo changes you'll need to rebuild the devcontainer so the new Dockerfile is used. In VS Code:
1. Open the Command Palette (Ctrl/Cmd+Shift+P)
2. Select `Dev Containers: Rebuild and Reopen in Container`
Or using the Dev Container CLI:
```bash
npm i -g @devcontainers/cli
devcontainer build --workspace-folder . --file .devcontainer/Dockerfile
devcontainer up --workspace-folder .which redis-cli jq http You can use the helper scripts to manage supporting services (registry and Redis) and the Local Docker registry:
./scripts/start-supporting-services.sh # starts Redis and registry via docker run
./scripts/registry-bridge.sh start # starts the local registry only (if needed)
./scripts/registry-bridge.sh status # show registry status and list images
./scripts/registry-bridge.sh clean # remove registry container & dataUse the helper script to start local supporting services (Redis and a local Docker registry):
./scripts/start-supporting-services.shIf you need to stop/remove them:
docker rm -f redis registry || true## 🐛 Troubleshooting ### LocalStack not responding ```bash # Check LocalStack health curl http://localhost:4566/health # Restart LocalStack (example using Docker) docker restart <localstack-container-name> # Or if you use the LocalStack CLI or supervisor, restart via that tool
# Check if gems are installed
bundle check
# Reinstall gems
bundle install
# Check database
rails db:create db:migrateMake sure these ports are available on your host machine.
| Back | FazBrowse Home | New Git URL |