Skip to content

Commit eb6405a

Browse files
authored
Merge pull request #32 from litencatt/change-default-generate-compose-yaml-name
デフォルトのファイル名をcompose.yml/compose.override.ymlに変更
2 parents af67417 + 03e2fcb commit eb6405a

File tree

9 files changed

+43
-43
lines changed

9 files changed

+43
-43
lines changed

DESIGN.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
### 目的
99
- Docker Composeのポートバインディング衝突を自動検出・解決
10-
- 元の`docker-compose.yml`を変更せずに`override.yml`を生成
11-
- ポート衝突解決後、自動的に`override.yml`を削除
10+
- 元の`compose.yml`を変更せずに`compose.override.yml`を生成
11+
- ポート衝突解決後、自動的に`compose.override.yml`を削除
1212

1313
### 技術スタック
1414
- **言語**: Go (1.21+)
@@ -40,7 +40,7 @@ graph TD
4040
4141
F --> K["Available Port Pool"]
4242
G --> L["Service Port Map"]
43-
H --> M["docker-compose.override.yml"]
43+
H --> M["compose.override.yml"]
4444
I --> N["Process Monitor"]
4545
J --> O["Auto Cleanup"]
4646
```
@@ -60,13 +60,13 @@ graph TD
6060
- プラットフォーム固有の実装を抽象化
6161

6262
3. **Docker Compose Parser** (`internal/parser/`)
63-
- `docker-compose.yml`の解析
63+
- `compose.yml`の解析
6464
- サービス・ポート情報の抽出
6565
- 複数フォーマット対応(YAML/JSON)
6666

6767
4. **Override Generator** (`internal/generator/`)
6868
- ポート衝突解決ロジック
69-
- `docker-compose.override.yml`構造生成
69+
- `compose.override.yml`構造生成
7070

7171
5. **File Manager** (`internal/file/`)
7272
- ファイル操作の抽象化
@@ -163,7 +163,7 @@ graph TD
163163

164164
#### 3.2.1 ポート衝突検出
165165
- システムの使用中ポート一覧取得
166-
- `docker-compose.yml`のポート設定解析
166+
- `compose.yml`のポート設定解析
167167
- 衝突ポートの特定
168168

169169
#### 3.2.2 自動ポート割り当て
@@ -172,7 +172,7 @@ graph TD
172172
- ポート番号の一貫性保持
173173

174174
#### 3.2.3 Override ファイル生成
175-
- 衝突解決用の`docker-compose.override.yml`作成
175+
- 衝突解決用の`compose.override.yml`作成
176176
- 元ファイルの構造保持
177177
- 最小限の変更のみ記述
178178

@@ -391,8 +391,8 @@ sequenceDiagram
391391

392392
**デフォルト設定**
393393
- ポート範囲: 8000-9999
394-
- Docker Composeファイル: docker-compose.yml
395-
- Overrideファイル: docker-compose.override.yml
394+
- Docker Composeファイル: compose.yml
395+
- Overrideファイル: compose.override.yml
396396

397397
**監視設定**
398398
- 監視間隔: 5秒
@@ -407,7 +407,7 @@ sequenceDiagram
407407
### 7.1 エラー種別
408408

409409
#### 7.1.1 ファイル関連エラー
410-
- `docker-compose.yml`が存在しない
410+
- `compose.yml`が存在しない
411411
- 権限不足でファイル作成できない
412412

413413
#### 7.1.2 ポート関連エラー

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212

1313
**gopose** (Go Port Override Solution Engine) is a tool that automatically detects and resolves Docker Compose port binding and network conflicts.
1414

15-
It generates a `docker-compose.override.yml` without modifying the original `docker-compose.yml`, and automatically deletes the `override.yml` after resolving port and network conflicts.
15+
It generates a `compose.override.yml` without modifying the original `compose.yml`, and automatically deletes the `override.yml` after resolving port and network conflicts.
1616

1717
### 🎯 Key Features
1818

19-
-**Non-destructive**: Does not modify the original `docker-compose.yml` file
19+
-**Non-destructive**: Does not modify the original `compose.yml` file
2020
-**Auto-detection**: Automatically detects conflicts with system ports in use
2121
-**Auto-resolution**: Automatically assigns available ports
2222
-**Network conflict avoidance**: Automatically detects and avoids Docker network subnet conflicts
@@ -133,8 +133,8 @@ port:
133133
exclude_privileged: true
134134

135135
file:
136-
compose_file: "docker-compose.yml"
137-
override_file: "docker-compose.override.yml"
136+
compose_file: "compose.yml"
137+
override_file: "compose.override.yml"
138138
backup_enabled: true
139139

140140
watcher:
@@ -227,14 +227,14 @@ time=2025-06-10T23:31:03.205+09:00 level=WARN msg="ネットワークサブネ
227227
time=2025-06-10T23:31:03.205+09:00 level=INFO msg="ネットワークサブネット競合を解決" component=gopose timestamp=2025-06-10T23:31:03.205+09:00 network=default original_subnet="172.20.0.0/24" new_subnet="10.20.0.0/24"
228228
time=2025-06-10T23:31:03.202+09:00 level=INFO msg=Override生成完了 component=gopose timestamp=2025-06-10T23:31:03.202+09:00 services_count=1
229229
time=2025-06-10T23:31:03.202+09:00 level=INFO msg=Override検証完了 component=gopose timestamp=2025-06-10T23:31:03.202+09:00
230-
time=2025-06-10T23:31:03.202+09:00 level=INFO msg=Overrideファイル書き込み完了 component=gopose timestamp=2025-06-10T23:31:03.202+09:00 output_path=docker-compose.override.yml file_size=607
231-
time=2025-06-10T23:31:03.202+09:00 level=INFO msg=Override.ymlファイルが生成されました component=gopose timestamp=2025-06-10T23:31:03.202+09:00 output_file=docker-compose.override.yml
230+
time=2025-06-10T23:31:03.202+09:00 level=INFO msg=Overrideファイル書き込み完了 component=gopose timestamp=2025-06-10T23:31:03.202+09:00 output_path=compose.override.yml file_size=607
231+
time=2025-06-10T23:31:03.202+09:00 level=INFO msg=Override.ymlファイルが生成されました component=gopose timestamp=2025-06-10T23:31:03.202+09:00 output_file=compose.override.yml
232232
time=2025-06-10T23:31:03.202+09:00 level=INFO msg="既存のコンテナを停止してからDocker Composeを起動" component=gopose timestamp=2025-06-10T23:31:03.202+09:00
233233
[+] Running 2/2
234234
✔ Container gopose-web-1 Removed 0.2s
235235
✔ Network gopose_default Removed 0.2s
236236
time=2025-06-10T23:31:03.779+09:00 level=INFO msg="Docker Composeを起動" component=gopose timestamp=2025-06-10T23:31:03.779+09:00
237-
time=2025-06-10T23:31:03.780+09:00 level=INFO msg="Docker Composeを実行" component=gopose timestamp=2025-06-10T23:31:03.780+09:00 command="docker compose -f /Users/keishi.hara/src/github.com/harakeishi/gopose/compose.yml -f docker-compose.override.yml up --force-recreate --remove-orphans"
237+
time=2025-06-10T23:31:03.780+09:00 level=INFO msg="Docker Composeを実行" component=gopose timestamp=2025-06-10T23:31:03.780+09:00 command="docker compose -f /Users/keishi.hara/src/github.com/harakeishi/gopose/compose.yml -f compose.override.yml up --force-recreate --remove-orphans"
238238
[+] Running 2/2
239239
✔ Network gopose_default Created 0.0s
240240
✔ Container gopose-web-1 Created 0.0s
@@ -268,7 +268,7 @@ networks:
268268
config:
269269
- subnet: 172.20.0.0/24 # Conflicts with other Docker networks
270270

271-
# Generated docker-compose.override.yml
271+
# Generated compose.override.yml
272272
networks:
273273
app-network:
274274
ipam:

README_JA.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212

1313
**gopose** (Go Port Override Solution Engine) は、Docker Compose のポートバインディング衝突とネットワーク衝突を自動検出・解決するツールです。
1414

15-
元の `docker-compose.yml` を変更せずに `docker-compose.override.yml` を生成し、ポート衝突・ネットワーク衝突解決後、自動的に `override.yml` を削除します。
15+
元の `compose.yml` を変更せずに `compose.override.yml` を生成し、ポート衝突・ネットワーク衝突解決後、自動的に `override.yml` を削除します。
1616

1717
### 🎯 主な特徴
1818

19-
-**非破壊的**: 元の `docker-compose.yml` ファイルを変更しません
19+
-**非破壊的**: 元の `compose.yml` ファイルを変更しません
2020
-**自動検出**: システムの使用中ポートとの衝突を自動検出
2121
-**自動解決**: 利用可能なポートを自動割り当て
2222
-**ネットワーク衝突回避**: Dockerネットワークのサブネット衝突を自動検出・回避
@@ -133,8 +133,8 @@ port:
133133
exclude_privileged: true
134134

135135
file:
136-
compose_file: "docker-compose.yml"
137-
override_file: "docker-compose.override.yml"
136+
compose_file: "compose.yml"
137+
override_file: "compose.override.yml"
138138
backup_enabled: true
139139

140140
watcher:
@@ -227,14 +227,14 @@ time=2025-06-10T23:31:03.205+09:00 level=WARN msg="ネットワークサブネ
227227
time=2025-06-10T23:31:03.205+09:00 level=INFO msg="ネットワークサブネット競合を解決" component=gopose timestamp=2025-06-10T23:31:03.205+09:00 network=default original_subnet="172.20.0.0/24" new_subnet="10.20.0.0/24"
228228
time=2025-06-10T23:31:03.202+09:00 level=INFO msg=Override生成完了 component=gopose timestamp=2025-06-10T23:31:03.202+09:00 services_count=1
229229
time=2025-06-10T23:31:03.202+09:00 level=INFO msg=Override検証完了 component=gopose timestamp=2025-06-10T23:31:03.202+09:00
230-
time=2025-06-10T23:31:03.202+09:00 level=INFO msg=Overrideファイル書き込み完了 component=gopose timestamp=2025-06-10T23:31:03.202+09:00 output_path=docker-compose.override.yml file_size=607
231-
time=2025-06-10T23:31:03.202+09:00 level=INFO msg=Override.ymlファイルが生成されました component=gopose timestamp=2025-06-10T23:31:03.202+09:00 output_file=docker-compose.override.yml
230+
time=2025-06-10T23:31:03.202+09:00 level=INFO msg=Overrideファイル書き込み完了 component=gopose timestamp=2025-06-10T23:31:03.202+09:00 output_path=compose.override.yml file_size=607
231+
time=2025-06-10T23:31:03.202+09:00 level=INFO msg=Override.ymlファイルが生成されました component=gopose timestamp=2025-06-10T23:31:03.202+09:00 output_file=compose.override.yml
232232
time=2025-06-10T23:31:03.202+09:00 level=INFO msg="既存のコンテナを停止してからDocker Composeを起動" component=gopose timestamp=2025-06-10T23:31:03.202+09:00
233233
[+] Running 2/2
234234
✔ Container gopose-web-1 Removed 0.2s
235235
✔ Network gopose_default Removed 0.2s
236236
time=2025-06-10T23:31:03.779+09:00 level=INFO msg="Docker Composeを起動" component=gopose timestamp=2025-06-10T23:31:03.779+09:00
237-
time=2025-06-10T23:31:03.780+09:00 level=INFO msg="Docker Composeを実行" component=gopose timestamp=2025-06-10T23:31:03.780+09:00 command="docker compose -f /Users/keishi.hara/src/github.com/harakeishi/gopose/compose.yml -f docker-compose.override.yml up --force-recreate --remove-orphans"
237+
time=2025-06-10T23:31:03.780+09:00 level=INFO msg="Docker Composeを実行" component=gopose timestamp=2025-06-10T23:31:03.780+09:00 command="docker compose -f /Users/keishi.hara/src/github.com/harakeishi/gopose/compose.yml -f compose.override.yml up --force-recreate --remove-orphans"
238238
[+] Running 2/2
239239
✔ Network gopose_default Created 0.0s
240240
✔ Container gopose-web-1 Created 0.0s
@@ -268,7 +268,7 @@ networks:
268268
config:
269269
- subnet: 172.20.0.0/24 # 他のDockerネットワークと衝突
270270

271-
# 生成されるdocker-compose.override.yml
271+
# 生成されるcompose.override.yml
272272
networks:
273273
app-network:
274274
ipam:

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var rootCmd = &cobra.Command{
2727
Short: "Docker Compose ポート衝突自動解決ツール",
2828
Long: `gopose は Docker Compose のポートバインディング衝突を自動検出・解決するツールです。
2929
30-
元の docker-compose.yml を変更せずに docker-compose.override.yml を生成し、
30+
元の compose.yml を変更せずに compose.override.yml を生成し、
3131
ポート衝突解決後、自動的に override.yml を削除します。`,
3232
Example: ` # ポート衝突を検出・解決してDocker Composeを準備
3333
gopose up

cmd/up.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ var upCmd = &cobra.Command{
168168
types.Field{Key: "port_range", Value: fmt.Sprintf("%d-%d", portConfig.Range.Start, portConfig.Range.End)})
169169

170170
// Docker Composeファイルの自動検出(指定されていない場合)
171-
if filePath == "" || filePath == "docker-compose.yml" {
172-
wd, err := os.Getwd()
171+
if filePath == "" || filePath == "compose.yml" {
172+
wd, err := os.Getwd()
173173
if err != nil {
174174
return fmt.Errorf("作業ディレクトリの取得に失敗: %w", err)
175175
}
@@ -274,7 +274,7 @@ var upCmd = &cobra.Command{
274274

275275
// 出力ファイル名の決定
276276
if outputFile == "" {
277-
outputFile = "docker-compose.override.yml"
277+
outputFile = "compose.override.yml"
278278
}
279279

280280
// ドライランモードでない場合のみファイル書き込み
@@ -308,12 +308,12 @@ func init() {
308308
// gopose固有のフラグを定義
309309
upCmd.Flags().StringVar(&portRange, "port-range", "", "利用するポート範囲 (例: 8000-9999)")
310310
upCmd.Flags().StringVar(&strategy, "strategy", "auto", "解決戦略 (auto, range, user)")
311-
upCmd.Flags().StringVarP(&outputFile, "output", "o", "", "出力ファイル名 (デフォルト: docker-compose.override.yml)")
311+
upCmd.Flags().StringVarP(&outputFile, "output", "o", "", "出力ファイル名 (デフォルト: compose.override.yml)")
312312
upCmd.Flags().BoolVar(&dryRun, "dry-run", false, "ドライラン(override.yml生成のみ、Docker Composeは実行しない)")
313313
upCmd.Flags().BoolVar(&skipComposeUp, "skip-compose-up", false, "[非推奨] このオプションは不要になりました。デフォルトでdocker compose upは実行されません。")
314314

315315
// Docker Composeオプションもサポート(透過的に渡される)
316-
upCmd.Flags().StringVarP(&filePath, "file", "f", "docker-compose.yml", "Docker Composeファイルのパス")
316+
upCmd.Flags().StringVarP(&filePath, "file", "f", "compose.yml", "Docker Composeファイルのパス")
317317
upCmd.Flags().StringVarP(&composeProjectName, "project-name", "p", "", "Docker Composeプロジェクト名")
318318
upCmd.Flags().BoolP("detach", "d", false, "Detached mode: バックグラウンドでサービスを実行")
319319
upCmd.Flags().Bool("build", false, "サービス起動前にイメージをビルド")

internal/config/default.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ func DefaultConfig() *types.AppConfig {
1818
ExcludePrivileged: true,
1919
},
2020
File: types.FileConfig{
21-
ComposeFile: "docker-compose.yml",
22-
OverrideFile: "docker-compose.override.yml",
21+
ComposeFile: "compose.yml",
22+
OverrideFile: "compose.override.yml",
2323
BackupEnabled: true,
2424
BackupDir: ".gopose/backups",
2525
},
@@ -55,8 +55,8 @@ func DefaultPortConfig() types.PortConfig {
5555
// DefaultFileConfig はデフォルトのファイル設定を返します。
5656
func DefaultFileConfig() types.FileConfig {
5757
return types.FileConfig{
58-
ComposeFile: "docker-compose.yml",
59-
OverrideFile: "docker-compose.override.yml",
58+
ComposeFile: "compose.yml",
59+
OverrideFile: "compose.override.yml",
6060
BackupEnabled: true,
6161
BackupDir: ".gopose/backups",
6262
}

internal/generator/override.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,11 @@ func (g *OverrideGeneratorImpl) generateFileHeader() string {
321321
# Generated at: %s
322322
#
323323
# This file contains port mappings to resolve conflicts detected in your
324-
# original docker-compose.yml file. The original file remains unchanged.
325-
#
324+
# original compose.yml file. The original file remains unchanged.
325+
#
326326
# To use this override:
327-
# 1. Keep this file in the same directory as your docker-compose.yml
328-
# 2. Run: docker-compose up
327+
# 1. Keep this file in the same directory as your compose.yml
328+
# 2. Run: docker compose up
329329
#
330330
# Docker Compose will automatically merge both files.
331331
#

internal/parser/yaml.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,10 +549,10 @@ func (d *ComposeFileDetectorImpl) DetectComposeFiles(ctx context.Context, direct
549549

550550
// 標準的なファイル名のリスト
551551
candidates := []string{
552-
"docker-compose.yml",
553-
"docker-compose.yaml",
554552
"compose.yml",
555553
"compose.yaml",
554+
"docker-compose.yml",
555+
"docker-compose.yaml",
556556
}
557557

558558
var foundFiles []string

testdata/gopose/gopose_e2e_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
desc: "gopose E2E Test Suite"
22

33
vars:
4-
override_file: "docker-compose.override.yml"
4+
override_file: "compose.override.yml"
55

66
steps:
77
- desc: "Dry-run mode works correctly"

0 commit comments

Comments
 (0)