Weather service installation

This commit is contained in:
2024-12-26 09:36:09 +01:00
parent f2050c1085
commit 2ca39264d1
10 changed files with 50 additions and 17 deletions

View File

@@ -1,6 +1,6 @@
weather_weather_api_base_url=https://api.openweathermap.org/data/2.5/weather
weather_weather_api_key=4ce897f7ce77f84919fd990cc68d9d20
weather_influx_db_base_url=http://192.168.1.44:8092
weather_influx_db_token=R1BGVaxWrX_ySaovweRz6ZTBDvHa5omQkricJGmn3PrI44jpfU7411PSmHOCjGcNR7OcBjmtE9gA62boHHXoKg==
weather_latitude=50.854019
weather_longitude=3.355230
weather_weather_api_base_url=
weather_weather_api_key=
weather_influx_db_base_url=
weather_influx_db_token=
weather_latitude=
weather_longitude=

View File

@@ -1,4 +1,4 @@
FROM rust:1.67 as builder
FROM rust:1.71 as builder
WORKDIR /usr/src/weather
COPY . .
RUN cargo install --path .

View File

@@ -1,5 +0,0 @@
#!/usr/bin/env bash
docker build . -t weather-microservice:latest
docker tag weather-microservice:latest registry.willemserruys.com/weather-microservice:latest
docker push registry.willemserruys.com/weather-microservice:latest

View File

@@ -1,4 +0,0 @@
#!/usr/bin/env bash
file=/home/willem/repos/homeAutomation/microservices/weather/logs.$(date "+%F").txt
docker run --env RUST_LOG=info --env-file /home/willem/repos/homeAutomation/microservices/weather/.env registry.willemserruys.com/weather-microservice:latest &>> $file

View File

@@ -0,0 +1,3 @@
#!/usr/bin/env bash
docker build ../ -t weather-service:latest

View File

@@ -0,0 +1,21 @@
#!/usr/bin/bash
# This script should be run as root
# Build and install weather service
./build-docker.sh
ln -s $HOME/repos/homeAutomation/microservices/weather/run-docker.sh /usr/bin/weather-service
cp weather.service /etc/systemd/system/
cp weather.timer /etc/systemd/system/
systemctl daemon-reload
systemctl enable weather.service
systemctl enable weather.timer
systemctl start weather.service
systemctl start weather.timer

View File

@@ -0,0 +1,3 @@
#!/usr/bin/env bash
# Make sure the weather-service-image exists locally (e.g. by running the build-docker script)
docker run --env RUST_LOG=info --env-file /home/pi/repos/homeAutomation/microservices/weather/.env.production weather-service:latest

View File

@@ -0,0 +1,8 @@
[Unit]
Description=Weather Service
[Service]
ExecStart=/usr/bin/weather-service
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,8 @@
[Unit]
Description=Run weather service each 2 minutes
[Timer]
OnCalendar=*:0/2
[Install]
WantedBy=timers.target