Skip to content

Commit

Permalink
chore: Adaptive container registry host. (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
huxuan committed Jan 28, 2024
1 parent 7c01ac7 commit 253ab0f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Expand Up @@ -128,6 +128,7 @@
"repo_host_type",
"repo_host",
"page_host",
"container_registry_host",
"ci",
"repo_namespace",
"repo_name",
Expand Down
10 changes: 10 additions & 0 deletions copier.yaml
Expand Up @@ -95,6 +95,16 @@ page_host:
help: 'Specify the host of the self-managed GitLab Pages:'
type: str
when: '{{ repo_host_type == "gitlab-self-managed" }}'
container_registry_host:
default: |-
[% if repo_host_type == 'github.com' -%]
ghcr.io
[%- elif repo_host_type == 'gitlab.com' -%]
registry.gitlab.com
[%- endif %]
help: 'Specify the host of the self-managed GitLab Container Registry:'
type: str
when: '{{ repo_host_type == "gitlab-self-managed" }}'
repo_namespace:
default: '{{ organization_name|lower|replace(" ", "-") }}'
help: 'Indicate the GitHub Repository Owner or GitLab Namespace. This is typically the account name of the author or the organization:'
Expand Down
4 changes: 2 additions & 2 deletions template/.devcontainer/devcontainer.json.jinja
Expand Up @@ -14,10 +14,10 @@
]
}
},
"image": "ghcr.io/{{ repo_namespace }}/{{ repo_name }}:dev-py{{ default_py }}",
"image": "{{ container_registry_host }}/{{ repo_namespace }}/{{ repo_name }}:dev-py{{ default_py }}",
// Force the image update to ensure the latest version which might be a bug.
// Reference: https://github.com/microsoft/vscode-remote-release/issues/9391
"initializeCommand": "docker pull ghcr.io/{{ repo_namespace }}/{{ repo_name }}:dev-py{{ default_py }}",
"initializeCommand": "docker pull {{ container_registry_host }}/{{ repo_namespace }}/{{ repo_name }}:dev-py{{ default_py }}",
// Use a targeted named volume for .venv folder to improve disk performance.
// Reference: https://code.visualstudio.com/remote/advancedcontainers/improve-performance#_use-a-targeted-named-volume
"mounts": [
Expand Down
Expand Up @@ -3,7 +3,7 @@
"args": {
"PYTHON_VERSION": "${localEnv:PYTHON_VERSION}"
},
"cacheFrom": "ghcr.io/serious-scaffold/ss-python:dev-py${localEnv:PYTHON_VERSION}",
"cacheFrom": "{{ container_registry_host }}/{{ repo_namespace }}/{{ repo_name }}:dev-py${localEnv:PYTHON_VERSION}",
"context": "../../..",
"dockerfile": "Dockerfile",
"target": "dev"
Expand Down
1 change: 1 addition & 0 deletions template/.vscode/settings.json
Expand Up @@ -128,6 +128,7 @@
"repo_host_type",
"repo_host",
"page_host",
"container_registry_host",
"ci",
"repo_namespace",
"repo_name",
Expand Down

0 comments on commit 253ab0f

Please sign in to comment.