From fd43ebf6e96dce725e5be0d4edcae9b25744f318 Mon Sep 17 00:00:00 2001 From: Aaron Fischer Date: Thu, 28 Sep 2023 22:40:00 +0200 Subject: [PATCH] Add some metadata and a Dockerfile --- Dockerfile | 11 +++++++++ cmd/server.go | 55 ++++++++++++++++++++++++++++++++++++--------- docker-compose.yaml | 8 +++++++ pkg/sensors/wind.go | 6 +++++ 4 files changed, 70 insertions(+), 10 deletions(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yaml create mode 100644 pkg/sensors/wind.go diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..834f5a7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM golang:alpine AS build +COPY . /app +WORKDIR /app +RUN GOOS=linux go generate +RUN GOOS=linux go build -o oko-spaceapi cmd/server.go + +FROM alpine +WORKDIR /app +COPY --from=build /app/oko-spaceapi /app/oko-spaceapi +EXPOSE 8080 +CMD ["/app/oko-spaceapi"] diff --git a/cmd/server.go b/cmd/server.go index 843b59b..2a45a7b 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -11,21 +11,56 @@ func main() { definition := spaceapi.Root{ // TODO: Fill up with stuff ApiCompatibility: []string{"14"}, - Links: []*spaceapi.LinksItems{ - { - Description: "Out main website", - Name: "website", - Url: "https://okoyono.de", - }, - }, - Space: "økoyono", - Url: "https://okoyono.de/", + Space: "økoyono", + Url: "https://okoyono.de/", Contact: &spaceapi.Contact{ - Email: "contact@okoyono.de", + Email: "oko@datenhalter.de", // TODO: Better email + Mastodon: "@f@social.okoyono.de", // TODO: Replace with real handle + Matrix: "#public:matrix.okoyono.de", }, Location: &spaceapi.Location{ Address: "", }, + Logo: "https://okoyono.de/images/ant.svg", + Links: []*spaceapi.LinksItems{ + { + Description: "Main website", + Name: "website", + Url: "https://okoyono.de", + }, + { + Description: "Forgejo SCM", + Name: "forgejo", + Url: "https://git.okoyono.de", + }, + { + Description: "Mastodon", + Name: "mastodon", + Url: "https://social.okoyono.de", + }, + }, + Projects: []string{ + "https://buchdesmonats.okoyono.de/", + "https://comicdesmonats.okoyono.de/", + "https://git.okoyono.de/okoyono/weatherstation", + }, + Sensors: &spaceapi.Sensors{ + TotalMemberCount: []*spaceapi.TotalMemberCountItems{ + { + Description: "We are a small group of people from south Germany, meeting remote on a regular basis.", + Location: "Remote", + Value: 7, + }, + }, + //Temperature: []*spaceapi.TemperatureItems{ + // { + // Location: "@f", + // Name: "weatherstatiøn", + // Description: "Weatherstatiøn located at @f.", + // Value: sensors.TemperatureF(), + // }, + //}, + }, } json, err := definition.MarshalJSON() diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..ababb63 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,8 @@ +version: "3" + +services: + spaceapi: + build: . + restart: always + ports: + - "8080:8080" \ No newline at end of file diff --git a/pkg/sensors/wind.go b/pkg/sensors/wind.go new file mode 100644 index 0000000..632abb8 --- /dev/null +++ b/pkg/sensors/wind.go @@ -0,0 +1,6 @@ +package sensors + +func TemperatureF() float64 { + // TODO: Fetch from influxdb (or remove influxdb finally!) + return 10.0 +}