Skip to content

Commit

Permalink
Lint with hadolint
Browse files Browse the repository at this point in the history
Signed-off-by: mueller-ma <[email protected]>
  • Loading branch information
mueller-ma committed Oct 31, 2023
1 parent b6e07b8 commit 855817b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Lint Dockerfile
uses: hadolint/[email protected]
with:
dockerfile: ${{ matrix.distribution }}/Dockerfile

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

Expand Down
10 changes: 8 additions & 2 deletions alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.vcs-url="https://github.com/openhab/openhab-docker.git" \
maintainer="openHAB <[email protected]>"

# Install basepackages
# https://github.com/hadolint/hadolint/wiki/DL4006
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]

# Install basepackages. Versions are "pinned" by using a pinned base image.
# hadolint ignore=DL3018
RUN apk update --no-cache && \
apk add --no-cache \
arping \
Expand All @@ -61,11 +65,13 @@ RUN apk update --no-cache && \
rm -rf /var/cache/apk/*

# Limit JDK crypto policy by default to comply with local laws which may prohibit use of unlimited strength cryptography
RUN JAVA_HOME=$(ls -d /usr/lib/jvm/*jdk*) && \
RUN JAVA_HOME=$(find /usr/lib/jvm/ -maxdepth 1 -name "*jdk*" -type d) && \
sed -i 's/^crypto.policy=unlimited/crypto.policy=limited/' "${JAVA_HOME}/conf/security/java.security"

# Install openHAB
# Set permissions for openHAB. Export TERM variable. See issue #30 for details!
# Single quotes are used on purpose, so $TERM is expanded when running the container.
# hadolint ignore=SC2016
RUN version="$(echo $OPENHAB_VERSION | sed 's/snapshot/SNAPSHOT/g')" && \
if [ $(echo $version | grep -E '^.+\.(M|RC).+$') ]; then url="https://openhab.jfrog.io/openhab/libs-milestone-local/org/openhab/distro/openhab/${version}/openhab-${version}.zip"; \
elif [ $(echo $version | grep -E '^4\..+-SNAPSHOT$') ]; then url="https://ci.openhab.org/job/openHAB-Distribution/lastSuccessfulBuild/artifact/distributions/openhab/target/openhab-${version}.zip"; \
Expand Down
10 changes: 8 additions & 2 deletions debian/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.vcs-url="https://github.com/openhab/openhab-docker.git" \
maintainer="openHAB <[email protected]>"

# Install basepackages
# https://github.com/hadolint/hadolint/wiki/DL4006
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# Install basepackages. Versions are "pinned" by using a pinned base image.
# hadolint ignore=DL3008
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
arping \
Expand All @@ -63,11 +67,13 @@ RUN apt-get update && \
rm -rf /var/lib/apt/lists/*

# Limit JDK crypto policy by default to comply with local laws which may prohibit use of unlimited strength cryptography
RUN JAVA_HOME=$(ls -d /usr/lib/jvm/*jdk* | tail -n 1) && \
RUN JAVA_HOME=$(find /usr/lib/jvm/ -maxdepth 1 -name "*jdk*" -type d) && \
sed -i 's/^crypto.policy=unlimited/crypto.policy=limited/' "${JAVA_HOME}/conf/security/java.security"

# Install openHAB
# Set permissions for openHAB. Export TERM variable. See issue #30 for details!
# Single quotes are used on purpose, so $TERM is expanded when running the container.
# hadolint ignore=SC2016
RUN version="$(echo $OPENHAB_VERSION | sed 's/snapshot/SNAPSHOT/g')" && \
if [ $(echo $version | grep -E '^.+\.(M|RC).+$') ]; then url="https://openhab.jfrog.io/openhab/libs-milestone-local/org/openhab/distro/openhab/${version}/openhab-${version}.zip"; \
elif [ $(echo $version | grep -E '^4\..+-SNAPSHOT$') ]; then url="https://ci.openhab.org/job/openHAB-Distribution/lastSuccessfulBuild/artifact/distributions/openhab/target/openhab-${version}.zip"; \
Expand Down

0 comments on commit 855817b

Please sign in to comment.