-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from ThetaGamma/testing
fix #5
- Loading branch information
Showing
6 changed files
with
125 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Please don't use this filke directly but | ||
# build the image with Shellscript "./build-nightly.sh" | ||
|
||
# Start from golang alpine base image | ||
FROM golang:alpine3.13 as builder | ||
RUN apk --no-cache add unzip | ||
|
||
# Set the Current Working Directory inside the container | ||
WORKDIR /app | ||
|
||
# Get the current source | ||
RUN wget -q "https://github.com/mdzio/ccu-jack/archive/master.zip" && \ | ||
unzip master.zip | ||
RUN cd ccu-jack-master/build && go run . | ||
|
||
######## Start a new stage from scratch and build the dist container ####### | ||
FROM alpine | ||
|
||
ARG BUILD_DATE | ||
ARG BUILD_VERSION | ||
ARG BUILD_VERSION_NIGHTLY | ||
|
||
LABEL maintainer="Theta Gamma <thetagamma11@gmail.com>" | ||
LABEL org.opencontainers.image.created=$BUILD_DATE \ | ||
org.opencontainers.image.version=$BUILD_VERSION_NIGHTLY \ | ||
org.opencontainers.image.title="CCU-Jack" \ | ||
org.opencontainers.image.description="REST/MQTT-Server for the HomeMatic CCU" \ | ||
org.opencontainers.image.vendor="CCU-Jack OpenSource Project" \ | ||
org.opencontainers.image.authors="mdzio <info@ccu-historian.de>" \ | ||
org.opencontainers.image.licenses="GPL-3.0 License" \ | ||
org.opencontainers.image.url="https://github.com/mdzio/ccu-jack" \ | ||
org.opencontainers.image.documentation="https://github.com/mdzio/ccu-jack/blob/master/README.md" | ||
|
||
# Set work directory | ||
WORKDIR /app | ||
|
||
# Get the compiled binary and extract it locally | ||
COPY --from=builder /app/ccu-jack-master/ccu-jack-linux-${BUILD_VERSION}.tar.gz . | ||
|
||
RUN tar -xvzf ccu-jack-linux-${BUILD_VERSION}.tar.gz && \ | ||
mkdir -p /app/conf /app/cert /data && \ | ||
adduser -h /app -D -H ccu-jack -u 1000 -s /sbin/nologin && \ | ||
chown -R ccu-jack:ccu-jack /data && chmod -R g+rwX /data && \ | ||
chown -R ccu-jack:ccu-jack /app && chmod -R g+rwX /app | ||
|
||
USER ccu-jack | ||
|
||
# MQTT, MQTT TLS, CCU-Jack VEAM/UI, CCU-Jack VEAM/UI TLS, CUxD | ||
EXPOSE 1883 8883 2121 2122 2123 | ||
|
||
# Add a healthcheck (default every 30 secs) | ||
HEALTHCHECK --interval=30s --timeout=5s --start-period=40s --retries=3 \ | ||
CMD wget --spider -S -q http://localhost:2121/ui/ 2>&1 | head -1 || exit 1 | ||
|
||
# Start it up with full path | ||
|
||
ENTRYPOINT [ "/app/ccu-jack","-config","/app/conf/ccu-jack.cfg" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,58 @@ | ||
# Docker | ||
|
||
Um CCU-Jack in einem Docker-Container zu starten sind folgende Schritte nötig: | ||
## Start von CCU Jack mit einem fertigen Image | ||
|
||
1. `Dockerfile` und ggf. `docker-compose.yml` herunterladen. | ||
Am einfachsten geht das Starten des Containers (unter Linux) mit Docker-Compose. Dazu einfach die Datei `docker-compose.yml` herunterladen und folgenden Befehl ausführen: | ||
|
||
```bash | ||
docker-compose up -d . | ||
``` | ||
|
||
In der `docker-compose.yml` können Netzwerk-Ports, die in der eigenen Umgebung nicht genutzt werden, auskommentiert werden. | ||
|
||
## Eigenes Docker Image bauen und nutzen | ||
|
||
Um einen eigenes CCU-Jack-Container-Image zu bauen gibt es zwei verschiedene Möglichkeiten | ||
|
||
### Variante 1: Image aus stabilen "Release" von mdzio/ccu-jack bauen | ||
|
||
das ist die empfohlene Variante, wenn man auf der sicheren Seite sein möchte. | ||
|
||
1. `Dockerfile` und `build-release.sh` herunterladen | ||
2. Docker-Image bauen: | ||
|
||
```bash | ||
export BUILD_VERSION=$(curl -Ls https://api.github.com/repos/mdzio/ccu-jack/releases/latest | grep -oP '"tag_name": "v\K(.*)(?=")') | ||
|
||
docker build --rm --no-cache \ | ||
--build-arg BUILD_VERSION="${BUILD_VERSION}" \ | ||
--build-arg BUILD_DATE="$(date +"%Y-%m-%dT%H:%M:%SZ")" \ | ||
--tag ccu-jack:latest --tag ccu-jack:${BUILD_VERSION} . | ||
sh build-release.sh | ||
``` | ||
3. Die Verzeichnisse `conf` und `cert` erstellen, und dort die eigene Konfiguration bzw. die eigenen Zertifikate speichern. | ||
4. a) Starten direkt über Docker: | ||
|
||
### Variante 2: Image aus dem aktuellen Code im Repo von mdzio/ccu-jack bauen | ||
|
||
das ist die Variante, wenn man neueste Änderungen aus dem Repo benötigt | ||
|
||
1. `Dockerfile` und `build-nightly.sh` herunterladen | ||
2. Docker-Image bauen: | ||
|
||
```bash | ||
sh build-nightly.sh | ||
``` | ||
|
||
### Konfiguration und Start des Containers | ||
|
||
- nun die Verzeichnisse `conf` und `cert` erstellen, und dort die eigene Konfiguration bzw. die eigenen Zertifikate speichern. | ||
- Starten direkt über Docker: | ||
|
||
```bash | ||
docker run -d -v "$PWD"/conf:/app/conf --name ccu-jack ccu-jack:latest | ||
``` | ||
|
||
b) Starten mit Docker-Compose: | ||
- Alternativ: im `docker-compose.yml` die `image` Zeile ersetzen durch | ||
|
||
```yaml | ||
image: ccu-jack:latest | ||
``` | ||
|
||
und starten mit | ||
|
||
```bash | ||
docker-compose up -d . | ||
``` | ||
In der `docker-compose.yml` können Netzwerk-Ports, die in der eigenen Umgebung nicht genutzt werden, auskommentiert werden. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
# used to build a "nightly" image from the latest source code at mdzio/ccu-jack which might not be a release yet | ||
# | ||
# TODO: multi-arch | ||
export BUILD_VERSION=$(curl -Ls https://api.github.com/repos/mdzio/ccu-jack/releases/latest | grep -oP '"tag_name": "v\K(.*)(?=")') | ||
docker build --rm --no-cache \ | ||
--build-arg BUILD_VERSION="${BUILD_VERSION}" \ | ||
--build-arg BUILD_DATE="$(date +"%Y-%m-%dT%H:%M:%SZ")" \ | ||
--build-arg BUILD_VERSION_NIGHTLY="${BUILD_VERSION}-$(date +"%Y-%m-%d")" \ | ||
--tag ccu-jack:${BUILD_VERSION}_nightly \ | ||
-f Dockerfile.nightly . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
# used to build a stable image from the latest release from mdzio/ccu-jack | ||
# | ||
export BUILD_VERSION=$(curl -Ls https://api.github.com/repos/mdzio/ccu-jack/releases/latest | grep -oP '"tag_name": "v\K(.*)(?=")') | ||
docker build --rm --no-cache \ | ||
--build-arg BUILD_VERSION="${BUILD_VERSION}" \ | ||
--build-arg BUILD_DATE="$(date +"%Y-%m-%dT%H:%M:%SZ")" \ | ||
--tag ccu-jack:latest --tag ccu-jack:${BUILD_VERSION} . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters