senaite / senaite.docker

SENAITE Docker Container
GNU General Public License v2.0
48 stars 38 forks source link

Bug: Setting the password fails #12

Closed winniehell closed 1 year ago

winniehell commented 2 years ago

When setting the PASSWORD environment variable on a new container I get the following error:

senaite_1  | Traceback (most recent call last):
senaite_1  |   File "bin/zope-passwd", line 309, in <module>
senaite_1  |     sys.exit(senaite.core.scripts.zope_passwd())
senaite_1  |   File "/home/senaite/senaitelims/src/senaite.core/src/senaite/core/scripts/__init__.py", line 79, in zope_passwd
senaite_1  |     return run_it("_zope_passwd")
senaite_1  |   File "/home/senaite/senaitelims/src/senaite.core/src/senaite/core/scripts/__init__.py", line 73, in run_it
senaite_1  |     module.run(app)
senaite_1  |   File "/home/senaite/senaitelims/src/senaite.core/src/senaite/core/scripts/_zope_passwd.py", line 24, in run
senaite_1  |     users = app.acl_users.users
senaite_1  | AttributeError: 'RequestContainer' object has no attribute 'users'

tested on latest 2.x image (8c142a35419a)

ramonski commented 2 years ago

Hi @winniehell,

it works for me with the following command:

$ docker pull senaite/senaite:2.x
$ docker run -p 8081:8080 -e PASSWORD="12345" -e SITE="senaite" senaite/senaite:2.x

Open the browser on http://localhost:8081/senaite

ramonski commented 2 years ago

Also check out this docker-compose file: https://github.com/senaite/senaite.docker/issues/9#issuecomment-1112236898

Or if you prefer the full-fledged cluster setup version including your own add-on:

version: "3.9"

services:

  nginx:
    container_name: nginx
    restart: "unless-stopped"
    image: nginx:latest
    ports:
      - 8000:443
    volumes:
        - ./nginx.conf:/etc/nginx/nginx.conf
        - ./ssl-cert-snakeoil.pem:/etc/nginx/ssl/nginx.cert
        - ./ssl-cert-snakeoil.key:/etc/nginx/ssl/nginx.key
    links:
      - haproxy

  haproxy:
    container_name: haproxy
    restart: unless-stopped
    image: haproxy:lts
    ports:
      - 8888:80
      - 8889:8404
    volumes:
      - ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg
    links:
      - client1
      - client2

  zeo:
    container_name: zeo
    image: senaite/senaite:2.x
    restart: "unless-stopped"
    command: zeo
    volumes:
      - ./data:/data

  client1:
    container_name: client1
    image: senaite/senaite:2.x
    restart: "unless-stopped"
    ports:
      - "8081:8080"
    links:
      - zeo
    deploy:
      resources:
        limits:
          memory: 4GB
    environment:
      ZEO_ADDRESS: "zeo:8080"
      ADDONS: "myaddon.lims senaite.databox senaite.storage"
      SOURCES: "myaddon.lims=fs myaddon.lims,senaite.storage=git https://github.com/senaite/senaite.storage.git branch=2.x,senaite.databox=git https://github.com/senaite/senaite.databox.git branch=master"
    volumes:
      # we need to be selective here, because build files with symlinks, e.g. parts/omelette, cause problems.
      - ../setup.py:/home/senaite/senaitelims/src/myaddon.lims/setup.py
      - ../README.md:/home/senaite/senaitelims/src/myaddon.lims/README.md
      - ../src/myaddon:/home/senaite/senaitelims/src/myaddon.lims/src/myaddon

  client2:
    container_name: client2
    image: senaite/senaite:2.x
    restart: "unless-stopped"
    ports:
      - "8082:8080"
    links:
      - zeo
    deploy:
      resources:
        limits:
          memory: 4GB
    environment:
      ZEO_ADDRESS: "zeo:8080"
      ADDONS: "myaddon.lims senaite.databox senaite.storage"
      SOURCES: "myaddon.lims=fs myaddon.lims,senaite.storage=git https://github.com/senaite/senaite.storage.git branch=2.x,senaite.databox=git https://github.com/senaite/senaite.databox.git branch=master"
    volumes:
      # we need to be selective here, because build files with symlinks, e.g. parts/omelette, cause problems.
      - ../setup.py:/home/senaite/senaitelims/src/myaddon.lims/setup.py
      - ../README.md:/home/senaite/senaitelims/src/myaddon.lims/README.md
      - ../src/myaddon:/home/senaite/senaitelims/src/myaddon.lims/src/myaddon

volumes:
  data:
    external: true
winniehell commented 2 years ago
$ docker run -p 8081:8080 -e PASSWORD="12345" -e SITE="senaite" senaite/senaite:2.x

@ramonski thank you, I can confirm this command works :+1: however it still crashes when leaving out -e SITE="senaite":

$ docker run -p 8081:8080 -e PASSWORD="12345" senaite/senaite:2.x
ramonski commented 2 years ago

Ah, this makes sense, because no Plone site is installed then. Maybe this option should imply then the site creation (even if not specified)

winniehell commented 2 years ago

@ramonski I think I have a rough idea now how to solve it and I'm going to update https://github.com/senaite/senaite.docker/pull/13 (not today though :sleeping:)

thank you, for your help! :pray: