Skip to content

Commit

Permalink
Initial Docker support (#34)
Browse files Browse the repository at this point in the history
* Initial Docker support

* Dockerfile cleanup

* Readme cleanup
  • Loading branch information
szibis authored May 24, 2024
1 parent 5d4fa7f commit bfd58da
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Include any files or directories that you don't want to be copied to your
# container here (e.g., local build artifacts, temporary files, etc.).
#
# For more help, visit the .dockerignore file reference guide at
# https://docs.docker.com/go/build-context-dockerignore/

**/.DS_Store
**/__pycache__
**/.venv
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/bin
**/charts
**/docker-compose*
**/compose.y*ml
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# syntax=docker/dockerfile:1

ARG PYTHON_VERSION=3.12.3
FROM python:${PYTHON_VERSION}-slim as base

# Prevents Python from writing pyc files.
ENV PYTHONDONTWRITEBYTECODE=1

# Keeps Python from buffering stdout and stderr to avoid situations where
# the application crashes without emitting any logs due to buffering.
ENV PYTHONUNBUFFERED=1

# Choose poetry version
ENV POETRY_VERSION=1.8.2

# Download dependencies as a separate step to take advantage of Docker's caching.
# Leverage a cache mount to /root/.cache/pip to speed up subsequent builds.
# Leverage a bind mount to requirements.txt to avoid having to copy them into
# into this layer.
RUN --mount=type=cache,target=/root/.cache/pip \
python3 -m pip install "poetry==$POETRY_VERSION"

# Install all dependencies for aiocomfoconnect
COPY pyproject.toml poetry.lock .
RUN poetry export -f requirements.txt | python3 -m pip install -r /dev/stdin

# Copy the source code into the container.
COPY . .

FROM base as final

# Run the application.
ENTRYPOINT ["python3", "-m", "aiocomfoconnect"]
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ codefix:
test:
@poetry run pytest

build:
docker build -t aiocomfoconnect .

.PHONY: check codefix test
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,28 @@ $ python -m aiocomfoconnect get-property --host 192.168.1.213 1 1 8 9 # Unit 0x
- `async cmd_rpdo_request(pdid, type, zone, timeout)`: Send a RPDO request.
- `async cmd_keepalive()`: Send a keepalive message.

## Docker

### Description
Docker with aiocomfoconnect allow to experiment and develop on local machine using same image and same environment on any platform where we can run container.
This allow us to skip some platform issues and work on similar things and python version by easly swapping them in Dockerfile.

### Building

Build the image command
```
make build
```

### Running
Now after we build our images is called `aiocomfoconnect`

To run aiocomfoconnect we can use bellow command in this case with `--help` arg.
```
docker run aiocomfoconnect --help
```
Any args from `aiocomfoconnect` can be passed into this image run just like for `python3 -m aiocomfoconnect` command in local build.

## Examples

### Discovery of ComfoConnect LAN C Bridges
Expand Down

0 comments on commit bfd58da

Please sign in to comment.