Skip to content

Commit

Permalink
feat: change dockerfile to add cron func
Browse files Browse the repository at this point in the history
  • Loading branch information
Dim145 committed May 29, 2024
1 parent c5df3ec commit 24e12ae
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 * * * *
12 changes: 12 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 24e12ae

Please sign in to comment.