Skip to content
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
1 change: 1 addition & 0 deletions .github/workflows/deploy-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
run: |
DOCKER_BUILDKIT=0 docker build \
--platform linux/amd64 \
--target production \
-t registry.heroku.com/${HEROKU_BACKEND_APP}/web \
-f backend/Dockerfile backend

Expand Down
55 changes: 55 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Docker Compose Commands for Different Environments

# Development - with hot reload and dev tools
dev:
docker compose -f docker-compose.dev.yml up --build

dev-detached:
docker compose -f docker-compose.dev.yml up --build -d

# Production - optimized builds
prod:
docker compose -f docker-compose.prod.yml up --build

prod-detached:
docker compose -f docker-compose.prod.yml up --build -d

# Testing - run tests in containers
test:
docker compose -f docker-compose.test.yml up --build --abort-on-container-exit

# Database only - just PostgreSQL
db:
docker compose -f docker-compose.db-only.yml up -d

# Clean up
clean:
docker compose -f docker-compose.dev.yml down -v
docker compose -f docker-compose.prod.yml down -v
docker compose -f docker-compose.test.yml down -v
docker compose -f docker-compose.db-only.yml down -v

# Stop all services
stop:
docker compose -f docker-compose.dev.yml down
docker compose -f docker-compose.prod.yml down
docker compose -f docker-compose.test.yml down
docker compose -f docker-compose.db-only.yml down

# View logs
logs-dev:
docker compose -f docker-compose.dev.yml logs -f

logs-prod:
docker compose -f docker-compose.prod.yml logs -f

# Shell access
shell-backend-dev:
docker compose -f docker-compose.dev.yml exec backend bash

shell-backend-prod:
docker compose -f docker-compose.prod.yml exec backend bash

# Database access
db-shell:
docker compose -f docker-compose.db-only.yml exec postgres psql -U guild_user -d guild_genesis
95 changes: 88 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,107 @@ This is a monorepo containing:

### Prerequisites
- [Docker](https://www.docker.com/)
- [Node.js](https://nodejs.org/) (for frontend development)
- [Astro CLI](https://docs.astro.build/en/getting-started/) (for frontend development)
- [Foundry](https://book.getfoundry.sh/getting-started/installation) (for smart contracts)

### Environment Setup

Create a `.env` file in the project root with the following variables:

```bash
# Database
DATABASE_URL=postgresql://guild_user:guild_password@localhost:5433/guild_genesis

# Frontend Environment Variables
PUBLIC_WALLET_CONNECT_PROJECT_ID=your_wallet_connect_project_id
PUBLIC_API_URL=http://localhost:3001
PUBLIC_BADGE_REGISTRY_ADDRESS=0x...
PUBLIC_EAS_CONTRACT_ADDRESS=0x...
PUBLIC_ACTIVITY_TOKEN_ADDRESS=0x...
PUBLIC_SCHEMA_ID=0x...

# Discord Bot (if using)
DISCORD_TOKEN=your_discord_bot_token
DISCORD_CLIENT_ID=your_discord_client_id
DISCORD_GUILD_ID=your_discord_guild_id

# Optional: Skip migrations in development
SKIP_MIGRATIONS=1

# Optional: Disable SQLx compile-time validation
SQLX_OFFLINE=true
```

**Required for Production:**
- `DATABASE_URL` - PostgreSQL connection string
- `PUBLIC_WALLET_CONNECT_PROJECT_ID` - Get from [WalletConnect Cloud](https://cloud.walletconnect.com/)
- Contract addresses - Deploy smart contracts first

**Optional for Development:**
- `SKIP_MIGRATIONS=1` - Skip automatic migrations (run manually)
- `SQLX_OFFLINE=true` - Disable SQLx compile-time validation

### Development Workflow

#### Quick Start
#### Option 1: Docker Compose (Recommended)

We provide multiple Docker Compose configurations for different environments:

```bash
# Development with hot reload
make dev

# Production build
make prod

# Run tests
make test

# Database only
make db

# Stop all services
make stop
```

#### Option 2: Local Development

**Backend:**
```bash
cd backend
cargo install sqlx-cli --no-default-features --features rustls,postgres
cargo sqlx prepare -- --bin guild-backend
```

**Frontend:**
```bash
cd frontend
npm install
npm run dev
```

**Database:**
```bash
docker compose up -d postgres
```

### Docker Compose Environments

- **`docker-compose.dev.yml`** - Development with hot reload, volume mounts, and dev tools
- **`docker-compose.prod.yml`** - Production with optimized builds and restart policies
- **`docker-compose.test.yml`** - Testing environment with test-specific configurations
- **`docker-compose.db-only.yml`** - Just PostgreSQL for local development

Use `make` commands or specify files directly:
```bash
docker-compose up -d
docker compose -f docker-compose.dev.yml up --build
```

**Access the applications:**
- Frontend: http://localhost:4321
- Frontend: http://localhost:3000
- Backend API: http://localhost:3001
- PostgreSQL: localhost:5432
- PostgreSQL: localhost:5433

#### Smart Contracts Development

Expand Down Expand Up @@ -131,9 +212,9 @@ event BadgeCreated(bytes32 indexed name, bytes32 description, address indexed cr
- [x] Web3 wallet integration
- [x] Basic profile and badge system
- [x] Smart contracts for on-chain badges
- [ ] SIWE authentication
- [x] SIWE authentication
- [ ] Database models and migrations
- [ ] API endpoints for profiles and badges
- [x] API endpoints for profiles and badges

### V1+ (Future)
- [ ] Gasless transactions
Expand All @@ -152,7 +233,7 @@ event BadgeCreated(bytes32 indexed name, bytes32 description, address indexed cr

## Contributing

This is a community-driven project. Join our [Discord](https://discord.gg/pg4UgaTr) to discuss features, propose changes, and contribute to the codebase.
This is a community-driven project. Join our [Discord](https://discord.gg/axCqT23Xhj) to discuss features, propose changes, and contribute to the codebase.

See detailed steps in [CONTRIBUTION.md](CONTRIBUTION.md).

Expand Down
34 changes: 34 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Rust build artifacts
target/
Cargo.lock

# IDE files
.vscode/
.idea/
*.swp
*.swo

# OS files
.DS_Store
Thumbs.db

# Git
.git/
.gitignore

# Documentation
README.md
*.md

# Environment files
.env
.env.local
.env.*.local

# Logs
*.log
logs/

# Temporary files
tmp/
temp/
25 changes: 21 additions & 4 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
FROM rust:latest AS build
FROM rust:latest AS base
WORKDIR /app

# Development stage
FROM base AS dev
RUN cargo install cargo-watch
COPY . .
ENV RUST_LOG=debug RUST_BACKTRACE=1
CMD ["cargo", "watch", "-x", "run --bin guild-backend"]

# Test stage
FROM base AS test
COPY . .
CMD ["cargo", "test", "--", "--test-threads=1"]

# Build stage
FROM base AS build
WORKDIR /app
ENV SQLX_OFFLINE=true
COPY . .
RUN cargo build --release

FROM debian:bookworm-slim
# Production stage
FROM debian:bookworm-slim AS production
RUN apt-get update && apt-get install -y --no-install-recommends \
netcat-openbsd \
&& rm -rf /var/lib/apt/lists/*
RUN useradd -m appuser
WORKDIR /app
COPY --from=build /app/target/release/guild-backend /app/app
COPY --from=build /app/target/release/guild-backend /app/guild-backend
ENV RUST_LOG=info PORT=3001
EXPOSE 3001
USER appuser
CMD ["/app/app"]
CMD ["/app/guild-backend"]

Loading
Loading