Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maxmind/mmdb-from-go-blogpost
Enriching MMDB files with your own data using Go.
https://github.com/maxmind/mmdb-from-go-blogpost
cidr database geoip2 geolite2 geolite2-country ip maxmind mmdb
Last synced: about 2 months ago
JSON representation
Enriching MMDB files with your own data using Go.
- Host: GitHub
- URL: https://github.com/maxmind/mmdb-from-go-blogpost
- Owner: maxmind
- License: apache-2.0
- Created: 2020-08-29T11:34:24.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-09-29T17:56:48.000Z (about 1 year ago)
- Last Synced: 2024-06-21T18:11:46.544Z (6 months ago)
- Topics: cidr, database, geoip2, geolite2, geolite2-country, ip, maxmind, mmdb
- Language: Go
- Homepage: https://blog.maxmind.com/2020/09/01/enriching-mmdb-files-with-your-own-data-using-go/
- Size: 48.8 KB
- Stars: 23
- Watchers: 15
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README-Docker.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# Docker README
* [Getting Started](#getting-started)
* [Building Your Docker Container](#building-your-docker-container)
* [Refactoring Your Code](#refactoring-your-code)
* [Mapping your local volume to the Docker container](#mapping-your-local-volume-to-the-docker-container)
* [Creating the database](#creating-the-database)## Getting Started
A `Dockerfile` has been provided in order to make this code more convenient to run. To get started via `Docker`, you'll need:
* A working Docker environment
* A `git checkout` of this repository
* A copy of `GeoLite2-Country.mmdb` in the root of this repository## Building Your Docker Container
After you have checked out this repository and added `GeoLite2-Country.mmdb` to the root directory of the repository, run this command from the root directory. (Linux users may need to preface this command with `sudo`).
```bash
docker build . -t mmdb-from-go
```This will build your Docker container, build your `Go` code and also run the example code for you. To log in to your container, run this command. (Linux users may need to preface this command with `sudo`).
```bash
docker run -it mmdb-from-go:latest /bin/bash
```Once you have logged in, you can test out your freshly created database:
```bash
mmdbinspect -db GeoLite2-Country.mmdb \
-db GeoLite2-Country-with-Department-Data.mmdb \
56.0.0.1 56.1.0.0/24 56.2.0.54 56.3.0.1 | less
```## Refactoring Your Code
You can freely edit the code outside of the Docker container and then re-run it from inside the container. To do so, you'll need to map your local volume to the container and then rebuild the database.
### Mapping your local volume to the Docker container
```bash
docker run -it --volume $(pwd):/project mmdb-from-go:latest /bin/bash
```### Creating the database
Once you are logged in to your container, run the following code:
```bash
go build && ./mmdb-from-go-blogpost
```