magic-pocket-cli 0.47.0__tar.gz → 0.48.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/.gitignore +1 -3
  2. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/PKG-INFO +2 -2
  3. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/main_cli.py +0 -2
  4. magic_pocket_cli-0.48.0/pocket_cli/cli/static_cli.py +32 -0
  5. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/django_cli.py +5 -3
  6. magic_pocket_cli-0.48.0/pocket_cli/paths.py +24 -0
  7. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/builders/__init__.py +9 -1
  8. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/builders/codebuild.py +4 -3
  9. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/builders/context_check.py +5 -5
  10. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/builders/depot.py +5 -3
  11. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/builders/docker.py +5 -3
  12. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/ecr.py +3 -0
  13. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/cloudfront.py +13 -5
  14. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/container.py +0 -17
  15. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pyproject.toml +2 -2
  16. magic_pocket_cli-0.47.0/pocket_cli/cli/runtime_config_cli.py +0 -272
  17. magic_pocket_cli-0.47.0/pocket_cli/cli/static_cli.py +0 -234
  18. magic_pocket_cli-0.47.0/pocket_cli/static_publish.py +0 -681
  19. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/__init__.py +0 -0
  20. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/__init__.py +0 -0
  21. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/aws_auth.py +0 -0
  22. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/backup_cli.py +0 -0
  23. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/build_cli.py +0 -0
  24. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/cleanup_deprecated_cli.py +0 -0
  25. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/cloudfront_cli.py +0 -0
  26. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/cloudfront_keys_cli.py +0 -0
  27. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/cloudfront_waf_cli.py +0 -0
  28. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/container_cli.py +0 -0
  29. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/deploy_cli.py +0 -0
  30. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/destroy_cli.py +0 -0
  31. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/dsql_cli.py +0 -0
  32. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/image_cli.py +0 -0
  33. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/inbound_cli.py +0 -0
  34. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/interaction.py +0 -0
  35. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/migrate_cli.py +0 -0
  36. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/neon_cli.py +0 -0
  37. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/permissions_cli.py +0 -0
  38. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/rds_cli.py +0 -0
  39. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/removed_flags.py +0 -0
  40. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/resource_helper.py +0 -0
  41. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/s3_cli.py +0 -0
  42. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/status_cli.py +0 -0
  43. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/store_url_helper.py +0 -0
  44. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/tidb_cli.py +0 -0
  45. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/upstash_cli.py +0 -0
  46. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/url_helper.py +0 -0
  47. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/vpc_cli.py +0 -0
  48. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/cli/waf_cli.py +0 -0
  49. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/mediator.py +0 -0
  50. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/migrations.py +0 -0
  51. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/__init__.py +0 -0
  52. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/__init__.py +0 -0
  53. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/backup_common.py +0 -0
  54. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/backup_legacy.py +0 -0
  55. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/builders/dockerignore.py +0 -0
  56. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/cloudformation.py +0 -0
  57. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/efs.py +0 -0
  58. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/iam_roles.py +0 -0
  59. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/lambdahandler.py +0 -0
  60. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/poll.py +0 -0
  61. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/s3_utils.py +0 -0
  62. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/stack_backed.py +0 -0
  63. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/stage_roles.py +0 -0
  64. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/state.py +0 -0
  65. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/backup.py +0 -0
  66. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/cloudfront_acm.py +0 -0
  67. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/cloudfront_keys.py +0 -0
  68. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/cloudfront_waf.py +0 -0
  69. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/dsql.py +0 -0
  70. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/inbound.py +0 -0
  71. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/inbound_domain.py +0 -0
  72. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/inbound_template.py +0 -0
  73. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/neon.py +0 -0
  74. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/rds.py +0 -0
  75. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/s3.py +0 -0
  76. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/sqs_alert.py +0 -0
  77. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/tidb.py +0 -0
  78. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/upstash.py +0 -0
  79. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/resources/vpc.py +0 -0
  80. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/templates/cloudformation/cf_function_api_host.js +0 -0
  81. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/templates/cloudformation/cf_function_basic_auth_prelude.js +0 -0
  82. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/templates/cloudformation/cf_function_cache_control.js +0 -0
  83. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/templates/cloudformation/cf_function_deploy_hash_strip.js +0 -0
  84. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/templates/cloudformation/cf_function_host_redirect_prelude.js +0 -0
  85. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/templates/cloudformation/cf_function_spa_auth.js +0 -0
  86. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/templates/cloudformation/cf_function_spa_fallback.js +0 -0
  87. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/templates/cloudformation/cloudfront.yaml +0 -0
  88. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/templates/cloudformation/cloudfront_acm.yaml +0 -0
  89. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/templates/cloudformation/cloudfront_keys.yaml +0 -0
  90. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/templates/cloudformation/cloudfront_waf.yaml +0 -0
  91. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/templates/cloudformation/container.yaml +0 -0
  92. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/templates/cloudformation/vpc.yaml +0 -0
  93. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/templates/init/django-dotenv.env +0 -0
  94. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/templates/init/django-settings.py +0 -0
  95. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/templates/init/pocket.Dockerfile +0 -0
  96. {magic_pocket_cli-0.47.0 → magic_pocket_cli-0.48.0}/pocket_cli/templates/init/pocket_simple.toml +0 -0
@@ -34,11 +34,9 @@ forge.local.toml
34
34
  # Activity Docs (作業ローカルの working doc。公開 repo には出さない)
35
35
  /docs/activity/
36
36
 
37
- # example deploy 生成物 (pocket が生成: runtime config / collectstatic 出力 / cache)
38
- /example-neon/pocket.runtime.toml
37
+ # example deploy 生成物 (pocket が生成: collectstatic 出力 / cache)
39
38
  /example-neon/pocket_cache/
40
39
  /example-neon/staticfiles/
41
- /example-tidb/pocket.runtime.toml
42
40
  /example-tidb/pocket_cache/
43
41
  /example-tidb/staticfiles/
44
42
 
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: magic-pocket-cli
3
- Version: 0.47.0
3
+ Version: 0.48.0
4
4
  Summary: CLI and deploy tools for magic-pocket.
5
5
  Requires-Python: >=3.10
6
6
  Requires-Dist: awscrt>=0.19.0
7
7
  Requires-Dist: click>=8.1.7
8
8
  Requires-Dist: deepdiff>=6.7.1
9
9
  Requires-Dist: jinja2>=3.1.3
10
- Requires-Dist: magic-pocket<0.48,>=0.47.0
10
+ Requires-Dist: magic-pocket<0.49,>=0.48.0
11
11
  Requires-Dist: pathspec>=1.0.4
12
12
  Requires-Dist: python-on-whales>=0.68.0
13
13
  Requires-Dist: pyyaml>=6.0.1
@@ -31,7 +31,6 @@ from pocket_cli.cli import (
31
31
  neon_cli,
32
32
  permissions_cli,
33
33
  rds_cli,
34
- runtime_config_cli,
35
34
  s3_cli,
36
35
  static_cli,
37
36
  status_cli,
@@ -131,7 +130,6 @@ main.add_command(deploy_cli.promote)
131
130
  main.add_command(destroy_cli.destroy)
132
131
  main.add_command(status_cli.status)
133
132
  main.add_command(django_cli.django if django_cli else _django_unavailable_command())
134
- main.add_command(runtime_config_cli.runtime_config)
135
133
  main.add_command(migrate_cli.migrate)
136
134
  main.add_command(permissions_cli.permissions)
137
135
  main.add_command(waf_cli.waf)
@@ -0,0 +1,32 @@
1
+ """`pocket static ...`: Rust 版 `pocket-rs static` への移行案内だけを出す stub。
2
+
3
+ 静的系 (object_hash route の publish / adopt / purge / status / hash generate) は
4
+ Rust 版に一本化した。サブコマンド・オプションは何を渡しても同じ案内を出して
5
+ 終了コード 2。
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import shlex
11
+ import sys
12
+
13
+ import click
14
+
15
+ INSTALL_DOCS_URL = "https://worgue.github.io/magic-pocket/guide/cli/#pocket-rs"
16
+
17
+
18
+ @click.command(
19
+ context_settings={"ignore_unknown_options": True, "allow_extra_args": True},
20
+ add_help_option=False,
21
+ )
22
+ @click.argument("args", nargs=-1, type=click.UNPROCESSED)
23
+ def static(args):
24
+ """(移行済み) Rust 版 `pocket-rs static` を使ってください。"""
25
+ replacement = shlex.join(("pocket-rs", "static", *args))
26
+ click.echo(
27
+ "`pocket static` は Rust 版 `pocket-rs static` に移りました。\n"
28
+ " 実行: %s\n"
29
+ " 導入: %s" % (replacement, INSTALL_DOCS_URL),
30
+ err=True,
31
+ )
32
+ sys.exit(2)
@@ -18,6 +18,7 @@ from pocket_cli.cli import interaction
18
18
  from pocket_cli.cli.build_cli import build
19
19
  from pocket_cli.cli.deploy_cli import run_deploy, run_promote
20
20
  from pocket_cli.cli.removed_flags import removed_skip_check_existing
21
+ from pocket_cli.paths import project_dir, project_path
21
22
  from pocket_cli.resources.container import Container
22
23
  from pocket_cli.resources.s3 import S3
23
24
 
@@ -305,7 +306,7 @@ def get_deploystatic_local_storage(stage: str):
305
306
  raise DeploystaticConfigError(
306
307
  "BACKEND %s is not supported" % storage["BACKEND"]
307
308
  )
308
- local_build_static_root = Path.cwd() / "pocket_cache" / "static_build" / stage
309
+ local_build_static_root = project_dir() / "pocket_cache" / "static_build" / stage
309
310
  return {
310
311
  "BACKEND": local_backend,
311
312
  "OPTIONS": {"location": str(local_build_static_root)},
@@ -390,8 +391,9 @@ def collectstatic_locally(stage: str, *, link: bool = False):
390
391
  if link:
391
392
  args.append("--link")
392
393
  cmd = _build_python_command(args)
393
- project_dir = _get_project_dir(stage)
394
- run(cmd, check=True, cwd=project_dir, env=_collectstatic_env(stage)) # noqa: S603 shell=False + 制御された引数
394
+ django_dir = _get_project_dir(stage)
395
+ cwd = project_path(django_dir) if django_dir else project_dir()
396
+ run(cmd, check=True, cwd=cwd, env=_collectstatic_env(stage)) # noqa: S603 shell=False + 制御された引数
395
397
  clear_staticfiles_override_env()
396
398
 
397
399
 
@@ -0,0 +1,24 @@
1
+ """pocket.toml の相対パスの基準 (project dir)。
2
+
3
+ pocket.toml は cwd から上方向に探すので、下位ディレクトリ (例: `frontend/`) から
4
+ 実行しても設定は読める。pocket.toml に書く相対パス (`dockerfile_path` / route の
5
+ `build` / `upload_dir` / `managed_assets` / django の `project_dir`) とビルド
6
+ コンテキストも、cwd ではなく見つけた pocket.toml のディレクトリを基準にする
7
+ (Rust 版 `pocket-rs static` と同じ基準)。
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ from pathlib import Path
13
+
14
+ from pocket.utils import get_toml_path
15
+
16
+
17
+ def project_dir() -> Path:
18
+ """pocket.toml のあるディレクトリ (絶対パス)"""
19
+ return get_toml_path().resolve().parent
20
+
21
+
22
+ def project_path(path: str) -> Path:
23
+ """pocket.toml からの相対パスを絶対パスにする (絶対パスはそのまま)"""
24
+ return project_dir() / path
@@ -3,6 +3,8 @@ from __future__ import annotations
3
3
  from typing import TYPE_CHECKING, Protocol
4
4
 
5
5
  if TYPE_CHECKING:
6
+ from pathlib import Path
7
+
6
8
  from pocket.context import BuildContext
7
9
 
8
10
 
@@ -11,9 +13,15 @@ class Builder(Protocol):
11
13
  self,
12
14
  *,
13
15
  target: str,
16
+ context_dir: Path,
14
17
  dockerfile_path: str,
15
18
  platform: str,
16
- ) -> None: ...
19
+ ) -> None:
20
+ """context_dir (= pocket.toml のディレクトリ) を context に build する。
21
+
22
+ dockerfile_path は context_dir からの相対パス。
23
+ """
24
+ ...
17
25
 
18
26
  def delete(self) -> None:
19
27
  """ビルドバックエンドのリソースを削除(不要なら何もしない)"""
@@ -87,10 +87,12 @@ class CodeBuildBuilder:
87
87
  self,
88
88
  *,
89
89
  target: str,
90
+ context_dir: Path,
90
91
  dockerfile_path: str,
91
92
  platform: str,
92
93
  ) -> None:
93
94
  print("CodeBuild でイメージをビルドします...")
95
+ print(" context: %s" % context_dir)
94
96
  print(" target: %s" % target)
95
97
  print(" dockerfile: %s" % dockerfile_path)
96
98
  print(" platform: %s" % platform)
@@ -103,7 +105,7 @@ class CodeBuildBuilder:
103
105
  # project の serviceRole を新ロールへ付け替えた後なので、旧名ロールは孤児
104
106
  if not self.external_roles:
105
107
  self._delete_role(self._legacy_role_name)
106
- self._upload_source(dockerfile_path)
108
+ self._upload_source(context_dir)
107
109
 
108
110
  build_id = self._start_build(
109
111
  target=target,
@@ -192,11 +194,10 @@ class CodeBuildBuilder:
192
194
 
193
195
  # --- ソースアップロード ---
194
196
 
195
- def _upload_source(self, dockerfile_path: str) -> None:
197
+ def _upload_source(self, context_dir: Path) -> None:
196
198
  import tempfile
197
199
 
198
200
  print(" ソースをS3にアップロード中...")
199
- context_dir = Path(".").resolve()
200
201
  spec = load_dockerignore(context_dir)
201
202
 
202
203
  # SpooledTemporaryFile: 50MB までメモリ、超えたらディスクへ自動退避
@@ -5,7 +5,7 @@ Lambda の実行ユーザーは非 root (sbx_user) のため、other-read の無
5
5
  読めず、全 handler が INIT フェーズで失敗する (wsgi も同居するためサイトごと
6
6
  500)。表面のエラーは Runtime.Unknown で原因に辿り着きにくいので、build 前に
7
7
  context を走査して legible に警告する。runtime が INIT で読む
8
- pocket.toml / pocket.runtime.toml はエラーに昇格する。
8
+ pocket.toml はエラーに昇格する。
9
9
 
10
10
  codebuild backend は source zip 作成時に mode を 0644/0755 へ正規化する
11
11
  (_add_source_file) ため対象外。docker / depot backend は context を生の
@@ -33,9 +33,9 @@ _MAX_LISTED = 10
33
33
  _warned_files: list[str] = []
34
34
 
35
35
  # runtime が INIT フェーズで読む設定ファイル。other-read が無いまま COPY される
36
- # と確実に INIT 失敗する (Rust runtime は pocket.toml を上方探索、Python runtime
37
- # は pocket.runtime.toml を読む) ため、警告でなくエラーに昇格する。
38
- _INIT_CRITICAL_NAMES = frozenset({"pocket.toml", "pocket.runtime.toml"})
36
+ # と確実に INIT 失敗する (Python / Rust の runtime とも pocket.toml を上方探索する)
37
+ # ため、警告でなくエラーに昇格する。
38
+ _INIT_CRITICAL_NAMES = frozenset({"pocket.toml"})
39
39
 
40
40
 
41
41
  def find_files_without_world_read(context_dir: Path) -> list[str]:
@@ -56,7 +56,7 @@ def warn_files_without_world_read(context_dir: Path) -> list[str]:
56
56
 
57
57
  一般ファイルを error にしないのは、Dockerfile 側で `COPY --chmod` や
58
58
  `RUN chmod` により image 内で正規化している構成では false positive に
59
- なるため。ただし runtime が INIT で読む pocket.toml / pocket.runtime.toml
59
+ なるため。ただし runtime が INIT で読む pocket.toml
60
60
  (_INIT_CRITICAL_NAMES) は該当 container が確実に INIT で死ぬうえ、非 secret
61
61
  の設定ファイルで local を `chmod 644` して困る構成が無いため error とする。
62
62
  """
@@ -31,6 +31,7 @@ class DepotBuilder:
31
31
  self,
32
32
  *,
33
33
  target: str,
34
+ context_dir: Path,
34
35
  dockerfile_path: str,
35
36
  platform: str,
36
37
  ) -> None:
@@ -38,22 +39,23 @@ class DepotBuilder:
38
39
 
39
40
  # context は生の permission のまま image に入るため build 前に検査する
40
41
  # (codebuild backend は zip 時に正規化されるので不要)
41
- warn_files_without_world_read(Path(".").resolve())
42
+ warn_files_without_world_read(context_dir)
42
43
 
43
44
  print("ECR にログインします...")
44
45
  docker.login_ecr(region_name=self.region)
45
46
 
46
47
  print("Depot でイメージをビルドします...")
47
48
  print(" target: %s" % target)
49
+ print(" context: %s" % context_dir)
48
50
  print(" dockerfile: %s" % dockerfile_path)
49
51
  print(" platform: %s" % platform)
50
52
 
51
53
  cmd = [
52
54
  "depot",
53
55
  "build",
54
- ".",
56
+ str(context_dir),
55
57
  "--file",
56
- dockerfile_path,
58
+ str(context_dir / dockerfile_path),
57
59
  "--tag",
58
60
  target,
59
61
  "--platform",
@@ -17,13 +17,15 @@ class DockerBuilder:
17
17
  self,
18
18
  *,
19
19
  target: str,
20
+ context_dir: Path,
20
21
  dockerfile_path: str,
21
22
  platform: str,
22
23
  ) -> None:
23
24
  # context は生の permission のまま image に入るため build 前に検査する
24
25
  # (codebuild backend は zip 時に正規化されるので不要)
25
- warn_files_without_world_read(Path(".").resolve())
26
+ warn_files_without_world_read(context_dir)
26
27
  print("Building docker image...")
28
+ print(" context: %s" % context_dir)
27
29
  print(" dockerpath: %s" % dockerfile_path)
28
30
  print(" tags: %s" % target)
29
31
  print(" platforms: %s" % platform)
@@ -31,8 +33,8 @@ class DockerBuilder:
31
33
  docker.login_ecr(region_name=self.region)
32
34
  print("Pushing docker image...")
33
35
  docker.build(
34
- ".",
35
- file=str(dockerfile_path),
36
+ str(context_dir),
37
+ file=str(context_dir / dockerfile_path),
36
38
  tags=target,
37
39
  platforms=[platform],
38
40
  provenance=False,
@@ -6,6 +6,8 @@ from typing import TYPE_CHECKING
6
6
  import boto3
7
7
  from pydantic import BaseModel, Field, computed_field
8
8
 
9
+ from pocket_cli.paths import project_dir
10
+
9
11
  if TYPE_CHECKING:
10
12
  from pocket_cli.resources.aws.builders import Builder
11
13
 
@@ -108,6 +110,7 @@ class Ecr:
108
110
  raise ValueError("builder is not configured")
109
111
  self._builder.build_and_push(
110
112
  target=target,
113
+ context_dir=project_dir(),
111
114
  dockerfile_path=self.dockerfile_path,
112
115
  platform=self.platform,
113
116
  )
@@ -16,6 +16,7 @@ from pydantic import BaseModel
16
16
 
17
17
  from pocket.resources.base import ResourceStatus
18
18
  from pocket.utils import echo
19
+ from pocket_cli.paths import project_dir, project_path
19
20
  from pocket_cli.resources.aws.cloudformation import CloudFrontStack
20
21
  from pocket_cli.resources.aws.s3_utils import delete_bucket_with_contents
21
22
 
@@ -243,7 +244,7 @@ class CloudFront:
243
244
  """managed_assets のファイルを S3 に同期する (全件 upload + 不要削除)。"""
244
245
  if not self.context.managed_assets:
245
246
  return
246
- base = Path(self.context.managed_assets)
247
+ base = project_path(self.context.managed_assets)
247
248
  stage_dir = base / self.context.stage
248
249
  if stage_dir.is_dir():
249
250
  asset_dir = stage_dir
@@ -296,7 +297,13 @@ class CloudFront:
296
297
  try:
297
298
  # route.build_cmd は pocket.toml の build.cmd (設定者 =
298
299
  # デプロイ実行者)。意図的な shell 実行のため S602 / semgrep を抑制。
299
- subprocess.run(route.build_cmd, shell=True, check=True) # noqa: S602 # nosemgrep
300
+ # 相対パスは pocket.toml のディレクトリ基準なので cwd もそこにする
301
+ subprocess.run( # noqa: S602
302
+ route.build_cmd,
303
+ shell=True, # nosemgrep
304
+ check=True,
305
+ cwd=project_dir(),
306
+ )
300
307
  except subprocess.CalledProcessError as e:
301
308
  echo.danger(
302
309
  "build コマンドが失敗しました (exit %d): %s"
@@ -384,7 +391,7 @@ class CloudFront:
384
391
  """route の upload_dir 配下のファイルを {S3 key: ローカル path} で返す。"""
385
392
  if not route.upload_dir:
386
393
  raise RuntimeError("route.upload_dir is not set")
387
- local_dir = Path(route.upload_dir)
394
+ local_dir = project_path(route.upload_dir)
388
395
  files: dict[str, Path] = {}
389
396
  for file in local_dir.rglob("*"):
390
397
  if file.is_dir():
@@ -448,8 +455,9 @@ class CloudFront:
448
455
  continue
449
456
  if route.is_object_hash:
450
457
  echo.info(
451
- "%s は object_hash route です。`pocket static publish --stage %s`"
452
- " で上げてください (deploy は触りません)"
458
+ "%s は object_hash route です。"
459
+ "`pocket-rs static publish --stage %s` で上げてください"
460
+ " (deploy は触りません)"
453
461
  % (route.path_pattern or "default", self.context.stage)
454
462
  )
455
463
  continue
@@ -1,6 +1,5 @@
1
1
  from __future__ import annotations
2
2
 
3
- from pathlib import Path
4
3
  from typing import TYPE_CHECKING
5
4
 
6
5
  import boto3
@@ -8,7 +7,6 @@ import boto3
8
7
  from pocket import context
9
8
  from pocket.resources.base import ResourceStatus
10
9
  from pocket.utils import echo
11
- from pocket_cli.cli.runtime_config_cli import generate_runtime_config
12
10
  from pocket_cli.mediator import Mediator
13
11
  from pocket_cli.resources.aws.builders import Builder, create_builder
14
12
  from pocket_cli.resources.aws.cloudformation import ContainerStack
@@ -88,10 +86,7 @@ class Container:
88
86
  """指定 tag (commit hash 等) で image を build & push する (deploy はしない)。
89
87
 
90
88
  build once 用。`:stage` タグは付けない。昇格は deploy 側で行う。
91
- pocket.runtime.toml は Dockerfile の COPY で image に焼き込まれるため、
92
- deploy_init と同様に build 前へ生成する。
93
89
  """
94
- generate_runtime_config(self._runtime_toml_path())
95
90
  ecr = self.ecr
96
91
  ecr.ensure_exists()
97
92
  ecr.build_and_push(tag=tag)
@@ -178,23 +173,11 @@ class Container:
178
173
  # 複数 container が deep merge で共存できるよう container 名で nest する
179
174
  return {"ecr": {self.context.name: {"repository_name": self.context.ecr_name}}}
180
175
 
181
- def _runtime_toml_path(self) -> Path:
182
- """pocket.runtime.toml の出力先を返す。
183
-
184
- django.project_dir が設定されていればその中に、
185
- なければ CWD に配置する。
186
- """
187
- if self.context.django and self.context.django.project_dir:
188
- return Path(self.context.django.project_dir) / "pocket.runtime.toml"
189
- return Path("pocket.runtime.toml")
190
-
191
176
  def deploy_init(self):
192
177
  if self.context.promote_commit_hash:
193
178
  # 昇格 (promote): 既存 :<hash> image へ :<stage> タグを移す。build しない。
194
- # runtime config は build 時に image へ焼き込み済みのため生成もしない。
195
179
  self.ecr.retag(self.context.promote_commit_hash, self.context.stage)
196
180
  else:
197
- generate_runtime_config(self._runtime_toml_path())
198
181
  self.ecr.sync()
199
182
  if self.context.vpc and not self.context.vpc.manage:
200
183
  vpc_stack = Vpc(self.context.vpc).stack
@@ -1,12 +1,12 @@
1
1
  [project]
2
2
  name = "magic-pocket-cli"
3
- version = "0.47.0"
3
+ version = "0.48.0"
4
4
  description = "CLI and deploy tools for magic-pocket."
5
5
  requires-python = ">=3.10"
6
6
  dependencies = [
7
7
  # lib は同 minor に束縛する。0.x では minor が breaking の単位のため、
8
8
  # 上限なしだと cli を pin した消費者にも lib の破壊的変更が届いてしまう
9
- "magic-pocket>=0.47.0,<0.48",
9
+ "magic-pocket>=0.48.0,<0.49",
10
10
  "click>=8.1.7",
11
11
  "jinja2>=3.1.3",
12
12
  "python-on-whales>=0.68.0",