Skip to content

Commit

Permalink
Merge pull request #197 from MattKobayashi/main
Browse files Browse the repository at this point in the history
Add support for Docker secrets
  • Loading branch information
oschwald authored Jan 16, 2023
2 parents 077a94f + 1a2c1d9 commit 1d7dafd
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
38 changes: 38 additions & 0 deletions doc/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ variables are required:

The following are optional:

* `GEOIPUPDATE_ACCOUNT_ID_FILE` - The path to a file containing your MaxMind account ID. This is intended to be used with Docker secrets (example below).
* `GEOIPUPDATE_LICENSE_KEY_FILE` - The path to a file containing your case-sensitive MaxMind license key. This is intended to be used with Docker secrets (example below).
* `GEOIPUPDATE_FREQUENCY` - The number of hours between `geoipupdate` runs.
If this is not set or is set to `0`, `geoipupdate` will run once and exit.
* `GEOIPUPDATE_HOST` - The host name of the server to use. The default is
Expand Down Expand Up @@ -84,6 +86,42 @@ volumes:
driver: local
```
You may also pass your MaxMind account ID and license key as secrets, for example:
```yaml
version: '3'
services:
geoipupdate:
container_name: geoipupdate
image: maxmindinc/geoipupdate
restart: unless-stopped
environment:
- 'GEOIPUPDATE_ACCOUNT_ID_FILE=/run/secrets/GEOIPUPDATE_ACCOUNT_ID'
- 'GEOIPUPDATE_LICENSE_KEY_FILE=/run/secrets/GEOIPUPDATE_LICENSE_KEY'
- 'GEOIPUPDATE_EDITION_IDS=GeoLite2-ASN GeoLite2-City GeoLite2-Country'
- GEOIPUPDATE_FREQUENCY=72
networks:
- geoipupdate
volumes:
- 'geoipupdate_data:/usr/share/GeoIP'
secrets:
- GEOIPUPDATE_ACCOUNT_ID
- GEOIPUPDATE_LICENSE_KEY

networks:
geoipupdate:

volumes:
geoipupdate_data:
driver: local

secrets:
GEOIPUPDATE_ACCOUNT_ID:
file: ./secrets/GEOIPUPDATE_ACCOUNT_ID.txt
GEOIPUPDATE_LICENSE_KEY:
file: ./secrets/GEOIPUPDATE_LICENSE_KEY.txt
```
Note - When using docker-compose, you need to either:
* set `GEOIPUPDATE_FREQUENCY` equal to something greater than 0 or
Expand Down
8 changes: 8 additions & 0 deletions docker/entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ if ! [ -z "$GEOIPUPDATE_DB_DIR" ]; then
database_dir=$GEOIPUPDATE_DB_DIR
fi

if [ ! -z "$GEOIPUPDATE_ACCOUNT_ID_FILE" ]; then
GEOIP_UPDATE_ACCOUNT_ID=$( cat "$GEOIPUPDATE_ACCOUNT_ID_FILE" )
fi

if [ ! -z "$GEOIPUPDATE_LICENSE_KEY_FILE" ]; then
GEOIP_UPDATE_LICENSE_KEY=$( cat "$GEOIPUPDATE_LICENSE_KEY_FILE" )
fi

if [ -z "$GEOIPUPDATE_ACCOUNT_ID" ] || [ -z "$GEOIPUPDATE_LICENSE_KEY" ] || [ -z "$GEOIPUPDATE_EDITION_IDS" ]; then
echo "ERROR: You must set the environment variables GEOIPUPDATE_ACCOUNT_ID, GEOIPUPDATE_LICENSE_KEY, and GEOIPUPDATE_EDITION_IDS!"
exit 1
Expand Down

0 comments on commit 1d7dafd

Please sign in to comment.