Skip to content

Commit

Permalink
fix(dockerfile): build custom Docker image with the latest Alpine; fi…
Browse files Browse the repository at this point in the history
…x link to linter in README
  • Loading branch information
ArtemkaKun committed Oct 12, 2024
1 parent b88c57d commit f0a19ff
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build_and_push_docker_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ env:
jobs:
build-and-push:
runs-on: "ubuntu-latest"
# NOTE: building and pushing Docker image of Dockerfile linter take around 1 minute.
# If this job takes more than 5 minutes, it means that something is wrong.
timeout-minutes: 5
# NOTE: building and pushing Docker image of Dockerfile linter take around 5 minutes.
# If this job takes more than 15 minutes, it means that something is wrong.
timeout-minutes: 15
steps:
- name: "Checkout ${{ github.event.repository.name }}"
uses: "actions/checkout@v4"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/validate_new_changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ env:
jobs:
validate-dockerfile-linter-image:
runs-on: "ubuntu-latest"
# NOTE: building and running Docker image of Dockerfile linter take around 1 minute.
# If this job takes more than 5 minutes, it means that something is wrong.
timeout-minutes: 5
# NOTE: building and running Docker image of Dockerfile linter take around 5 minutes.
# If this job takes more than 15 minutes, it means that something is wrong.
timeout-minutes: 15
steps:
- name: "Checkout ${{ github.event.repository.name }}"
uses: "actions/checkout@v4"
Expand Down
17 changes: 13 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
FROM ghcr.io/hadolint/hadolint:2.12.1-beta-alpine
FROM alpine:3.20

COPY ./ /linter_workdir
RUN mkdir /linter_workdir

RUN addgroup -S lintergroup && adduser -S linteruser -G lintergroup && chown -R linteruser:lintergroup /linter_workdir

RUN apk add --no-cache wget=1.24.5-r0 \
&& wget --progress=dot:mega -O /linter_workdir/hadolint https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Linux-x86_64 \
&& chmod +x /linter_workdir/hadolint \
&& apk del wget

# NOTE: we need to have a separate directory for linter to work only with needed files,
# not with files from the entire system.
WORKDIR /linter_workdir

HEALTHCHECK --timeout=1s --retries=1 CMD hadolint --version || exit 1
USER linteruser

HEALTHCHECK --timeout=1s --retries=1 CMD /linter_workdir/hadolint --version || exit 1

ENTRYPOINT ["/bin/sh", "-c", "find /linter_workdir/repo -name 'Dockerfile*' -type f | \
while read -r dockerfile; do hadolint \"$dockerfile\"; done"]
while read -r dockerfile; do /linter_workdir/hadolint \"$dockerfile\"; done"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![image size](https://ghcr-badge.egpl.dev/articola-tools/dockerfile-linter/size?color=dodgerblue)](https://ghcr-badge.egpl.dev/articola-tools/dockerfile-linter/size?color=dodgerblue)

This repo contains Dockerfile with preconfigured [Dockerfile linter](https://github.com/hadolint/hadolint?tab=readme-ov-file#rules).
This repo contains Dockerfile with preconfigured [Dockerfile linter](https://github.com/hadolint/hadolint).
This linter is used in Articola Tools organization's repositories to lint Dockerfile files like
other linters.

Expand Down

0 comments on commit f0a19ff

Please sign in to comment.