Search code examples
dockerploneplone-6

Manually start plone 6 instance inside docker container


Based on example here I added entrypoint: sh -c 'tail -f /dev/null':

version: "3"
services:

  backend:
    image: plone/plone-backend:6.0
    restart: always
    environment:
      ZEO_ADDRESS: zeo:8100
    ports:
    - "8080:8080"
    depends_on:
      - zeo
    entrypoint: sh -c 'tail -f /dev/null'

  zeo:
    image: plone/plone-zeo:latest
    restart: always
    volumes:
      - data:/data
    ports:
    - "8100:8100"

volumes:
  data: {}

I started the app using docker-compose up as usual, then I run docker-compose exec backend bash. Now I can't find a way to start the instance. I expect something like: bin/instace fg.

I tried this a lot with no success. Not working with build: ., not working with a new Dockerfile based on plone/plone-backend:6.0 + buildout.cfg, etc. I feel it should be simple, but just can't figure it out.

I found this: https://community.plone.org/t/interactive-shell-for-debugging-with-plone-6-docker-compose-the-wsgi-equivalent-of-bin-instance-debug/16370

but in my case I don't want a debug mode in this way. My goal is to edit with vim some files from eggs, to add some pdb then I want to start the instance in foreground mode, in order to investigate how some functionalities are working. I do this a lot in Plone 4. How can I do this in Plone 6?


Solution

  • A solution (but see the UPDATED one)

    version: "3"
    services:
    
      backend:
        image: plone/plone-backend:6.0
        restart: always
        environment:
          ZEO_ADDRESS: zeo:8100
          SECURITY_POLICY_IMPLEMENTATION: "C"
          VERBOSE_SECURITY: "off"
          DEFAULT_ZPUBLISHER_ENCODING: "utf-8"
          DEBUG_MODE: "off"
          ZODB_CACHE_SIZE: "50000"
        tty: true
        stdin_open: true
        command: cat
        ports:
        - "8080:8080"
        depends_on:
          - zeo
    
      zeo:
        image: plone/plone-zeo:latest
        restart: always
        volumes:
          - data:/data
        ports:
        - "8100:8100"
    
    volumes:
      data: {}
    

    Go into container with:

    $ docker-compose exec backend bash

    Then run:

    $ gosu plone /app/bin/runwsgi -v etc/zope.ini config_file=zope.conf

    This will start the instance in fg mode. (http://0.0.0.0:8080/)

    I found this here: https://github.com/plone/plone-backend/issues/64#issuecomment-1211912408

    UPDATE (better solution):

    You can copy this entire code into your docker-compose.yml and you will have the instructions as comments.

    # CREATE PROJECT
    # $ mkdir plone6
    # $ cd plone6
    # $ vim docker-compose.yml
    #   Copy example from
    #   https://6.docs.plone.org/install/containers/images/backend.html#example
    #     Update: - data:/data
    #       with: - ./data:/data
    #
    # START PLONE
    # Stop all docker containers:
    # $ docker stop $(docker ps -aq)
    # $ docker-compose build
    # $ sudo chown -R 500 data/
    # $ docker-compose up
    #
    # ENTER THE BACKEND CONTAINER 
    # $ docker-compose exec backend bash
    #
    # INSTALL VIM INTO CONTAINER
    # $ apt update
    # $ apt install vim
    #
    # FIND THE PACKAGES, EDIT (example plone.restapi)
    # $ ./bin/python
    # >>> import plone.restapi
    # >>> plone.restapi.__file__
    # '/app/lib/python3.11/site-packages/plone/restapi/__init__.py'
    # >>> exit()
    # $ vim /app/lib/python3.11/site-packages/plone/restapi/__init__.py
    # To add a breakpoint write: import pdb; pdb.set_trace()
    #
    # START INSTANCE IN FG MODE
    # In docker-compose.yml add for backend:
        # tty: true
        # stdin_open: true
        # command: cat
    # docker-compose up
    # docker-compose exec backend bash
    # ./docker-entrypoint.sh
    # set
    # ./docker-entrypoint.sh start
    version: "3"
    services:
    
      backend:
        image: plone/plone-backend:6.0
        restart: always
        environment:
          ZEO_ADDRESS: zeo:8100
        tty: true
        stdin_open: true
        command: cat
        ports:
        - "8080:8080"
        depends_on:
          - zeo
    
      zeo:
        image: plone/plone-zeo:latest
        restart: always
        volumes:
          - ./data:/data
        ports:
        - "8100:8100"
    
    volumes:
      data: {}