Add Docker image build workflow - #3
Hidden character warning
Conversation
|
Your cubic subscription is currently inactive. Please reactivate your subscription to receive AI reviews and use cubic. |
WalkthroughThis update introduces a reusable devcontainer setup, including configuration files, feature metadata, and automation scripts to streamline development environment provisioning. Documentation is added to explain usage, and a GitHub Actions workflow is established to build and publish a Docker image to the GitHub Container Registry. Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant VSCode/Devcontainer
participant FeatureInstallScript
participant RepoImportScript
Developer->>VSCode/Devcontainer: Start devcontainer
VSCode/Devcontainer->>FeatureInstallScript: Run features/common/install.sh
FeatureInstallScript->>RepoImportScript: Execute script/import.sh (if exists)
RepoImportScript-->>FeatureInstallScript: Apply repository configuration
FeatureInstallScript-->>VSCode/Devcontainer: Feature setup complete
VSCode/Devcontainer-->>Developer: Devcontainer ready with applied settings
sequenceDiagram
participant GitHub
participant GitHub Actions
participant Docker Buildx
participant GHCR
GitHub->>GitHub Actions: Push to main or manual trigger
GitHub Actions->>Docker Buildx: Build Docker image (./docker/Dockerfile)
Docker Buildx->>GHCR: Push image (ghcr.io/<repo>/config-base:latest)
GHCR-->>GitHub Actions: Image published
Poem
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. Note ⚡️ Faster reviews with cachingCodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
PR Summary
This PR introduces a reusable devcontainer configuration and Docker image build workflow, enabling standardized development environments across projects with automated container image publishing to GitHub Container Registry.
- New workflow
.github/workflows/docker-image.ymltriggers on main branch but is configured for 'master', which may prevent automated builds .devcontainer/devcontainer.jsonestablishes base configuration using Microsoft's Ubuntu image with custom featuresfeatures/common/install.shassumes/bin/zshavailability which could fail in minimal containers- Added comprehensive Japanese documentation in
.devcontainer/README.mdexplaining component reuse - New
features/common/devcontainer-feature.jsondefines base configuration with version 0.1.0
6 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile
| "name": "Config Base Container", | ||
| "image": "mcr.microsoft.com/devcontainers/base:ubuntu", | ||
| "features": { | ||
| "../features/common": {} |
There was a problem hiding this comment.
style: Consider using an absolute path or repository reference instead of a relative path to ensure the feature can be referenced correctly from other repositories
| context: ./docker | ||
| file: ./docker/Dockerfile | ||
| push: true | ||
| tags: ghcr.io/${{ github.repository }}/config-base:latest |
There was a problem hiding this comment.
style: Consider adding version tags in addition to 'latest' for better image versioning
| set -e | ||
| REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)" | ||
| if [ -f "$REPO_ROOT/script/import.sh" ]; then | ||
| /bin/zsh "$REPO_ROOT/script/import.sh" |
There was a problem hiding this comment.
logic: Hardcoding /bin/zsh could fail if zsh isn't installed. Consider using $SHELL or defaulting to /bin/sh
| /bin/zsh "$REPO_ROOT/script/import.sh" | |
| "${SHELL:-/bin/sh}" "$REPO_ROOT/script/import.sh" |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (8)
features/common/install.sh (3)
1-2: Enhance script robustness with stricter shell options
Consider addingset -u(treat unset variables as errors) andset -o pipefailto catch more failure modes.Example diff:
#!/bin/sh set -e +set -u +set -o pipefail
3-3: Simplify path resolution usingrealpath
Usingrealpathcan make the intent clearer and handle edge cases.Example diff:
-REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)" +REPO_ROOT="$(realpath "$(dirname "$0")/../..")"
4-6: Provide fallback ifzshis unavailable
Hardcoding/bin/zshmay fail if zsh isn't installed. Check for a compatible shell or fallback tosh.Example diff:
-if [ -f "$REPO_ROOT/script/import.sh" ]; then - /bin/zsh "$REPO_ROOT/script/import.sh" -fi +if [ -f "$REPO_ROOT/script/import.sh" ]; then + if command -v zsh >/dev/null 2>&1; then + zsh "$REPO_ROOT/script/import.sh" + else + sh "$REPO_ROOT/script/import.sh" + fi +fi.devcontainer/devcontainer.json (1)
2-3: Consider using the published GHCR image
To leverage the workflow's output, update theimagefield to the built image tag, e.g.:"image": "ghcr.io/${{ github.repository_owner }}/${{ github.repository_name }}/config-base:latest"This ensures your devcontainer uses the pre-built environment.
README.md (2)
13-14: Clarify registry and code formatting
Wrap key paths and registry names in backticks, and mention GHCR explicitly.Example diff:
-- `.devcontainer`: Provides a reusable devcontainer configuration and feature for applying these settings automatically. -- GitHub Actions builds the `docker/Dockerfile` and publishes the image to GitHub Container Registry. +- `.devcontainer`: Provides a reusable devcontainer configuration and feature for applying these settings automatically. +- GitHub Actions builds the `docker/Dockerfile` and publishes the image to `GitHub Container Registry (GHCR)` under `ghcr.io/<owner>/<repo>/config-base:latest`.🧰 Tools
🪛 LanguageTool
[uncategorized] ~13-~13: Loose punctuation mark.
Context: ...ent tools and systems. -.devcontainer: Provides a reusable devcontainer config...(UNLIKELY_OPENING_PUNCTUATION)
41-44: Align heading level for Devcontainer section
Use## Devcontainerto match other top-level sections or ensure it nests under Usage intentionally.Example diff:
-### Devcontainer +## Devcontainer.devcontainer/README.md (1)
1-17: Consider adding a link to the main README
Providing a link back to the root README gives users context for the overall repo purpose.Example diff:
# 共通 devcontainer コンポーネント + +> 詳細はルートの [README.md](../README.md) を参照してください。.github/workflows/docker-image.yml (1)
18-26: Consider Updatingactions/checkoutto v4
Whileactions/checkout@v3works well today, v4 is available and includes performance improvements and new features. You can optionally bump this to lock in the latest enhancements:- uses: actions/checkout@v3 + uses: actions/checkout@v4🧰 Tools
🪛 actionlint (1.7.7)
18-18: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
19-19: the runner of "docker/setup-qemu-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
20-20: the runner of "docker/setup-buildx-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
22-22: the runner of "docker/login-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
📒 Files selected for processing (6)
.devcontainer/README.md(1 hunks).devcontainer/devcontainer.json(1 hunks).github/workflows/docker-image.yml(1 hunks)README.md(2 hunks)features/common/devcontainer-feature.json(1 hunks)features/common/install.sh(1 hunks)
🧰 Additional context used
🪛 LanguageTool
README.md
[uncategorized] ~13-~13: Loose punctuation mark.
Context: ...ent tools and systems. - .devcontainer: Provides a reusable devcontainer config...
(UNLIKELY_OPENING_PUNCTUATION)
🪛 actionlint (1.7.7)
.github/workflows/docker-image.yml
18-18: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
19-19: the runner of "docker/setup-qemu-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
20-20: the runner of "docker/setup-buildx-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
22-22: the runner of "docker/login-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🔇 Additional comments (6)
.devcontainer/devcontainer.json (1)
4-6: Local feature reference looks correct
Your feature inclusion via a relative path is valid and aligns with the devcontainer spec.features/common/devcontainer-feature.json (1)
1-6: Feature metadata is valid
Theid,version,name, anddescriptionfields align with devcontainer feature requirements..github/workflows/docker-image.yml (4)
1-2: Workflow Naming and Purpose Looks Good
The workflow name is clear and descriptive, accurately reflecting its function for building and releasing the Docker image.
3-10: Trigger Configuration is Appropriate
Usingpushonmainfor changes underdocker/**(and the workflow file itself) alongsideworkflow_dispatchcovers your CI/CD needs without adding unnecessary events.
11-17: Job Permissions are Correctly Scoped
Grantingcontents: readandpackages: writefollows the principle of least privilege while allowing image publishing to GHCR.
27-34: Build and Push Steps are Correct
The QEMU setup, Buildx configuration, login step, anddocker/build-push-action@v5invocation are correctly defined, ensuring multi-platform builds and pushing theconfig-base:latestimage to GHCR.
Summary
Testing
bash -n features/common/install.shjq . .devcontainer/devcontainer.jsonjq . features/common/devcontainer-feature.jsonSummary by CodeRabbit
New Features
Documentation