Sign inSign up

ekoerner/heritrix

By ekoerner

•Updated almost 5 years ago

*deprecated* Heritrix - visit https://hub.docker.com/r/iipc/heritrix

Image
2

10K+

ekoerner/heritrix repository overview

⁠Heritrix Docker


(Deprecated) Please use the images at: https://hub.docker.com/r/iipc/heritrix⁠
This "unofficial" Dockerfile has been merged/included into the official gh:internetarchive/heritrix3 repo.


Current Heritrix build wrapped in Docker container.

Uses Heritrix build: 3.4.0-20210923⁠

1⁠: allows to run a single job via JOBNAME environment variable, see pull request #406; -r option⁠
+contrib: with additional heritrix-contrib Image
custom user: run heritrix with custom heritrix (1000) user to be a bit more secure

⁠Build image

# tag it (-t) as "heritrix"
# specify version (if not latest default, specified in image) with: --build-arg version=3.4.0-20210923
docker build --build-arg version=3.4.0-20210923 -t heritrix .

⁠Run image

NOTE, the current image requires the USERNAME and PASSWORD environment variables to be set. Later revisions will allow config files (that may be mapped via volume mounts). (Still in work.)

Basic run commands:

# run it in foreground
# -it required for clean stopping with Ctrl+C
# --rm for cleaning up afterwards of volumes etc.
docker run --rm -it heritrix

# run it in background
# --name is optional but easier to find for stopping
docker run -d --name heritrix_container heritrix
# logs
docker logs heritrix_container
# stop it
docker stop heritrix_container
⁠Configuring it for real usage
# --init : use tini init wrapper
# --rm : remove container after exit
# -it : runs docker interactively (pseudo TTY)
# -d : detach, run container in background
# -p : map public api port of 8443 (host) to 8443 (container port)
# -e : set environment variables for user/pass of REST API
#      JAVA_OPTS=-Xmx1024M (to restrict heritrix memory usage)
# -v : mount local folder into container (to persist job results)
#      on windows/WSL[2] volume mounts might not work (container files are not in local folder?)
#      heritrix is install at /opt/heritrix
#      heritrix jobs are at   /opt/heritrix/jobs
docker run --init --rm -d \
    --name heritrix_container \
    -p 8443:8443 \
    -e "USERNAME=admin" -e "PASSWORD=admin" \
    -v $(pwd)/jobs:/opt/heritrix/jobs \
    heritrix

# or mount a credentials file into the container (docker secrets?)
echo "admin:admin" > $(pwd)/creds
docker run --init --rm -d \
    --name heritrix_container \
    -p 8443:8443 \
    -e "CREDSFILE=/opt/heritrix/creds.txt" \
    -v $(pwd)/creds:/opt/heritrix/creds.txt \
    -v $(pwd)/jobs:/opt/heritrix/jobs \
    heritrix
⁠Run just a single job

Only since version 3.4.0-20210803⁠ (See pull request #406⁠)!

# docker options the same as above
# * specify with -e "JOBNAME=<jobname> the job that should be run
# * mount the job folder with the crawler-beans.cxml to the <jobname>
#   folder within the container
# * the crawl will start immediately
# 
docker run --init --rm -d \
    --name heritrix_container \
    -p 8443:8443 \
    -e "USERNAME=admin" -e "PASSWORD=admin" -e "JOBNAME=myjob" \
    -v $(pwd)/myjob:/opt/heritrix/jobs/myjob \
    heritrix
⁠Run heritrix scripts

Run the hoppath.pl⁠ script:

# the last two lines are the relative path to the job lob
# (in the container) as well as the URI_PREFIX
docker run -it --rm \
    -v "$(pwd)/myjob:/opt/heritrix/jobs/myjob" \
    --entrypoint bin/hoppath.pl \
    heritrix \
    jobs/myjob/latest/logs/crawl.log \
    https://

⁠Example files

.env

PORT=8443
USERNAME=admin
PASSWORD=admin
#JOBNAME=myjob

docker-compose.yml

version: "3.7"
services:

  heritrix:
    build: .
    container_name: "heritrix"
    # TEST: keeps the container running without doing anything (for inspections)
    # entrypoint: bash -c 'while :; do :; done & kill -STOP $$! && wait $$!'
    # env_file: .env
    environment:
      - USERNAME=admin
      - PASSWORD=admin
      # optional jobname to run (will only run this single job and exit!)
      # - JOBNAME=myjob
      # - JAVA_OPTS=-Xmx1024M
    init: true
    ports:
      # if you want to use a .env file with `PORT=8443` for example
      # - ${PORT}:8443
      - 8443:8443
    restart: unless-stopped
    volumes:
      # where jobs will be stored
      - job-files:/opt/heritrix/jobs
      # or if JOBNAME envvar is used (mount just the single job folder)
      # jobfolder in the container needs to have the same name as in JOBNAME
      # - $(pwd)/host_myjob:/opt/heritrix/jobs/myjob

volumes:
  job-files:

Tag summary

Content type

Image

Digest

Size

164.8 MB

Last updated

almost 5 years ago

docker pull ekoerner/heritrix