test updates

This commit is contained in:
skidoodle 2024-09-07 18:59:47 +02:00
parent 7e14ec4d76
commit d4ac1c0dd8
5 changed files with 10 additions and 5 deletions

View file

@ -8,7 +8,8 @@ RUN go install github.com/maxmind/geoipupdate/v7/cmd/geoipupdate@latest
RUN mkdir -p /build/data
FROM alpine:latest
RUN apk add --no-cache curl
RUN apk add --no-cache curl tzdata busybox-suid
WORKDIR /app
COPY --from=builder /build/ipinfo .
COPY --from=builder /go/bin/geoipupdate /usr/local/bin/geoipupdate
@ -23,6 +24,9 @@ RUN echo "AccountID ${GEOIPUPDATE_ACCOUNT_ID}" > /etc/GeoIP.conf && \
echo "EditionIDs ${GEOIPUPDATE_EDITION_IDS}" >> /etc/GeoIP.conf && \
echo "DatabaseDirectory ${GEOIPUPDATE_DB_DIR}" >> /etc/GeoIP.conf
RUN echo "0 0 * * * geoipupdate >> /var/log/geoipupdate.log 2>&1" > /etc/crontabs/root
RUN cat /etc/crontabs/root
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s CMD curl --fail http://localhost:3000/ || exit 1
EXPOSE 3000

View file

@ -1,5 +1,3 @@
version: '3.9'
services:
ipinfo:
build: .

View file

@ -1,5 +1,3 @@
version: '3.9'
services:
ipinfo:
image: ghcr.io/skidoodle/ipinfo:main

View file

@ -114,6 +114,7 @@ func lookupIPData(ip net.IP) *dataStruct {
Location struct {
Latitude float64 `maxminddb:"latitude"`
Longitude float64 `maxminddb:"longitude"`
Timezone string `maxminddb:"time_zone"`
} `maxminddb:"location"`
}
err := cityDB.Lookup(ip, &cityRecord)
@ -152,6 +153,7 @@ func lookupIPData(ip net.IP) *dataStruct {
Region: sd,
Country: toPtr(cityRecord.Country.Names["en"]),
Continent: toPtr(cityRecord.Continent.Names["en"]),
Timezone: toPtr(cityRecord.Location.Timezone),
Loc: toPtr(fmt.Sprintf("%.4f,%.4f", cityRecord.Location.Latitude, cityRecord.Location.Longitude)),
}
}

View file

@ -21,6 +21,7 @@ type dataStruct struct {
Region *string `json:"region"`
Country *string `json:"country"`
Continent *string `json:"continent"`
Timezone *string `json:"timezone"`
Loc *string `json:"loc"`
}
@ -124,6 +125,8 @@ func getField(data *dataStruct, field string) *string {
return data.Country
case "continent":
return data.Continent
case "timezone":
return data.Timezone
case "loc":
return data.Loc
default: