feat(db): add deploiement stack
Signed-off-by: Klagarge <remi@heredero.ch>
This commit is contained in:
@@ -1,5 +1,11 @@
|
|||||||
INFLUX_PORT=8181
|
INFLUX_PORT=8181
|
||||||
UI_PORT=8093
|
UI_PORT=8093
|
||||||
|
INFLUX_DATABASE=provence
|
||||||
|
|
||||||
|
REST_PORT=8080
|
||||||
|
REST_USERNAME=
|
||||||
|
REST_PASSWORD=
|
||||||
|
|
||||||
MQTT_BROKER_URL=tls://mqtt.e.kb28.ch:8883
|
MQTT_BROKER_URL=tls://mqtt.e.kb28.ch:8883
|
||||||
MQTT_USERNAME=
|
MQTT_USERNAME=
|
||||||
MQTT_PASSWORD=
|
MQTT_PASSWORD=
|
||||||
|
|||||||
26
db/Dockerfile
Normal file
26
db/Dockerfile
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
FROM golang:1.25-alpine AS builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY ./src/go.mod ./src/go.sum ./
|
||||||
|
RUN go mod tidy
|
||||||
|
|
||||||
|
COPY ./src .
|
||||||
|
RUN CGO_ENABLED=0 go build -ldflags="-w -s" -o /gateway .
|
||||||
|
|
||||||
|
|
||||||
|
FROM alpine:latest AS certs
|
||||||
|
RUN apk --no-cache add ca-certificates
|
||||||
|
|
||||||
|
FROM scratch AS final
|
||||||
|
LABEL org.opencontainers.image.authors="remi.heredero@hevs.ch" \
|
||||||
|
org.opencontainers.image.title="PI-E2EEDA Gateway MQTT/Influx/REST" \
|
||||||
|
org.opencontainers.image.description="This container is an application for the E2EEDA PI. Use MQTT to communicate with devices, enabling real-time updates and control. Time-series data, such as device states, is stored in InfluxDB for analytics and monitoring. A REST API provides external access for managing devices and retrieving data." \
|
||||||
|
org.opencontainers.image.source="https://github.com/PI-E2EEDA/Plein-de-eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-project"
|
||||||
|
|
||||||
|
COPY --from=builder /gateway /gateway
|
||||||
|
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
ENTRYPOINT ["/gateway"]
|
||||||
@@ -74,6 +74,34 @@ services:
|
|||||||
- RABBITMQ_DEFAULT_PASS=${MQTT_PASSWORD:?MQTT_PASSWORD is required}
|
- RABBITMQ_DEFAULT_PASS=${MQTT_PASSWORD:?MQTT_PASSWORD is required}
|
||||||
command: sh -c "rabbitmq-plugins enable rabbitmq_mqtt && rabbitmq-server"
|
command: sh -c "rabbitmq-plugins enable rabbitmq_mqtt && rabbitmq-server"
|
||||||
|
|
||||||
|
gateway:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
depends_on:
|
||||||
|
influxdb:
|
||||||
|
condition: service_healthy
|
||||||
|
mqtt:
|
||||||
|
condition: service_started
|
||||||
|
environment:
|
||||||
|
- MQTT_BROKER_URL=${MQTT_BROKER_URL:-mqtt://mqtt:1883}
|
||||||
|
- MQTT_USERNAME=${MQTT_USERNAME:?MQTT_USERNAME is required}
|
||||||
|
- MQTT_PASSWORD=${MQTT_PASSWORD:?MQTT_PASSWORD is required}
|
||||||
|
- INFLUX_URL=${INFLUX_URL:-http://influxdb:${INFLUX_PORT:-8181}}
|
||||||
|
- INFLUX_DATABASE=${INFLUX_DATABASE}
|
||||||
|
- INFLUX_TOKEN_FILE=/run/secrets/admin-token
|
||||||
|
- REST_PORT=${REST_PORT:-8080}
|
||||||
|
- REST_USERNAME=${REST_USERNAME}
|
||||||
|
- REST_PASSWORD=${REST_PASSWORD}
|
||||||
|
- MAPPING_CONFIG_PATH=/config/mapping.json
|
||||||
|
secrets:
|
||||||
|
- admin-token
|
||||||
|
volumes:
|
||||||
|
- ./mapping.json:/config/mapping.json:ro
|
||||||
|
ports:
|
||||||
|
- "${REST_PORT:-8080}:8080"
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
influxdb3_data:
|
influxdb3_data:
|
||||||
rabbitmq_data:
|
rabbitmq_data:
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ func mqttConnection() *mqtt.MqttGateway {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func influxConnection() *influx.InfluxGateway {
|
func influxConnection() *influx.InfluxGateway {
|
||||||
influxUrl := getEnv("INFLUX_URL", "https://db.e.kb28.ch:443")
|
influxUrl := getEnv("INFLUX_URL", "http://influxdb:8181")
|
||||||
|
|
||||||
influxDatabase := getEnv("INFLUX_DATABASE", "provence")
|
influxDatabase := getEnv("INFLUX_DATABASE", "provence")
|
||||||
influxToken := getEnv("INFLUX_TOKEN", "")
|
influxToken := getEnv("INFLUX_TOKEN", "")
|
||||||
|
|||||||
Reference in New Issue
Block a user