メインコンテンツまでスキップ

開発環境セットアップ

開発環境を構築するための詳細な手順です。

必要なツール

Go 1.25+

# macOS (Homebrew)
brew install go@1.25

# Ubuntu/Debian
# https://go.dev/dl/ からインストール

# バージョン確認
go version

Node.js 22+ と pnpm

# Node.js インストール(nvm推奨)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
nvm install 22
nvm use 22

# pnpm インストール
npm install -g pnpm@10.18.1

# バージョン確認
node --version # v22.x.x
pnpm --version # 10.18.1

Docker & Docker Compose

# macOS
brew install --cask docker

# Ubuntu
sudo apt-get update
sudo apt-get install docker.io docker-compose-plugin

# バージョン確認
docker --version
docker compose version

buf (Protocol Buffers)

# macOS (Homebrew)
brew install bufbuild/buf/buf

# その他のOS
# https://buf.build/docs/installation からインストール

# バージョン確認
buf --version

セットアップ手順

1. リポジトリクローン

git clone <repository-url>
cd bazbii

2. 依存関係インストール

# フロントエンド依存関係
pnpm install

# Go依存関係(自動的に整理される)
make go/tidy

3. 環境変数設定(必要に応じて)

# 開発環境の環境変数ファイルを確認
ls infra/env/dev/

4. データベース起動

# PostgreSQLコンテナ起動
make compose/db.up

# マイグレーション実行
make db/mig-up

# 動作確認
make compose/db.logs

5. アプリケーション起動

# 全コンテナ起動
make compose/up

# ログ確認(別ターミナル)
make compose/logs

6. 動作確認

# ヘルスチェック
curl http://localhost:3000/healthz

# API動作確認(オプション)
curl http://localhost:3000/app/v1/timeline?center_h3=617700169958678527

IDE設定

VS Code推奨拡張機能

  • Go (golang.go)
  • TypeScript and JavaScript Language Features
  • Docker
  • Protocol Buffers (buf)

エディタ設定

.editorconfigがプロジェクトに含まれている場合、エディタが自動的に設定を適用します。

トラブルシューティング

ポート競合

# 使用中のポートを確認
sudo lsof -i :5432 # PostgreSQL
sudo lsof -i :8080 # API Server
sudo lsof -i :3000 # Gateway

# Docker Composeのポートを変更する場合は
# infra/env/dev/ports.env を編集

データベース接続エラー

# データベースコンテナの状態確認
docker ps | grep postgres

# データベースコンテナ再起動
make compose/db.reset
make db/reset

依存関係の問題

# Go依存関係整理
make go/tidy

# pnpm依存関係整理
pnpm install

# キャッシュクリア
make go/clean
rm -rf node_modules
pnpm install

Protocol Buffers生成エラー

# bufのバージョン確認
buf --version

# コード再生成
make proto/gen

関連ドキュメント