Skip to content

Commit

Permalink
Specify debian version in Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
ArdKuijpers committed Oct 24, 2023
1 parent 92032ad commit a138299
Show file tree
Hide file tree
Showing 12 changed files with 592 additions and 591 deletions.
52 changes: 26 additions & 26 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
**/__pycache__
**/.mypy_cache
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
README.md
**/__pycache__
**/.mypy_cache
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
README.md
.env
8 changes: 4 additions & 4 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ATAG_HOST=<ip-address-of-atag-thermostat>
MQTT_HOST=<ip-address-of-mqtt-broker>
MQTT_PORT=1883
# MQTT_USERNAME=<mqtt-broker-username>
ATAG_HOST=<ip-address-of-atag-thermostat>
MQTT_HOST=<ip-address-of-mqtt-broker>
MQTT_PORT=1883
# MQTT_USERNAME=<mqtt-broker-username>
# MQTT_PASSWORD=<mqtt-broker-passwd>
152 changes: 76 additions & 76 deletions .github/workflows/dockerpublish.yml
Original file line number Diff line number Diff line change
@@ -1,76 +1,76 @@
name: Docker

on:
push:
# Publish `master` as Docker `latest` image.
branches:
- master

# Publish `v1.2.3` tags as releases.
tags:
- v*

# Run tests for any PRs.
pull_request:

env:
# TODO: Change variable to your image's name.
IMAGE_NAME: image

jobs:
# Run tests.
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Run tests
run: |
if [ -f docker-compose.test.yml ]; then
docker-compose --file docker-compose.test.yml build
docker-compose --file docker-compose.test.yml run sut
else
docker build . --file Dockerfile
fi
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
push:
# Ensure test job passes before pushing image.
needs: test

runs-on: ubuntu-latest
if: github.event_name == 'push'

steps:
- uses: actions/checkout@v2

- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME

- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin

- name: Push image
run: |
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
name: Docker

on:
push:
# Publish `master` as Docker `latest` image.
branches:
- master

# Publish `v1.2.3` tags as releases.
tags:
- v*

# Run tests for any PRs.
pull_request:

env:
# TODO: Change variable to your image's name.
IMAGE_NAME: image

jobs:
# Run tests.
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Run tests
run: |
if [ -f docker-compose.test.yml ]; then
docker-compose --file docker-compose.test.yml build
docker-compose --file docker-compose.test.yml run sut
else
docker build . --file Dockerfile
fi
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
push:
# Ensure test job passes before pushing image.
needs: test

runs-on: ubuntu-latest
if: github.event_name == 'push'

steps:
- uses: actions/checkout@v2

- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME

- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin

- name: Push image
run: |
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
17 changes: 9 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
.mypy_cache/

# local files
.env
.vscode
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
.mypy_cache/

# local files
.env
.vscode
.vs
62 changes: 31 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@

# For more information, please refer to https://aka.ms/vscode-docker-python
FROM python:3.9-slim as base

FROM base as builder
RUN apt-get update \
&& apt-get install gcc=4:10.* git=1:2.* -y \
&& apt-get clean
COPY requirements.txt /app/requirements.txt
WORKDIR /app
ENV PATH=/root/.local/bin:$PATH
RUN pip install --user -r requirements.txt
COPY . /app

FROM base as app
COPY . /app
COPY --from=builder /root/.local /root/.local

# # Keeps Python from generating .pyc files in the container
# ENV PYTHONDONTWRITEBYTECODE 1

# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED 1

# Access local binaries
ENV PATH=/root/.local/bin:$PATH

WORKDIR /app

# During debugging, this entry point will be overridden. For more information, refer to https://aka.ms/vscode-docker-python-debug
CMD ["python", "app.py"]

# For more information, please refer to https://aka.ms/vscode-docker-python
FROM python:3.9.18-slim-bullseye as base

FROM base as builder
RUN apt-get update \
&& apt-get install gcc=4:10.* git=1:2.* -y \
&& apt-get clean
COPY requirements.txt /app/requirements.txt
WORKDIR /app
ENV PATH=/root/.local/bin:$PATH
RUN pip install --user -r requirements.txt
COPY . /app

FROM base as app
COPY . /app
COPY --from=builder /root/.local /root/.local

# # Keeps Python from generating .pyc files in the container
# ENV PYTHONDONTWRITEBYTECODE 1

# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED 1

# Access local binaries
ENV PATH=/root/.local/bin:$PATH

WORKDIR /app

# During debugging, this entry point will be overridden. For more information, refer to https://aka.ms/vscode-docker-python-debug
CMD ["python", "app.py"]
94 changes: 47 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
# atagone-mqtt-bridge

[![Codacy Badge](https://app.codacy.com/project/badge/Grade/fd572a99c73f429cb6aba7ac43776515)](https://www.codacy.com/gh/EtxeanNet/atagone-mqtt-bridge?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=EtxeanNet/atagone-mqtt-bridge&amp;utm_campaign=Badge_Grade)
![Docker Pulls](https://img.shields.io/docker/pulls/etxean/atagone-mqtt-bridge)
[![HitCount](https://hits.dwyl.com/EtxeanNet/atagone-mqtt-bridge.svg)](https://hits.dwyl.com/EtxeanNet/atagone-mqtt-bridge)

An app to control and monitor an Atag One thermostat via Python/Docker

## Introduction

**atagone-mqtt-bridge** works as an bridge between the Atag One webapi and MQTT. It periodically polls the Atag One thermostat and publishes the sensor information to an MQTT broker. Reversely, it subscribes to control messages on a number of MQTT topics and controls the Atag One thermostat e.g. to change the central heating or water setpoints.

The MQTT topics that the bridge follow the [Homie convention](https://homieiot.github.io/). By this means the Atag One can be integrated easily with home automation systems that recognize this convention such as [openHAB](https://www.openhab.org/) or [HomeAssistant](https://github.com/nerdfirefighter/HA_Homie/tree/dev).

Under the hood, this bridge uses (a modified version of) the [pyatag](https://github.com/MatsNl/pyatag) library to interface with the Atag One Thermostat and the [homie v3](https://github.com/mjcumming/HomieV3) library to communicate with the MQTT broker.

## Setup

The configuration of atagone-mqtt-bridge is done with the following environment variables.

`MQTT_HOST`
: The address of the MQTT broker.

`MQTT_PORT`
: USe this if your MQTT broker uses a port different from 1883.

`MQTT_USERNAME`
: Only use this if you need to use a username to connect to your MQTT broker.

`MQTT_PASSWORD`
: Only use this if you need this to connect to your MQTT broker.

`MQTT_CLIENT`
: The name used to identify this client to the MQTT broker. If not specified, the client will announce itself as '&lt;atagmqtt-HOSTNAME&gt;'.

`ATAG_HOST`
: The address of your Atag One thermostat. If this is not specified then the Atag One themostat is discovered automatically on the local netwerk. Make sure that UDP port 11000 is not blocked by the firewall.

## Build

You can run the app directly from Python, after installing the modules from `requirements.txt`. Alternatatively, you can use the supplied Dockerfile to build a Docker container to run app.

Building for docker hub can be done with:

```bash
docker buildx build --push --platform linux/arm/v7,linux/arm64/v8,linux/amd64 --tag etxean/atagone-mqtt-bridge:<version> --tag etxean/atagone-mqtt-bridge:latest .
```
# atagone-mqtt-bridge

[![Codacy Badge](https://app.codacy.com/project/badge/Grade/fd572a99c73f429cb6aba7ac43776515)](https://www.codacy.com/gh/EtxeanNet/atagone-mqtt-bridge?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=EtxeanNet/atagone-mqtt-bridge&amp;utm_campaign=Badge_Grade)
![Docker Pulls](https://img.shields.io/docker/pulls/etxean/atagone-mqtt-bridge)
[![HitCount](https://hits.dwyl.com/EtxeanNet/atagone-mqtt-bridge.svg)](https://hits.dwyl.com/EtxeanNet/atagone-mqtt-bridge)

An app to control and monitor an Atag One thermostat via Python/Docker

## Introduction

**atagone-mqtt-bridge** works as an bridge between the Atag One webapi and MQTT. It periodically polls the Atag One thermostat and publishes the sensor information to an MQTT broker. Reversely, it subscribes to control messages on a number of MQTT topics and controls the Atag One thermostat e.g. to change the central heating or water setpoints.

The MQTT topics that the bridge follow the [Homie convention](https://homieiot.github.io/). By this means the Atag One can be integrated easily with home automation systems that recognize this convention such as [openHAB](https://www.openhab.org/) or [HomeAssistant](https://github.com/nerdfirefighter/HA_Homie/tree/dev).

Under the hood, this bridge uses (a modified version of) the [pyatag](https://github.com/MatsNl/pyatag) library to interface with the Atag One Thermostat and the [homie v3](https://github.com/mjcumming/HomieV3) library to communicate with the MQTT broker.

## Setup

The configuration of atagone-mqtt-bridge is done with the following environment variables.

`MQTT_HOST`
: The address of the MQTT broker.

`MQTT_PORT`
: USe this if your MQTT broker uses a port different from 1883.

`MQTT_USERNAME`
: Only use this if you need to use a username to connect to your MQTT broker.

`MQTT_PASSWORD`
: Only use this if you need this to connect to your MQTT broker.

`MQTT_CLIENT`
: The name used to identify this client to the MQTT broker. If not specified, the client will announce itself as '&lt;atagmqtt-HOSTNAME&gt;'.

`ATAG_HOST`
: The address of your Atag One thermostat. If this is not specified then the Atag One themostat is discovered automatically on the local netwerk. Make sure that UDP port 11000 is not blocked by the firewall.

## Build

You can run the app directly from Python, after installing the modules from `requirements.txt`. Alternatatively, you can use the supplied Dockerfile to build a Docker container to run app.

Building for docker hub can be done with:

```bash
docker buildx build --push --platform linux/arm/v7,linux/arm64/v8,linux/amd64 --tag etxean/atagone-mqtt-bridge:<version> --tag etxean/atagone-mqtt-bridge:latest .
```
Loading

0 comments on commit a138299

Please sign in to comment.