parent
1a8d3572be
commit
80de438800
@ -0,0 +1,27 @@
|
||||
################################################################################
|
||||
## MAIN STAGE ##
|
||||
################################################################################
|
||||
# Copy the manager into the distroless image.
|
||||
#FROM scratch
|
||||
#FROM hub.sre.ink/base/distroless-static:nonroot-20210710
|
||||
#FROM mirror.ccs.tencentyun.com/library/alpine:3.13
|
||||
FROM alpine:3.15.0
|
||||
#FROM hub.sre.ink/base/alpine:3.15.0
|
||||
#FROM centos:7.9.2009
|
||||
LABEL Description="sre ip region service"
|
||||
MAINTAINER sre <sre@yangqiao.org>
|
||||
#RUN echo 'https://mirrors.cloud.tencent.com/alpine/v3.13/main' > /etc/apk/repositories \
|
||||
# && echo 'https://mirrors.cloud.tencent.com/alpine/v3.13/community' >>/etc/apk/repositories \
|
||||
# && apk update && apk add tzdata && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
|
||||
# && echo "Asia/Shanghai" > /etc/timezone
|
||||
RUN apk update && apk add tzdata && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
|
||||
&& echo "Asia/Shanghai" > /etc/timezone
|
||||
|
||||
WORKDIR /app
|
||||
ADD ipregion.bin /app/ipregion.bin
|
||||
COPY ip2region.db /app/ip2region.db
|
||||
RUN chmod -R 777 /app
|
||||
|
||||
#USER nonroot:nonroot
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT ["/app/ipregion.bin"]
|
||||
@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"IPRegion/global"
|
||||
"IPRegion/ip2region"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestIpInfo(tt *testing.T) {
|
||||
address := "114.114.114.114"
|
||||
var ipInfo ip2region.IpInfo
|
||||
ipInfo, _ = GetIPInfo(address, global.SearchType)
|
||||
res, _ := json.Marshal(ipInfo)
|
||||
fmt.Println(string(res))
|
||||
|
||||
}
|
||||
Loading…
Reference in new issue