Skip to content
Permalink
Browse files

Go modules and Docker builder

  • Loading branch information...
s32x committed Feb 17, 2019
1 parent 5d45c22 commit c23a56267d3dfed70b2b78501ec26c4ced0bdf3c
Showing 2,939 changed files with 79 additions and 707,290 deletions.
@@ -6,18 +6,15 @@ jobs:
- DOCKER_TAG: s32x/ipdata
- HEROKU_APP: ipdatainfo
docker:
- image: circleci/golang:1.11.4
- image: circleci/golang:1.11.5
steps:
- checkout
- run:
name: Install Packr
command: go get -u github.com/gobuffalo/packr/v2/packr2
name: Download vendored Go dependencies
command: GO111MODULE=on go mod vendor
- run:
name: Run unit tests
command: make test
- run:
name: Build binary for Alpine linux
command: env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 packr2 build -ldflags="-s -w" -o bin/server
- setup_remote_docker
- run:
name: Build Docker image with binary
@@ -32,11 +29,5 @@ jobs:
name: Install the Heroku CLI
command: curl https://cli-assets.heroku.com/install.sh | sh
- run:
name: Login to Heroku Containers
command: heroku container:login
- run:
name: Push the image to Heroku
command: heroku container:push web -a $HEROKU_APP
- run:
name: Release the image on Heroku
command: heroku container:release web -a $HEROKU_APP
name: Deploy the app
command: make deploy
@@ -0,0 +1,3 @@
vendor
bin
run.sh
@@ -1,4 +1,27 @@
# ============================== BINARY BUILDER ==============================
FROM golang:1.11.5 as builder

# Copy in the source
WORKDIR /go/src/s32x.com/ipdata
COPY / .

# Dependencies
RUN apt-get update -y && \
apt-get upgrade -y
RUN GO111MODULE=on go mod vendor

# Build the binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./bin/server

# =============================== FINAL IMAGE ===============================
FROM alpine:latest

# Dependencies
RUN apk add --no-cache ca-certificates
ADD bin/server /usr/local/bin/server
CMD server

# Static files
COPY service/static /service/static

# Binary
COPY --from=builder /go/src/s32x.com/ipdata/bin/server /usr/local/bin/server
CMD ["server"]
@@ -1,7 +1,7 @@
The BSD 3-clause License
========================

Copyright (c) 2018, Steven Wolfe. All rights reserved.
Copyright (c) 2019, Steven Wolfe. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -1,21 +1,16 @@
clean:
-rm -rf bin
packr2 clean
deps:
make clean
-rm -rf vendor
-rm -r glide.yaml
-rm -f glide.lock
glide cache-clear
glide init --non-interactive
glide install
-rm -f go.mod
-rm -f go.sum
go clean
GO111MODULE=on go mod init
GO111MODULE=on go mod vendor
test:
go test ./...
run:
make clean
packr2 build -ldflags="-s -w" -o ./bin/server
./bin/server
install:
make clean
make deps
packr2 install
go install
deploy:
heroku container:login
heroku container:push web -a ipdatainfo
heroku container:release web -a ipdatainfo
@@ -1,13 +1,13 @@
<p align="center">
<img src="service/web/assets/logo.png" width="310" height="110" border="0" alt="ipdata">
<img src="service/static/assets/logo.png" width="310" height="110" border="0" alt="ipdata">
<br>
<a href="https://circleci.com/gh/s32x/ipdata/tree/master"><img src="https://circleci.com/gh/s32x/ipdata/tree/master.svg?style=svg" alt="CircleCI"></a>
<a href="https://goreportcard.com/report/s32x.com/ipdata"><img src="https://goreportcard.com/badge/s32x.com/ipdata" alt="Go Report Card"></a>
<a href="https://godoc.org/s32x.com/ipdata/ipdata"><img src="https://godoc.org/s32x.com/ipdata/ipdata?status.svg" alt="GoDoc"></a>
</p>

<p align="center">
<img src="service/web/assets/graphic.png" width="650px" height="418px" alt="ipdata curl">
<img src="service/static/assets/graphic.png" width="650px" height="418px" alt="ipdata curl">
</p>

`ipdata` is a free and open-source ip address lookup system. It combines the results retrieved from multiple maxminddb databases to provide you general geo/isp data for version 4 addresses. The project is currently available as a [publicly consumable API](#public-api-usage), an easily importable [Golang package called `ipdata`](#full-go-example) for use in your own Go projects, and a public [Docker image on DockerHub](https://hub.docker.com/r/s32x/ipdata/).
@@ -88,7 +88,7 @@ func main() {
The BSD 3-clause License
========================

Copyright (c) 2018, Steven Wolfe. All rights reserved.
Copyright (c) 2019, Steven Wolfe. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
16 go.mod
@@ -0,0 +1,16 @@
module s32x.com/ipdata

require (
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
github.com/labstack/echo v3.3.10+incompatible
github.com/labstack/gommon v0.2.8 // indirect
github.com/mattn/go-colorable v0.1.0 // indirect
github.com/mattn/go-isatty v0.0.4 // indirect
github.com/mmcloughlin/geohash v0.0.0-20181009053802-f7f2bcae3294
github.com/oschwald/maxminddb-golang v1.3.0
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v0.0.0-20170224212429-dcecefd839c4 // indirect
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67 // indirect
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a // indirect
)
15 go.sum
@@ -0,0 +1,15 @@
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/labstack/echo v3.3.10+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s=
github.com/labstack/gommon v0.2.8/go.mod h1:/tj9csK2iPSBvn+3NLM9e52usepMtrd5ilFYA+wQNJ4=
github.com/mattn/go-colorable v0.1.0 h1:v2XXALHHh6zHfYTJ+cSkwtyffnaOyR1MXaA91mTrb8o=
github.com/mattn/go-colorable v0.1.0/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mmcloughlin/geohash v0.0.0-20181009053802-f7f2bcae3294/go.mod h1:oNZxQo5yWJh0eMQEP/8hwQuVx9Z9tjwFUqcTB1SmG0c=
github.com/oschwald/maxminddb-golang v1.3.0/go.mod h1:3jhIUymTJ5VREKyIhWm66LJiQt04F0UCDdodShpjWsY=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v0.0.0-20170224212429-dcecefd839c4/go.mod h1:50wTf68f99/Zt14pr046Tgt3Lp2vLyFZKzbFXTOabXw=
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67 h1:ng3VDlRp5/DHpSWl02R4rM9I+8M2rhmsuLwAMmkLQWE=
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -5,7 +5,6 @@ import (
"net/http"
"strings"

packr "github.com/gobuffalo/packr/v2"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
"s32x.com/ipdata/ipdata"
@@ -41,8 +40,7 @@ func Start(port, env string) {
e.Use(middleware.Gzip())

// Serve the static web content on the base echo instance
wb := packr.New("web box", "./web")
e.GET("*", echo.WrapHandler(http.FileServer(wb)))
e.Static("*", "./service/static")

// Create the API group with separate middlewares
api := e.Group("/lookup")
File renamed without changes.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit c23a562

Please sign in to comment.
You can’t perform that action at this time.