RocketChat / Docker.Official.Image

Docker hub - community managed image
291 stars 217 forks source link

How to update/migrate from old docker-compose.yml to compose.yml? #177

Open Rintan opened 1 year ago

Rintan commented 1 year ago

New compose file introduced in #160 . It seems to be essential to upgrade 4.8 or newer. Are there any upgrade guide?

gradualChange commented 1 year ago

Any updates on this?

Did you ever find this out @Rintan ?

Rintan commented 1 year ago

@gradualChange

I've tried to use a bitnami mongo image, but it seems to be difficult due to different database structure. So, I've migrated the database and modified compose.yaml to be compatible with the older db structure.

#volumes:
#  mongodb_data: { driver: local }

services:
  rocketchat:
    image: rocketchat/rocket.chat:${RELEASE:-latest}
    restart: unless-stopped
    labels:
      traefik.enable: "false"
      #traefik.http.routers.rocketchat.rule: Host(`${DOMAIN:-}`)
      #traefik.http.routers.rocketchat.tls: "true"
      #traefik.http.routers.rocketchat.entrypoints: https
      #traefik.http.routers.rocketchat.tls.certresolver: le
    environment:
      MONGO_URL: "${MONGO_URL:-\
        mongodb://${MONGODB_ADVERTISED_HOSTNAME:-mongodb}:${MONGODB_INITIAL_PRIMARY_PORT_NUMBER:-27017}/\
        ${MONGODB_DATABASE:-rocketchat}?replicaSet=${MONGODB_REPLICA_SET_NAME:-rs0}}&directConnection=true"
      MONGO_OPLOG_URL: "${MONGO_OPLOG_URL:\
        -mongodb://${MONGODB_ADVERTISED_HOSTNAME:-mongodb}:${MONGODB_INITIAL_PRIMARY_PORT_NUMBER:-27017}/\
        local?replicaSet=${MONGODB_REPLICA_SET_NAME:-rs0}}&directConnection=true"
      ROOT_URL: ${ROOT_URL:-http://localhost:${HOST_PORT:-3000}}
      PORT: ${PORT:-3000}
      DEPLOY_METHOD: docker
      DEPLOY_PLATFORM: ${DEPLOY_PLATFORM:-}
      REG_TOKEN: ${REG_TOKEN:-}
    depends_on:
      - mongodb
    expose:
      - ${PORT:-3000}
    ports:
      - "${BIND_IP:-0.0.0.0}:${HOST_PORT:-3000}:${PORT:-3000}"

  mongodb:
    image: mongo:${MONGODB_VERSION:-5.0}
    restart: unless-stopped
    volumes:
      - ./data/db:/data/db
    command: mongod --oplogSize 128 --replSet rs0 --storageEngine=wiredTiger
    environment:
      MONGODB_REPLICA_SET_MODE: primary
      MONGODB_REPLICA_SET_NAME: ${MONGODB_REPLICA_SET_NAME:-rs0}
      MONGODB_PORT_NUMBER: ${MONGODB_PORT_NUMBER:-27017}
      MONGODB_INITIAL_PRIMARY_HOST: ${MONGODB_INITIAL_PRIMARY_HOST:-mongodb}
      MONGODB_INITIAL_PRIMARY_PORT_NUMBER: ${MONGODB_INITIAL_PRIMARY_PORT_NUMBER:-27017}
      MONGODB_ADVERTISED_HOSTNAME: ${MONGODB_ADVERTISED_HOSTNAME:-mongodb}
      MONGODB_ENABLE_JOURNAL: ${MONGODB_ENABLE_JOURNAL:-true}
      ALLOW_EMPTY_PASSWORD: ${ALLOW_EMPTY_PASSWORD:-yes}

  mongo-init-replica:
    image: mongo:${MONGODB_VERSION:-5.0}
    command: >
      bash -c
        "for (( ; ; )); do
          mongo mongodb/rocketchat --eval \"
            rs.initiate({
              _id: 'rs0',
              members: [ { _id: 0, host: 'localhost:27017' } ]})\" &&
          s=$$? && break || s=$$?;
          echo \"Could not reach MongoDB. Waiting 5 secs ...\";
          sleep 5;
        done; (exit $$s)"
    depends_on:
      - mongodb
gradualChange commented 1 year ago

Thanks @Rintan . I ended up figuring this out myself; the database was already using WiredTiger and Compose V2 worked with the compose file I had already; no changes needed. I'm still using the older MongoDB image instead of the Bitnami one too. Hopefully this is able to help someone else out, though.