Yasser Mohamed
Yasser Mohamed

Reputation: 7

docker compose file and certbot container keeps restart

iam running odoo by docker compose and get

bfd9cccbf689 certbot/certbot "/bin/sh -c trap exi…" 16 minutes ago Restarting (0) 39 seconds ago root-certbot-renew-1

version: "3.8"
services:
  odoo:
    build:
      context: .
      dockerfile_inline: |
        FROM odoo:18
        USER root

        USER odoo
    depends_on:
      - db
    environment:
      - PYTHONUNBUFFERED=1
      - ODOO_SERVER=odoo-bin
      - WDB_NO_BROWSER_AUTO_OPEN=True
      - WDB_SOCKET_SERVER=wdb
      - WDB_WEB_PORT=1984
      - WDB_WEB_SERVER=localhost
      - DISPLAY=:0
      - QT_QPA_PLATFORM=offscreen
    ports:
      - "8018:8069"  # Odoo web interface
      - "8072:8072"  # Add this line to expose the longpolling port
    volumes:
      - ./odoo.conf:/etc/odoo/odoo.conf      # Mount your custom Odoo config
 #     - /18+e/odoo/addons:/mnt/enterprise-addons # Enterprise addons
      - ./sanad_custom:/mnt/custom-addons

  db:
    image: postgres:14
    ports:
      - "5432:5432"
    volumes:
      - ./data:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: postgres
      POSTGRES_USER: odoo
      POSTGRES_PASSWORD: odoo

  nginx:
    image: nginx:latest
    depends_on:
      - odoo
    ports:
      - "80:80"  # Expose Nginx on port 80
      - "443:443" # https port
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro  # Mount custom Nginx config
      - ./nginx_logs:/var/log/nginx
      - ./certbot-webroot:/var/www/certbot
      - ./ssl:/etc/letsencrypt   #ssl vertificates volume
    restart: always

  certbot:
    image: certbot/certbot
    volumes:
      - ./ssl:/etc/letsencrypt
      - ./certbot-webroot:/var/www/certbot
    command: certonly --non-interactive --force-renewal  --webroot --webroot-path=/var/www/certbot --email [email protected] --agree-tos --no-eff-email -d sanad-co.io
    depends_on:
      - nginx

  certbot-renew:
    image: certbot/certbot
    volumes:
      - ./ssl:/etc/letsencrypt
      - ./certbot-webroot:/var/www/certbot
    entrypoint: ["/bin/sh", "-c"]
    command: |
      trap exit TERM; while :; do
        certbot renew
        sleep 12h
        wait $${!}
      done
    restart: unless-stopped

the problem the certbot-renew keeps restart and when i change

command:

to

 command: |
     while true;do
       echo "Running certbot renewal check..."
       certbot renew --quiet --non-interactive || echo "Renewal not needed or failed"
       echo "Sleeping for 12 hours before next renewal check..."
     sleep 12h
     done
   restart: unless-stopped

i get this error rtbot-renew-1 | true: line 0: syntax error: unexpected end of file (expecting "do") and

Upvotes: 0

Views: 12

Answers (0)

Related Questions