Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Rintan opened this issue Nov 24, 2022 · 3 comments
Open

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

Rintan opened this issue Nov 24, 2022 · 3 comments

Comments

@Rintan
Copy link

Rintan commented Nov 24, 2022

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

@gradualChange
Copy link

Any updates on this?

Did you ever find this out @Rintan ?

@Rintan
Copy link
Author

Rintan commented Jul 31, 2023

@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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants