Skip to content

Developer's Guide

Eric Marti edited this page Dec 19, 2020 · 4 revisions

Building your own image

Before you try to build, ensure that you have docker installed and running:

$ docker version
Client: Docker Engine - Community
 Cloud integration: 1.0.2
 Version:           19.03.13
 API version:       1.40
 Go version:        go1.13.15
 Git commit:        4484c46d9d
 Built:             Wed Sep 16 16:58:31 2020
 OS/Arch:           darwin/amd64
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          19.03.13
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       4484c46d9d
  Built:            Wed Sep 16 17:07:04 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.3.7
  GitCommit:        8fba4e9a7d01810a393d5d25a3621dc101981175
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

If you see an Error response from daemon: dial unix docker.raw.sock: connect: connection refused error, please see this support page: Docker Docs

To speed up the build process, pull the latest image from Docker Hub:

$ docker pull ericjmarti/inventory-hunter:latest

Finally, to build your own Docker image, run the following command from the inventory-hunter directory:

$ docker build -t my-inventory-hunter .

Note: The docker build command may take a while to complete. If you experience errors during the build, check to see if there is sufficient memory available on your build host.

Running unit tests

Now that you have your own Docker image built, try running the unit test suite:

$ ./run_tests.bash -i my-inventory-hunter

The run_tests.bash script will start up a container and map the tests directory from your workspace into the container's root filesystem. This means that you do not need to rebuild the image every time you make edits to unit tests.

Running your own image

By default, the docker_run.bash and docker_run.ps1 scripts use the official image from Docker Hub. To start a container with your newly-built image, run:

# Bash:
$ ./docker_run.bash -i my-inventory-hunter ...

# PowerShell:
PS C:\dev\inventory-hunter> .\docker_run.ps1 -Image my-inventory-hunter ...

These scripts map a data and log directory from your workspace to the container. The data directory contains HTMLs generated by each container's web scrapers. These files are useful for debugging existing web scrapers and developing new ones. The log directory stores one log file per container. Log files in this directory stick around after containers exit.

Clone this wiki locally