Skip to content

Commit

Permalink
Merge pull request #139 from unixorn/update-dockerfile
Browse files Browse the repository at this point in the history
Docker build cleanups
  • Loading branch information
unixorn authored Nov 22, 2023
2 parents fc26f35 + 34c406f commit 9ba66c8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
1 change: 1 addition & 0 deletions .github/workflows/mega-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PAT: ${{secrets.PAT}}
REPOSITORY_TRIVY_DISABLE_ERRORS: true
DOCKERFILE_HADOLINT_DISABLE_ERRORS: true

# Upload Mega-Linter artifacts.
# They will be available on Github action page "Artifacts" section
Expand Down
16 changes: 3 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
FROM python:3.10
FROM python:slim

ARG application_version
LABEL maintainer="Joe Block <[email protected]>"
LABEL description="ha-mqtt-discoverable utility image"
LABEL version=${application_version}

RUN apt-get update && \
apt-get install --no-install-recommends -y apt-utils=2.2.4 ca-certificates=20210119 && \
update-ca-certificates && \
rm -fr /tmp/* /var/lib/apt/lists/*

# Copy wheel file built by Poetry
COPY dist/*.whl /app/

RUN python -m pip install --upgrade pip --no-cache-dir && \
pip install --no-cache-dir /app/*.whl && \
pip cache purge && \
rm -rf /app/*.whl
RUN python -m pip install ha-mqtt-discoverable && \
pip cache purge

USER nobody

Expand Down
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

# If this pukes trying to import paho, try running 'poetry install'
MODULE_VERSION=$(shell poetry run python3 -c 'from ha_mqtt_discoverable import __version__;print(__version__)' )
MODULE_VERSION=$(shell grep vers pyproject.toml | cut -d= -f2 | sed s/\"//g)

clean: ## Cleans out stale wheels, generated tar files, .pyc and .pyo files
rm -fv dist/*.tar dist/*.whl
Expand All @@ -40,8 +40,10 @@ trial: wheel
docker buildx build --no-cache --build-arg application_version=${MODULE_VERSION} --load -t unixorn/ha-mqtt-discoverable:$(MODULE_VERSION) .

multiarch_image: wheel ## Makes a multi-architecture docker image for linux/arm64, linux/amd64 and linux/arm/v7 and pushes it to dockerhub
docker buildx build --no-cache --build-arg application_version=${MODULE_VERSION} --platform linux/arm64,linux/amd64,linux/arm/v7 --push -t unixorn/ha-mqtt-discoverable:$(MODULE_VERSION) .
make local
docker buildx build --no-cache --build-arg application_version=${MODULE_VERSION} --platform linux/arm64,linux/amd64,linux/arm/v7 --push -t unixorn/ha-mqtt-discoverable .
docker buildx build --build-arg application_version=${MODULE_VERSION} --platform linux/arm64,linux/amd64,linux/arm/v7 --push -t unixorn/ha-mqtt-discoverable:$(MODULE_VERSION) .
docker pull unixorn/ha-mqtt-discoverable
docker pull unixorn/ha-mqtt-discoverable:$(MODULE_VERSION)

wheel: clean format ## Builds a wheel for our modules. 'poetry' bakes the dependencies into the wheel metadata.
poetry build
Expand Down

0 comments on commit 9ba66c8

Please sign in to comment.