Repository navigation
Fix Dockerfile casing warnings and add automated validation #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
bb0c638
Fix Dockerfile casing warning and add GitHub Action for validation
rberrelleza 8a8ec7c
Add local Dockerfile validation script and update README
rberrelleza 7adef66
Add hadolint configuration and fix trailing whitespace
rberrelleza 6a44b5f
fix casing
rberrelleza 7d75750
Fix Dockerfile linting errors
rberrelleza b5d4ca7
Update gem versions to latest
rberrelleza ffa2233
build image in action
rberrelleza 7d4a424
Apply suggestions from code review
rberrelleza 51c1aa2
Merge branch 'main' into okteto/workspace-loiqb7lY
rberrelleza dc6a44d
Update trusted registry for Okteto to ghcr.io
rberrelleza 355d983
Update trusted registries in .hadolint.yaml
rberrelleza File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| name: Dockerfile Validation | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main, master ] | ||
| paths: | ||
| - 'Dockerfile' | ||
| - '.github/workflows/dockerfile-validation.yml' | ||
| pull_request: | ||
| branches: [ main, master ] | ||
|
rberrelleza marked this conversation as resolved.
Outdated
|
||
| paths: | ||
| - 'Dockerfile' | ||
| - '.github/workflows/dockerfile-validation.yml' | ||
|
|
||
| jobs: | ||
| validate-dockerfile: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Lint Dockerfile | ||
| uses: hadolint/hadolint-action@v3.1.0 | ||
| with: | ||
| dockerfile: Dockerfile | ||
| failure-threshold: warning | ||
|
|
||
| - name: Build Docker image | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: . | ||
| file: ./Dockerfile | ||
| push: false | ||
| tags: test-build:latest | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # Hadolint configuration for Dockerfile linting | ||
| # See: https://github.com/hadolint/hadolint | ||
|
|
||
| # Rules to ignore | ||
| ignored: | ||
| # DL3008: Pin versions in apt get install | ||
| - DL3008 | ||
| # DL3009: Delete the apt-get lists after installing something | ||
| - DL3009 | ||
| # DL3015: Avoid additional packages by specifying `--no-install-recommends` | ||
| - DL3015 | ||
|
|
||
| # Rules to treat as warnings instead of errors | ||
| warning: | ||
| # DL3018: Pin versions in apk add | ||
| - DL3018 | ||
|
|
||
| # Trusted registries for base images | ||
| trustedRegistries: | ||
| - docker.io | ||
| - okteto | ||
| - golang | ||
| - ruby | ||
|
|
||
| # Override specific rules | ||
| override: | ||
| error: [] | ||
| warning: [] | ||
| info: [] | ||
| style: [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,24 @@ | ||
| FROM okteto/okteto:master as okteto | ||
| FROM okteto/okteto:master AS okteto | ||
|
|
||
| FROM golang:1.24 as message-builder | ||
| FROM golang:1.24 AS message-builder | ||
| RUN curl -L https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux64 > /usr/bin/jq && \ | ||
| chmod +x /usr/bin/jq | ||
|
|
||
| WORKDIR /app | ||
| COPY go.mod . | ||
| COPY message.go . | ||
| RUN go build -o /message . | ||
|
|
||
|
|
||
| FROM ruby:3-slim-buster | ||
|
|
||
| RUN gem install octokit faraday-retry | ||
| RUN gem install octokit:10.0.0 faraday-retry:2.3.2 | ||
|
|
||
| COPY notify-pr.sh /notify-pr.sh | ||
| RUN chmod +x notify-pr.sh | ||
| RUN chmod +x /notify-pr.sh | ||
| COPY --from=message-builder /usr/bin/jq /usr/bin/jq | ||
| COPY entrypoint.sh /entrypoint.sh | ||
| COPY --from=message-builder /message /message | ||
| COPY --from=okteto /usr/local/bin/okteto /usr/local/bin/okteto | ||
|
|
||
| ENTRYPOINT ["/entrypoint.sh"] | ||
| ENTRYPOINT ["/entrypoint.sh"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Script to validate Dockerfile locally | ||
| # This script can be run locally to test the Dockerfile before pushing | ||
|
|
||
| set -e | ||
|
|
||
| echo "π Validating Dockerfile..." | ||
|
|
||
| # Check if Docker is available | ||
| if ! command -v docker &> /dev/null; then | ||
| echo "β Docker is not installed or not in PATH" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Check if Dockerfile exists | ||
| if [ ! -f "Dockerfile" ]; then | ||
| echo "β Dockerfile not found in current directory" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "β Docker is available" | ||
| echo "β Dockerfile found" | ||
|
|
||
| # Build the Docker image | ||
| echo "ποΈ Building Docker image..." | ||
| if docker build -t dockerfile-test:latest .; then | ||
| echo "β Docker image built successfully" | ||
| else | ||
| echo "β Docker build failed" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Test basic functionality | ||
| echo "π§ͺ Testing Docker image..." | ||
|
|
||
| # Test that the image runs | ||
| if docker run --rm dockerfile-test:latest /bin/sh -c "echo 'Container started successfully'"; then | ||
| echo "β Container runs successfully" | ||
| else | ||
| echo "β Container failed to run" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Test that required binaries are present | ||
| echo "π Checking required binaries..." | ||
| if docker run --rm dockerfile-test:latest /bin/sh -c "which okteto && which jq && which ruby"; then | ||
| echo "β All required binaries are present" | ||
| else | ||
| echo "β Some required binaries are missing" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Test that entrypoint is executable | ||
| if docker run --rm dockerfile-test:latest /bin/sh -c "test -x /entrypoint.sh"; then | ||
| echo "β Entrypoint is executable" | ||
| else | ||
| echo "β Entrypoint is not executable" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Clean up | ||
| echo "π§Ή Cleaning up..." | ||
| docker rmi dockerfile-test:latest | ||
|
|
||
| echo "π All tests passed! Dockerfile is valid." |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.