archivy-docker icon indicating copy to clipboard operation
archivy-docker copied to clipboard

ElasticSearch enabled in light image

Open almereyda opened this issue 2 years ago • 0 comments

Archivy watches for ElasticSearch, if no environmental variable is given to disable.

mkdir -p archivy_data archivy_config
wget https://github.com/archivy/archivy-docker/raw/main/config-lite.yml -O archivy_config/config.yml

Then, depending on Docker or Podman being used, we issue:

chown -R 1000:1000 archivy_*
podman unshare chown 1000:1000 -R archivy_*

When running the following docker-compose.yml (with fused configurations of light and custom-config), Archivy attempts to wait for ElasticSearch, because it is enabled:

version: '3'

services:

  archivy:
    image: uzayg/archivy:latest-lite
    ports:
      - "5000"
    environment:
      - ELASTICSEARCH_ENABLED=0
      - FLASK_DEBUG=0
    volumes:
      - ./archivy_data:/archivy/data:z
      - ./archivy_config:/archivy/.local/share/archivy:z
$ docker-compose up
Creating network "archivy_default" with the default driver
Creating archivy_archivy_1 ... done
Attaching to archivy_archivy_1
archivy_1  | Setting environment variables.
archivy_1  | The following environment variables were set:
archivy_1  |            FLASK_DEBUG=0
archivy_1  |            ELASTICSEARCH_ENABLED=1
archivy_1  |            ELASTICSEARCH_URL=http://elasticsearch:9200/
archivy_1  |            ARCHIVY_PORT=5000
archivy_1  | Checking if Elasticsearch is up and running
archivy_1  | Waiting for Elasticsearch @ http://elasticsearch:9200/ to start.
archivy_1  | Waiting for Elasticsearch @ http://elasticsearch:9200/ to start.
archivy_1  | Waiting for Elasticsearch @ http://elasticsearch:9200/ to start.
^CGracefully stopping... (press Ctrl+C again to force)
Stopping archivy_archivy_1 ... done

This is circumvented with inserting the environmental variable ELASTICSEARCH_ENABLED set to 0.

      - ELASTICSEARCH_ENABLED=0
$ docker-compose up
Creating network "archivy_default" with the default driver
Creating archivy_archivy_1 ... done
Attaching to archivy_archivy_1
archivy_1  | Setting environment variables.
archivy_1  | The following environment variables were set:
archivy_1  |            FLASK_DEBUG=0
archivy_1  |            ELASTICSEARCH_ENABLED=0
archivy_1  |            ELASTICSEARCH_URL=http://elasticsearch:9200/
archivy_1  |            ARCHIVY_PORT=5000
archivy_1  | Elasticsearch not used. Search function will not work.
archivy_1  | Starting Archivy
archivy_1  | Running archivy...
archivy_1  | [2022-09-24 18:39:42,440] INFO in __init__: OUTPUT_FOLDER: /tmp/click-web
archivy_1  |  * Serving Flask app 'archivy' (lazy loading)
archivy_1  |  * Environment: production
archivy_1  |    WARNING: This is a development server. Do not use it in a production deployment.
archivy_1  |    Use a production WSGI server instead.
archivy_1  |  * Debug mode: off
archivy_1  |  * Running on all addresses.
archivy_1  |    WARNING: This is a development server. Do not use it in a production deployment.
archivy_1  |  * Running on http://10.89.5.2:5000/ (Press CTRL+C to quit)
archivy_1  | 10.89.5.2 - - [24/Sep/2022 18:42:45] "GET / HTTP/1.1" 302 -
archivy_1  | 10.89.5.2 - - [24/Sep/2022 18:42:45] "GET /login?next=%2F HTTP/1.1" 200 -
archivy_1  | 10.89.5.2 - - [24/Sep/2022 18:42:45] "GET /static/main.css HTTP/1.1" 200 -
archivy_1  | 10.89.5.2 - - [24/Sep/2022 18:42:45] "GET /static/logo.png HTTP/1.1" 200 -
archivy_1  | 10.89.5.2 - - [24/Sep/2022 18:42:45] "GET /static/archivy.svg HTTP/1.1" 200 -

We can then create the admin user, and get the port of the application from the container API:

$ docker-compose exec archivy archivy create-admin username
$ docker-compose port archivy 5000

Note: This is using Podman > 4 together with systemctl enable --user podman.socket podman.service and export DOCKER_HOST=unix:///run/user/1000/podman/podman.sock and docker-compose 1.29.2, why we add the :z annotation to the volume mounts. More about why this is neccessary in:

  • https://unix.stackexchange.com/questions/651198/podman-volume-mounts-when-to-use-the-z-or-z-suffix
  • https://blog.christophersmart.com/2021/01/31/podman-volumes-and-selinux/

This adds an additional unshare step to the initialisation of the directories to be mounted, if they were not autogenerated.

  • https://www.tutorialworks.com/podman-rootless-volumes/

almereyda avatar Sep 24 '22 18:09 almereyda