openlibrary Docker & Self-Hosted Deployment

GitHub

One webpage for every book ever published!

6,599 stars Python Python 1 file ยท ~11,631 tokens #books#hacktoberfest#internet-archive#library-catalogue#open-source
RAW Compose
1. Pull Image (DOCKERHUB) docker pull library/postgres
2. Docker Run (1-Click Launch) docker run -d --name openlibrary -p 8087:8087 --restart always postgres
3. Podman Run podman run -d --name openlibrary -p 8087:8087 --restart always postgres
4. Skopeo Inspect (Zero-Pull Manifest) skopeo inspect docker://docker.io/library/postgres:latest
5. ORAS Pull (OCI Artifact) oras pull postgres
6. Compose Deployment docker compose up -d
scripts/solr_builder/compose.yaml
Download .yml
services:
  db:
    profiles:
      - build
    image: postgres
    restart: unless-stopped
    environment:
      POSTGRES_PASSWORD: example
    working_dir: "/solr_builder"
    volumes:
      - "postgres-data:/var/lib/postgresql/data"
      - ".:/solr_builder"
      - "/storage:/storage"
    networks:
      - db-access

  adminer:
    profiles:
      - build
    image: adminer
    restart: unless-stopped
    ports:
      - 8087:8080
    networks:
      - db-access

  solr:
    profiles:
      - build
    image: solr:10.0.0
    restart: on-failure
    environment:
      # This is optimized for bulk loading, so a lot of the auto*Commits are disabled
      # Keep other SOLR_OPTS in sync with other instances of solr in compose files
      - SOLR_OPTS=
        -Dsolr.autoSoftCommit.maxTime=-1
        -Dsolr.autoCommit.maxTime=3600000
        -Dsolr.environment=test
      - SOLR_MODULES=analysis-extras
      - SOLR_JAVA_MEM=-Xms3g -Xmx3g
    ports:
      - 8983:8983
    volumes:
      - solr-data:/var/solr
      - ../../conf/solr:/opt/solr/server/solr/configsets/olconfig:ro
    networks:
      - solr-access
    command: solr-precreate openlibrary /opt/solr/server/solr/configsets/olconfig

  # Only run these two services if we're connecting this solr to production/testing
  # To run:
  # docker compose down
  # docker compose --profile production up -d
  solr_prod:
    profiles:
      - production
    restart: unless-stopped
    image: solr:10.0.0
    expose:
      - 8983
    ports:
      - 8983:8983
    environment:
      # Keep in sync with compose.production.yaml
      - SOLR_OPTS=
        -Dsolr.autoSoftCommit.maxTime=60000
        -Dsolr.autoCommit.maxTime=120000
        -Dsolr.max.booleanClauses=30000
        -Dsolr.environment=stage
        -Dol.replication.role.leader=true
      - SOLR_MODULES=analysis-extras
      # More memory for production
      - SOLR_JAVA_MEM=-Xms10g -Xmx10g
      # This might overwrite the above?
      - SOLR_HEAP=8g
    volumes:
      - solr-data:/var/solr
      - ../../conf/solr:/opt/solr/server/solr/configsets/olconfig:ro
    networks:
      solr-access:
        aliases:
          - solr  # Override other solr service's hostname
    logging:
      options:
        max-size: "512m"
        max-file: "4"
    # Create (or use if already existing) a core called "openlibrary" with our config & schema
    command: solr-precreate openlibrary /opt/solr/server/solr/configsets/olconfig

  # We need ability to use openlibrary code
  ol:
    profiles:
      - never
    image: olpython:latest
    build:
      context: ../..
      dockerfile: scripts/solr_builder/Dockerfile.olpython
      args:
        - PIP_INDEX_URL=${PIP_INDEX_URL:-}
        - HTTPS_PROXY=${HTTPS_PROXY:-}
        - NO_PROXY=${NO_PROXY:-}
    volumes:
      # Persistent volume mount for installed git submodules
      - ol-vendor:/openlibrary/vendor
      # The above volume mounts are required so that the local dev bind mount below
      # does not clobber the data generated inside the image / container
      - "../../:/openlibrary"
      - "/storage:/storage"
    networks:
      - solr-access
      - db-access

volumes:
  postgres-data:
  solr-data:
  ol-vendor:

networks:
  db-access:
  solr-access: