diff --git a/Dockerfile b/Dockerfile index efa2c2a..4e7c097 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 6da0029..ef73764 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -1,5 +1,3 @@ -version: '3.9' - services: ipinfo: build: . diff --git a/docker-compose.yml b/docker-compose.yml index ccafcfc..bacf78a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.9' - services: ipinfo: image: ghcr.io/skidoodle/ipinfo:main diff --git a/iputils.go b/iputils.go index 27c6e73..10c42c2 100644 --- a/iputils.go +++ b/iputils.go @@ -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)), } } diff --git a/server.go b/server.go index ec004e7..239604e 100644 --- a/server.go +++ b/server.go @@ -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: