Migrate from a legacy setup (Mongo 2.x)

Until early 2021 the following Docker-Compose configuration was in place:

version: '3'

services:
  dataonly:
    image: themis-registry.promyze.com/themis-data
    container_name: dataonly-container
    volumes:
     - ./themis:/shared
     - ./data:/data/db
     - ./log:/data/log
  mongodb:
    image: themis-registry.promyze.com/themis-mongodb:2.6.12
    container_name: mongodb-container
    volumes_from:
     - dataonly
    ports:
     - 27017
  themis:
    image: promyze/promyze:4.12.0
    container_name: themis-container
    environment:
      - THEMIS_URL=http://localhost:3001 #REPLACE WITH THE FULL URL OF THEMIS
    depends_on:
      - mongodb
    ports:
      - 3000:3000 # Replace the left part by the port of your choice
      - 3001:3001 # Replace the left part by the port of your choice
    volumes_from:
      - dataonly

As we now recommand to use Mongo 4.X as a database, and since the Docker-Compose file has evolved, here a quick step-by-step migration guide:

Packmind previous name was Promyze, which was also previously know as Themis 😉

1) Backup current data

First of all, we'll create a dump of the current database and export it outside the container:

$> docker exec -ti mongodb-container bash
$> ./home/themis/export_db.sh
$> exit 

On your host machine, you'll see

$> cd <HOME_PACKMIND_DIRECTORY>
$> ls themis/
themis.2024-03-07.00-00-01.tar.gz  
themis.2024-03-07.08-55-00.tar.gz

So our backup are now available on the host machine.

Now we're going to apply the following modification to the docker-compose.yml file to add the new container Mongo 4.4:

version: '3'

services:
  dataonly:
    image: themis-registry.promyze.com/themis-data
    container_name: dataonly-container
    volumes:
     - ./themis:/shared
     - ./data:/data/db
     - ./log:/data/log
  ################ Here we insert the Mongo 4 container    
  mongodb-4:
    image: mongo:4.4
    container_name: mongodb4-container
    volumes:
      - ./mongodb4:/data/db
    ports:
     - 27017
  mongodb:
    image: themis-registry.promyze.com/themis-mongodb:2.6.12
    container_name: mongodb-container
    volumes_from:
     - dataonly
    ports:
     - 27017
  themis:
    image: promyze/promyze:4.12.0
    container_name: themis-container
    environment:
      - THEMIS_URL=http://localhost:3001 #REPLACE WITH THE FULL URL OF THEMIS
    depends_on:
      - mongodb
    ports:
      - 3000:3000 # Replace the left part by the port of your choice
      - 3001:3001 # Replace the left part by the port of your choice
    volumes_from:
      - dataonly

Deploy this:

$> docker-compose up -d
$> docker cp themis/<YOUR_LATEST_BACKUP> mongodb4-container:/tmp/.
$> docker exec -ti mongodb4-container bash
$> tar -zxvf /tmp/<YOUR_BACKUP>
$> mongorestore --db promyze shared/themis/themis
$> docker-compose stop
$> docker-compose rm -f themis-container 

Now, let's update the whole Docker-Compose.yml to remove the old Mongo 2 and now use the new containers system:

version: '3'

services:

  promyze-proxy:
    image: promyze/promyze-proxy:latest
    depends_on:
      - promyze-api
      - promyze-suggestions
    ports:
      - 3001:3001

  promyze-api:
    depends_on:
      - mongodb-4
    image: promyze/promyze-api:latest
    environment:
      # Set other variables here
      - PROMYZE_URL=http://localhost:3001
      - MONGO_URI=mongodb://mongodb4-container:27017/promyze

  promyze-suggestions:
    image: promyze/promyze-suggestions:latest
    depends_on:
      - mongodb-4
      - promyze-api
    environment:
      - MONGO_URI=mongodb://mongodb4-container:27017/promyze

  mongodb-4:
  
    image: mongo:4.4
    container_name: mongodb4-container
    volumes:
      - ./mongodb4:/data/db
    ports:
     - 27017

And now can redeploy everything:

$> docker-compose up -d --remove-orphans

And you're done 🎉

Last updated