Skip to content
Open
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
31 changes: 27 additions & 4 deletions src/ol_concourse/pipelines/infrastructure/k8s_apps/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ class AppPipelineParams(BaseModel):
dockerfile_path (str): The path to the Dockerfile within the repository. Defaults to "./Dockerfile".
fastly_service_prefix (Optional[str]): A prefix used to identify Fastly service IDs in Vault.
purge_fastly_cache (bool): Whether to include steps to purge the Fastly cache after deployment. Defaults to False.
fastly_purge_scope (str): Controls which Fastly purge endpoint is called when purge_fastly_cache is True.
Use "purge_all" (the default) to purge the entire service cache via POST /purge_all.
Pass a surrogate-key string (e.g. "html-pages") to purge only objects tagged with
that key via POST /purge/{surrogate_key}. Use a scoped key when some cached assets
(e.g. content-addressed static files) must survive a deployment.
repo_name (Optional[str]): The name of the git repository. Defaults to app_name if not provided.
"""

Expand All @@ -53,6 +58,7 @@ class AppPipelineParams(BaseModel):
dockerfile_path: str = "./Dockerfile"
fastly_service_prefix: str | None = None
purge_fastly_cache: bool = False
fastly_purge_scope: str = "purge_all"
repo_name: str | None = None
repo_main_branch: str = "main"
repo_rc_branch: str = "release-candidate"
Expand Down Expand Up @@ -82,11 +88,14 @@ def set_repo_name(self) -> "AppPipelineParams":
"mitxonline": AppPipelineParams(app_name="mitxonline", build_target="production"),
"mit-learn-nextjs": AppPipelineParams(
app_name="mit-learn-nextjs",
build_target="build_skip_yarn",
# No build_target: use the default `runner` stage, which bakes `yarn build`
# into the Docker image via `output: "standalone"` in next.config.js.
# NEXT_PUBLIC_* values are injected at runtime from Kubernetes env vars.
repo_name="mit-learn",
dockerfile_path="frontends/main/Dockerfile.web",
purge_fastly_cache=True,
fastly_service_prefix="learn_",
fastly_purge_scope="html-pages",
),
"xpro": AppPipelineParams(
app_name="xpro",
Expand Down Expand Up @@ -437,7 +446,11 @@ def build_app_pipeline(app_name: str) -> Pipeline:
path="sh",
args=[
"-exc",
f"""curl -H "Fastly-Key: ((fastly.fastly_api_token))" -H "Accept: application/json" -i -X POST "https://api.fastly.com/service/((fastly.{pipeline_parameters.fastly_service_prefix}service_id_ci))/purge_all" """,
(
f'curl -H "Fastly-Key: ((fastly.fastly_api_token))" -H "Accept: application/json" -i -X POST "https://api.fastly.com/service/((fastly.{pipeline_parameters.fastly_service_prefix}service_id_ci))/purge_all"'
if pipeline_parameters.fastly_purge_scope == "purge_all"
else f'curl -H "Fastly-Key: ((fastly.fastly_api_token))" -H "Accept: application/json" -i -X POST "https://api.fastly.com/service/((fastly.{pipeline_parameters.fastly_service_prefix}service_id_ci))/purge/{pipeline_parameters.fastly_purge_scope}"'
),
],
Comment thread
blarghmatey marked this conversation as resolved.
),
),
Expand Down Expand Up @@ -467,7 +480,12 @@ def build_app_pipeline(app_name: str) -> Pipeline:
path="sh",
args=[
"-exc",
f"""curl -H "Fastly-Key: ((fastly.fastly_api_token))" -H "Accept: application/json" -i -X POST "https://api.fastly.com/service/((fastly.{pipeline_parameters.fastly_service_prefix}service_id_qa))/purge_all" """,
(
f'curl -H "Fastly-Key: ((fastly.fastly_api_token))" -H "Accept: application/json" -i -X POST "https://api.fastly.com/service/((fastly.{pipeline_parameters.fastly_service_prefix}service_id_qa))/purge_all"'
if pipeline_parameters.fastly_purge_scope
== "purge_all"
else f'curl -H "Fastly-Key: ((fastly.fastly_api_token))" -H "Accept: application/json" -i -X POST "https://api.fastly.com/service/((fastly.{pipeline_parameters.fastly_service_prefix}service_id_qa))/purge/{pipeline_parameters.fastly_purge_scope}"'
),
],
),
),
Expand All @@ -486,7 +504,12 @@ def build_app_pipeline(app_name: str) -> Pipeline:
path="sh",
args=[
"-exc",
f"""curl -H "Fastly-Key: ((fastly.fastly_api_token))" -H "Accept: application/json" -i -X POST "https://api.fastly.com/service/((fastly.{pipeline_parameters.fastly_service_prefix}service_id_production))/purge_all" """,
(
f'curl -H "Fastly-Key: ((fastly.fastly_api_token))" -H "Accept: application/json" -i -X POST "https://api.fastly.com/service/((fastly.{pipeline_parameters.fastly_service_prefix}service_id_production))/purge_all"'
if pipeline_parameters.fastly_purge_scope
== "purge_all"
else f'curl -H "Fastly-Key: ((fastly.fastly_api_token))" -H "Accept: application/json" -i -X POST "https://api.fastly.com/service/((fastly.{pipeline_parameters.fastly_service_prefix}service_id_production))/purge/{pipeline_parameters.fastly_purge_scope}"'
),
],
),
),
Expand Down
Loading