@@ -62,18 +62,10 @@ RUN python -m pip install --no-cache --no-index /root/wheels/* && \
|
|||||||
COPY --chmod=0700 entrypoint.sh /root/entrypoint.sh
|
COPY --chmod=0700 entrypoint.sh /root/entrypoint.sh
|
||||||
COPY config .
|
COPY config .
|
||||||
COPY src .
|
COPY src .
|
||||||
RUN echo ${VERSION} > /proxy-version.txt
|
RUN echo ${VERSION} > /proxy-version.txt \
|
||||||
RUN date > /build-date.txt
|
&& date > /build-date.txt
|
||||||
EXPOSE 5005 8127 10000
|
EXPOSE 5005 8127 10000
|
||||||
|
|
||||||
# command to run on container start
|
# command to run on container start
|
||||||
ENTRYPOINT ["/root/entrypoint.sh"]
|
ENTRYPOINT ["/root/entrypoint.sh"]
|
||||||
CMD [ "python3", "./server.py" ]
|
CMD [ "python3", "./server.py" ]
|
||||||
|
|
||||||
|
|
||||||
LABEL org.opencontainers.image.title="TSUN Gen3 Proxy"
|
|
||||||
LABEL org.opencontainers.image.authors="Stefan Allius"
|
|
||||||
LABEL org.opencontainers.image.source=https://github.com/s-allius/tsun-gen3-proxy
|
|
||||||
LABEL org.opencontainers.image.description='This proxy enables a reliable connection between TSUN third generation inverters (eg. TSOL MS600, MS800, MS2000) and an MQTT broker to integrate the inverter into typical home automations.'
|
|
||||||
LABEL org.opencontainers.image.licenses="BSD-3-Clause"
|
|
||||||
LABEL org.opencontainers.image.vendor="Stefan Allius"
|
|
||||||
|
|||||||
39
app/build.sh
39
app/build.sh
@@ -17,6 +17,7 @@ VERSION="${VERSION:1}"
|
|||||||
arr=(${VERSION//./ })
|
arr=(${VERSION//./ })
|
||||||
MAJOR=${arr[0]}
|
MAJOR=${arr[0]}
|
||||||
IMAGE=tsun-gen3-proxy
|
IMAGE=tsun-gen3-proxy
|
||||||
|
|
||||||
GREEN='\033[0;32m'
|
GREEN='\033[0;32m'
|
||||||
BLUE='\033[0;34m'
|
BLUE='\033[0;34m'
|
||||||
NC='\033[0m'
|
NC='\033[0m'
|
||||||
@@ -26,44 +27,22 @@ IMAGE=docker.io/sallius/${IMAGE}
|
|||||||
VERSION=${VERSION}+$1
|
VERSION=${VERSION}+$1
|
||||||
elif [[ $1 == rc ]] || [[ $1 == rel ]] || [[ $1 == preview ]] ;then
|
elif [[ $1 == rc ]] || [[ $1 == rel ]] || [[ $1 == preview ]] ;then
|
||||||
IMAGE=ghcr.io/s-allius/${IMAGE}
|
IMAGE=ghcr.io/s-allius/${IMAGE}
|
||||||
|
echo 'login to ghcr.io'
|
||||||
|
echo $GHCR_TOKEN | docker login ghcr.io -u s-allius --password-stdin
|
||||||
else
|
else
|
||||||
echo argument missing!
|
echo argument missing!
|
||||||
echo try: $0 '[debug|dev|preview|rc|rel]'
|
echo try: $0 '[debug|dev|preview|rc|rel]'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $1 == debug ]] ;then
|
export IMAGE
|
||||||
BUILD_ENV="dev"
|
export VERSION
|
||||||
else
|
export BUILD_DATE
|
||||||
BUILD_ENV="production"
|
export BRANCH
|
||||||
fi
|
export MAJOR
|
||||||
|
|
||||||
BUILD_CMD="buildx build --push --build-arg VERSION=${VERSION} --build-arg environment=${BUILD_ENV} --attest type=provenance,mode=max --attest type=sbom,generator=docker/scout-sbom-indexer:latest"
|
|
||||||
ARCH="--platform linux/amd64,linux/arm64,linux/arm/v7"
|
|
||||||
LABELS="--label org.opencontainers.image.created=${BUILD_DATE} --label org.opencontainers.image.version=${VERSION} --label org.opencontainers.image.revision=${BRANCH}"
|
|
||||||
|
|
||||||
echo version: $VERSION build-date: $BUILD_DATE image: $IMAGE
|
echo version: $VERSION build-date: $BUILD_DATE image: $IMAGE
|
||||||
if [[ $1 == debug ]];then
|
docker buildx bake -f app/docker-bake.hcl $1
|
||||||
docker ${BUILD_CMD} ${ARCH} ${LABELS} --build-arg "LOG_LVL=DEBUG" -t ${IMAGE}:debug app
|
|
||||||
|
|
||||||
elif [[ $1 == dev ]];then
|
|
||||||
docker ${BUILD_CMD} ${ARCH} ${LABELS} -t ${IMAGE}:dev app
|
|
||||||
|
|
||||||
elif [[ $1 == preview ]];then
|
|
||||||
echo 'login to ghcr.io'
|
|
||||||
echo $GHCR_TOKEN | docker login ghcr.io -u s-allius --password-stdin
|
|
||||||
docker ${BUILD_CMD} ${ARCH} ${LABELS} -t ${IMAGE}:preview -t ${IMAGE}:${VERSION} app
|
|
||||||
|
|
||||||
elif [[ $1 == rc ]];then
|
|
||||||
echo 'login to ghcr.io'
|
|
||||||
echo $GHCR_TOKEN | docker login ghcr.io -u s-allius --password-stdin
|
|
||||||
docker ${BUILD_CMD} ${ARCH} ${LABELS} -t ${IMAGE}:rc -t ${IMAGE}:${VERSION} app
|
|
||||||
|
|
||||||
elif [[ $1 == rel ]];then
|
|
||||||
echo 'login to ghcr.io'
|
|
||||||
echo $GHCR_TOKEN | docker login ghcr.io -u s-allius --password-stdin
|
|
||||||
docker ${BUILD_CMD} ${ARCH} ${LABELS} --no-cache -t ${IMAGE}:latest -t ${IMAGE}:${MAJOR} -t ${IMAGE}:${VERSION} app
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e "${BLUE} => checking docker-compose.yaml file${NC}"
|
echo -e "${BLUE} => checking docker-compose.yaml file${NC}"
|
||||||
docker-compose config -q
|
docker-compose config -q
|
||||||
|
|||||||
94
app/docker-bake.hcl
Normal file
94
app/docker-bake.hcl
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
variable "IMAGE" {
|
||||||
|
default = "tsun-gen3-proxy"
|
||||||
|
}
|
||||||
|
variable "VERSION" {
|
||||||
|
default = "0.0.0"
|
||||||
|
}
|
||||||
|
variable "MAJOR" {
|
||||||
|
default = "0"
|
||||||
|
}
|
||||||
|
variable "BUILD_DATE" {
|
||||||
|
default = "dev"
|
||||||
|
}
|
||||||
|
variable "BRANCH" {
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
variable "DESCRIPTION" {
|
||||||
|
default = "This proxy enables a reliable connection between TSUN third generation inverters (eg. TSOL MS600, MS800, MS2000) and an MQTT broker to integrate the inverter into typical home automations."
|
||||||
|
}
|
||||||
|
|
||||||
|
target "_common" {
|
||||||
|
context = "app"
|
||||||
|
dockerfile = "Dockerfile"
|
||||||
|
args = {
|
||||||
|
VERSION = "${VERSION}"
|
||||||
|
environment = "production"
|
||||||
|
}
|
||||||
|
attest = [
|
||||||
|
"type =provenance,mode=max",
|
||||||
|
"type =sbom,generator=docker/scout-sbom-indexer:latest"
|
||||||
|
]
|
||||||
|
annotations = [
|
||||||
|
"index:org.opencontainers.image.title=TSUN Gen3 Proxy",
|
||||||
|
"index:org.opencontainers.image.authors=Stefan Allius",
|
||||||
|
"index:org.opencontainers.image.created=${BUILD_DATE}",
|
||||||
|
"index:org.opencontainers.image.version=${VERSION}",
|
||||||
|
"index:org.opencontainers.image.revision=${BRANCH}",
|
||||||
|
"index:org.opencontainers.image.description=${DESCRIPTION}",
|
||||||
|
"index:org.opencontainers.image.licenses=BSD-3-Clause",
|
||||||
|
"index:org.opencontainers.image.source=https://github.com/s-allius/tsun-gen3-proxy"
|
||||||
|
]
|
||||||
|
labels = {
|
||||||
|
"org.opencontainers.image.title" = "TSUN Gen3 Proxy"
|
||||||
|
"org.opencontainers.image.authors" = "Stefan Allius"
|
||||||
|
"org.opencontainers.image.created" = "${BUILD_DATE}"
|
||||||
|
"org.opencontainers.image.version" = "${VERSION}"
|
||||||
|
"org.opencontainers.image.revision" = "${BRANCH}"
|
||||||
|
"org.opencontainers.image.description" = "${DESCRIPTION}"
|
||||||
|
"org.opencontainers.image.licenses" = "BSD-3-Clause"
|
||||||
|
"org.opencontainers.image.source" = "https://github.com/s-allius/tsun-gen3-proxy"
|
||||||
|
}
|
||||||
|
output = [
|
||||||
|
"type=image,push=true"
|
||||||
|
]
|
||||||
|
|
||||||
|
no-cache = false
|
||||||
|
platforms = ["linux/amd64", "linux/arm64", "linux/arm/v7"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "_debug" {
|
||||||
|
args = {
|
||||||
|
LOG_LVL = "DEBUG"
|
||||||
|
environment = "dev"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
target "_prod" {
|
||||||
|
args = {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
target "debug" {
|
||||||
|
inherits = ["_common", "_debug"]
|
||||||
|
tags = ["${IMAGE}:debug"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "dev" {
|
||||||
|
inherits = ["_common"]
|
||||||
|
tags = ["${IMAGE}:dev"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "preview" {
|
||||||
|
inherits = ["_common", "_prod"]
|
||||||
|
tags = ["${IMAGE}:dev", "${IMAGE}:${VERSION}"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "rc" {
|
||||||
|
inherits = ["_common", "_prod"]
|
||||||
|
tags = ["${IMAGE}:rc", "${IMAGE}:${VERSION}"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "rel" {
|
||||||
|
inherits = ["_common", "_prod"]
|
||||||
|
|
||||||
|
tags = ["${IMAGE}:latest", "${IMAGE}:${MAJOR}", "${IMAGE}:${VERSION}"]
|
||||||
|
no-cache = true
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user