Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make a docker container out of this? #16

Closed
Waldorf3 opened this issue Oct 5, 2023 · 5 comments
Closed

How to make a docker container out of this? #16

Waldorf3 opened this issue Oct 5, 2023 · 5 comments

Comments

@Waldorf3
Copy link

Waldorf3 commented Oct 5, 2023

Hi,
This is really cool, exactly what I need, but I can't find any built docker container for it, and I haven't got a clue how to build one. I'm not a developer.

I followed instructions at https://stackify.com/docker-build-a-beginners-guide-to-building-docker-images which suggested this

Building Docker images
With Dockerfile written, you can build the image using the following command:

$ docker build .
We can see the image we just built using the command docker images.

$ docker images
If you run the command above, you will see something similar to the output below.

REPOSITORY TAG IMAGE ID CREATED SIZE
7b341adb0bf1 2 minutes ago 83.2MB

But that wasn't quite what I got:

sudo docker build .
[+] Building 10.9s (9/10)                                                                                docker:default
 => [internal] load build definition from Dockerfile                                                               0.1s
 => => transferring dockerfile: 370B                                                                               0.0s
 => [internal] load .dockerignore                                                                                  0.1s
 => => transferring context: 2B                                                                                    0.0s
 => [internal] load metadata for docker.io/library/golang:1.21-alpine                                              2.1s
 => [builder 1/4] FROM docker.io/library/golang:1.21-alpine@sha256:1c9cc949513477766da12bfa80541c4f24957323b0ee00  6.6s
 => => resolve docker.io/library/golang:1.21-alpine@sha256:1c9cc949513477766da12bfa80541c4f24957323b0ee00630a6ff4  0.0s
 => => sha256:3380a7e42c62007b14a7285882f764255d92e933ca7b31ae181f4b4dcd10fc06 1.16kB / 1.16kB                     0.0s
 => => sha256:ba29250af387de3f8daa10fe591b0911922513ea635082b90420baaa76fe814d 6.32kB / 6.32kB                     0.0s
 => => sha256:cc37b24bb09971feb8bf4882e861bce9db0c985a16a900adb0dc9de3f854243b 284.69kB / 284.69kB                 0.2s
 => => sha256:94517ad51c70c15adb540d431b757078be8f6214a2f1d2181afc9454fa65d281 67.00MB / 67.00MB                   1.8s
 => => sha256:2087470b845b2224ab3a61dafcdf2abbf9540f77be63368c3346b85ad2969fa6 155B / 155B                         0.2s
 => => sha256:1c9cc949513477766da12bfa80541c4f24957323b0ee00630a6ff4ccf334b75b 1.65kB / 1.65kB                     0.0s
 => => extracting sha256:cc37b24bb09971feb8bf4882e861bce9db0c985a16a900adb0dc9de3f854243b                          0.1s
 => => extracting sha256:94517ad51c70c15adb540d431b757078be8f6214a2f1d2181afc9454fa65d281                          3.4s
 => => extracting sha256:2087470b845b2224ab3a61dafcdf2abbf9540f77be63368c3346b85ad2969fa6                          0.0s
 => [internal] load build context                                                                                  0.0s
 => => transferring context: 370B                                                                                  0.0s
 => [stage-1 1/2] WORKDIR /app                                                                                     0.0s
 => [builder 2/4] WORKDIR /app                                                                                     0.3s
 => [builder 3/4] COPY . .                                                                                         0.1s
 => ERROR [builder 4/4] RUN apk add make git upx && make build VERSION=     && upx --best --lzma whatismyip        1.6s
------
 > [builder 4/4] RUN apk add make git upx && make build VERSION=     && upx --best --lzma whatismyip:
0.507 fetch https://dl-cdn.alpinelinux.org/alpine/v3.18/main/x86_64/APKINDEX.tar.gz
0.744 fetch https://dl-cdn.alpinelinux.org/alpine/v3.18/community/x86_64/APKINDEX.tar.gz
1.139 (1/12) Installing brotli-libs (1.0.9-r14)
1.163 (2/12) Installing libunistring (1.1-r1)
1.199 (3/12) Installing libidn2 (2.3.4-r1)
1.210 (4/12) Installing nghttp2-libs (1.55.1-r0)
1.219 (5/12) Installing libcurl (8.3.0-r0)
1.237 (6/12) Installing libexpat (2.5.0-r1)
1.247 (7/12) Installing pcre2 (10.42-r1)
1.274 (8/12) Installing git (2.40.1-r0)
1.376 (9/12) Installing make (4.4.1-r1)
1.387 (10/12) Installing libgcc (12.2.1_git20220924-r10)
1.400 (11/12) Installing libstdc++ (12.2.1_git20220924-r10)
1.435 (12/12) Installing upx (4.0.2-r0)
1.460 Executing busybox-1.36.1-r2.trigger
1.473 OK: 23 MiB in 28 packages
1.544 make: *** No rule to make target 'build'.  Stop.
------
Dockerfile:10
--------------------
   9 |
  10 | >>> RUN apk add make git upx && make build VERSION=$VERSION \
  11 | >>>     && upx --best --lzma whatismyip
  12 |
--------------------
ERROR: failed to solve: process "/bin/sh -c apk add make git upx && make build VERSION=$VERSION     && upx --best --lzma whatismyip" did not complete successfully: exit code: 2

Any chance you could offer some guidance here? Most appreciated!

@dcarrillo
Copy link
Owner

Hi, Thank you for using this project.

I not sure why you can't build the docker image locally, but you can use the official docker image from dockerhub (linux/amd64) as explained here

Regards.

@Waldorf3
Copy link
Author

Waldorf3 commented Oct 5, 2023

Very cool, cheers.

I kinda saw the image on docker hub, but without explanation. So looking at

docker run --tty --interactive --rm \
    -v $PWD/<path to city database>:/tmp/GeoIP2-City-Test.mmdb:ro \
    -v $PWD/<path to ASN database>:/tmp/GeoLite2-ASN-Test.mmdb:ro -p 8080:8080 \
    dcarrillo/whatismyip:latest \
      -geoip2-city /tmp/GeoIP2-City-Test.mmdb \
      -geoip2-asn /tmp/GeoLite2-ASN-Test.mmdb
  1. Where can I find the databases?
  2. I don't really understand the last two lines, are they environment variables or something?

@dcarrillo
Copy link
Owner

dcarrillo commented Oct 6, 2023

The databases, as explained in the documentation, can be downloaded from MaxMind. For testing purposes, you can use the ones located in the test directory (these databases contain a minimal set of data).

The last two lines set the minimal parameters you need to pass for the service to work, which are the database paths.

@juanrodgil
Copy link

juanrodgil commented Mar 24, 2024

Could be cool to add the posibility to configure the geoip locations and the template with enviroments variables, so it could be used with docker-compose.

Something like this

version: '3.5'

services:

  geoipupdate:
    container_name: geoipupdate
    image: ghcr.io/maxmind/geoipupdate
    restart: unless-stopped
    environment:
      - GEOIPUPDATE_ACCOUNT_ID=######
      - GEOIPUPDATE_LICENSE_KEY=###################
      - 'GEOIPUPDATE_EDITION_IDS=GeoLite2-ASN GeoLite2-City GeoLite2-Country'
      - GEOIPUPDATE_FREQUENCY=72
    volumes:
      - ${CONFIG_PATH}/geoipupdate:/usr/share/GeoIP
    networks:
      - default

  whatismyip:
    container_name: whatismyip
    image: dcarrillo/whatismyip
    restart: unless-stopped
    environment:
      - geoip2-city=/usr/share/GeoIP/GeoLite2-City.mmdb
      - geoip2-asn=/usr/share/GeoIP/GeoLite2-ASN.mmdb
    ports:
      - 84:8080
    volumes:
      - ${CONFIG_PATH}/geoipupdate:/usr/share/GeoIP:ro
    networks:
      - default

networks:
  default:
    driver: bridge

@dcarrillo
Copy link
Owner

Hi, this is a closed issue, if you have any other question please open a new one.

Regarding your suggestion, indeed, having ENVARS could be a good idea, in the meantime, you can always add a command configuration to your docker compose file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants