diff --git a/Dockerfile b/Dockerfile index 131d640..f5e9188 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,9 +13,14 @@ RUN dotnet build "Hariane2Mqtt.csproj" -c $BUILD_CONFIGURATION -o /app/build FROM build AS publish ARG BUILD_CONFIGURATION=Release -RUN dotnet publish "Hariane2Mqtt.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false +RUN dotnet publish "Hariane2Mqtt.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:SelfContained=true -FROM base AS final +FROM mcr.microsoft.com/dotnet/runtime-deps:8.0-alpine AS final WORKDIR /app COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "Hariane2Mqtt.dll"] + +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +CMD ["/entrypoint.sh"] diff --git a/docker-compose.yml b/docker-compose.yml index 66f85a4..4ba8d84 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,3 +4,13 @@ build: context: . dockerfile: Dockerfile + environment: + DEBUG: false + HARIANE_NUM_CONTRAT: "123456789" + HARIANE_PASSWORD: "123456789" + HARIANE_USERNAME: "prenom.nom" + MQTT_CLIENT_ID: harianne2mqtt_client + MQTT_HOST: "XXX.XXX.XXX.XXX" + MQTT_PASSWORD: "123456789" + MQTT_PORT: 1883 + CRON: 0 * * * * \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..f0d4deb --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +if [ -z "$CRON" ]; then + echo "CRON is not set. Exiting." + exit 1 +fi + +echo "$CRON" + +echo "$CRON /app/Hariane2Mqtt > /dev/stdout 2> /dev/stdout" > /etc/crontabs/root + +crond -f -L /dev/stdout \ No newline at end of file