Migration to Docker & Rcstack#

Migrate old pre 4.28.0 installer based releases#

1. Decide on components use#

By default, RhodeCode stack uses Redis and Postgres. We recommend using those in Docker as things like backup/restore are much easier, and possible to run by our installer

If you plan to use your own redis or DB, disable those services in .custom/docker-compose-services.override.yaml by setting replicas: 0

see: Configuration of components

Select your DB type by commenting postgres or mysql db in .custom/docker-compose-services.override.yaml For Sqlite, disable both DB types.

Note

Selecting your own Redis, DB etc would require pointing to those instance inside .ini config files. By default rcstack is configured to talk to docker based addresses of those services.

2. bootstrap the environment for rcstack#

./rcstack init

During the install/configure phase pick corresponding edition (ce/ee) transfer your license-token, and domain used in previous setup.

Then ensure 4.28.0 version is set for proper migration

./rcstack cli set-runtime-image 4.28.0

3. Copy over your old configuration into new shared config dir#

The init command will generate a docker optimized configurations, those by default have all services configured to be run against docker stack. Few options should be copied from old .ini config files for best backward compatibility and smooth migration.

The new .ini files are located in the config/_shared/ directory. This is located in directory where rcstack is installed.

Assumes installation is inside a directory /home/rcdev/.rccontrol/enterprise-1

cp /home/rcdev/.rccontrol/enterprise-1/rhodecode.ini /root/docker-rhodecode/config/_shared/rhodecode_old.ini
cp /home/rcdev/.rccontrol/vcsserver-1/vcsserver.ini /root/docker-rhodecode/config/_shared/vcsserver_old.ini

Then compare the new files e.g rhodecode.ini with rhodecode_old.ini and adjust accordingly, most important items for review are:

  • location of storages paths (those should be left Dockerized)

  • redis/db connection urls (depends on choice of services, either Docker urls, or external urls)

  • app_instance_uuid = COPY_OLD_VALUE

  • rhodecode.encrypted_values.secret = COPY_OLD_VALUE

  • beaker.session.secret = COPY_OLD_VALUE

  • email configuration

For example, if you leave on your own redis instance then no adjustment is needed, if you decide to use docker based redis, here’s an example change you need to make:

#rc_cache.cache_perms.arguments.host = localhost # this was commented out
# new options is change to connect to docker redis instance, hostname is just the name of compose service (redis)
rc_cache.cache_perms.arguments.host = redis
rc_cache.cache_perms.arguments.port = 6379
rc_cache.cache_perms.arguments.db = 0
rc_cache.cache_perms.arguments.socket_timeout = 30

4. launch services stack#

Launch the service stack with Database and all required services

./rcstack stack services up -d

Check the status of service stack by checking the status command

./rcstack status

Running hostname: https://code.rhodecode.com
CONTAINER ID   NAMES                                 IMAGE                               STATUS                                 PORTS
5746f723d892   rc_cluster_services-channelstream-1   channelstream/channelstream:0.7.1   Up About a minute (healthy)            8000/tcp
bef9599eef0c   rc_cluster_services-database-1        postgres:14.9                       Up About a minute (healthy)            5432/tcp
addf574b6f1c   rc_cluster_services-elasticsearch-1   elasticsearch:6.8.23                Up About a minute (healthy)            9200/tcp, 9300/tcp
9f89816cc6dc   rc_cluster_services-nginx-errors-1    nginx:1.25.2                        Up About a minute                      80/tcp
1c8e90e8ab7d   rc_cluster_services-nginx-statics-1   nginx:1.25.2                        Up About a minute (health)             80/tcp
fcb8378cd506   rc_cluster_services-redis-1           redis:7.0.12                        Up About a minute (healthy)            6379/tcp

5. make a db dump#

Note

Run this only if docker-based DB is selected. Skip otherwise

create a backup of your existing database, so it can be migrated to docker instance. Place the backup file into .custom/db_dump

# For MySQL DBs
$ mysqldump -u <uname> -p <pass> rhodecode_db_name > .custom/db_dump/mysql-db-backup.sql

# For PostgreSQL DBs
$ PGPASSWORD=<pass> pg_dump --inserts -U <uname> -h localhost rhodecode_db_name > .custom/db_dump/postgresql-db-backup.sql

# For SQLite
$ sqlite3 rhodecode.db ‘.dump’ > .custom/db_dump/sqlite-db-backup.sql

6. restore db#

Note

Run this only if docker-based DB is selected. Skip otherwise

Cleanup previous db created by init script, and re-create it. Restore the database into docker container running DB. Run the ./rcstack cli db command:

./rcstack cli db

attaching pg_data                           under: /var/lib/postgresql/data
attaching $PWD/.custom/db_dump              under: /var/rc-data-dump

restore dump:
\i /var/rc-data-dump/your_dump.sql

psql (14.9 (Debian 14.9-1.pgdg120+1))
Type "help" for help.

rhodecode=# \connect template1
template1=# drop database rhodecode;
template1=# create database rhodecode;
template1=# \connect rhodecode
rhodecode=# \i /var/rc-data-dump/postgresql-db-backup.sql

This will restore the previously stored DB dump into new dockerized DB.

7. move data into docker storage#

Step one is to move the required components to the .custom/storage directory inside the docker compose stack. This directory is mounted later on so data can be copied over into docker storage engine volumes.

Note

The tarball cache can be omitted since RhodeCode uses a new system which is not compatible with older release

Note

The path for artifacts can be found inside the old .ini file and DB

#artifacts, %(here)s is current location of old .ini file
file_store.storage_path = %(here)s/data/file_store

7.1. Copy artifacts into docker shared dir

mv -v .rccontrol/enterprise-1/data/file_store .custom/storage/

7.2. Copy gists into docker shared dir

mv -v /home/rhodecode/repos/.gist .custom/storage/repos/.gist

7.3. Copy repositories into docker shared dir

mv -v /home/rhodecode/repos .custom/storage/

Once that is done, we can now move from the host directory into docker storage engine volumes.

./rcstack cli storage

attaching rc_datavolume         under: /vol/datavolume
attaching rc_reposvolume        under: /vol/repovolume
attaching $PWD/.custom/storage  under: /vol/backupvolume

root@a27697d13f44:/vol#

7.4. Move artifacts

root@a27697d13f44:/vol# mv /vol/backupvolume/repos/* /vol/repovolume/

7.5. Move gists

root@a27697d13f44:/vol# mv /vol/backupvolume/repos/* /vol/repovolume/

7.6. Move repositories

root@a27697d13f44:/vol# mv /vol/backupvolume/repos/* /vol/repovolume/

7.7 Make sure proper permissions are set on the storage files, group/user is 999

root@a27697d13f44:/vol# chown -R 999:999 /vol/repovolume

8. Ensure other old services are stopped#

At this point we’re going to run the whole stack, because the router binds to some of the common ports, we need to make sure old db/nginx are stopped before we proceed.

It’s also important to stop running RhodeCode services.

This is where a first downtime of previously ran setup would occur.

9. Start complete stack#

./rcstack stack all up -d

10. Fix DB paths#

Docker internally changed the paths used before, he’re a way to change it using ishell. But this can be also adjusted in the UI

./rcstack cli ishell
ui1 = RhodeCodeUi.query().filter(RhodeCodeUi.ui_key=='usercache').scalar()
ui2 = RhodeCodeUi.query().filter(RhodeCodeUi.ui_key=='store_location').scalar()
ui3 = RhodeCodeUi.query().filter(RhodeCodeUi.ui_key=='/').scalar()

ui1.ui_value = '/var/opt/rhodecode_repo_store/.cache/largefiles'
ui2.ui_value = '/var/opt/rhodecode_repo_store/.cache/lfs_store'
ui3.ui_value = '/var/opt/rhodecode_repo_store'

Session().add(ui1);Session().commit()
Session().add(ui2);Session().commit()
Session().add(ui3);Session().commit()

11. Adjust SVN Proxy#

Note

This is only required for pre 5.1 migration, if you’re migrating from 4.X to 5.1+ this step can be omitted.

Go to the VCS config from the Admin ‣ Settings ‣ VCS

  • Select Proxy subversion HTTP requests checkbox

  • Enter http://svn:8090 into Subversion HTTP Server URL

  • Click the Generate Apache Config button.

12. Run full remap & rescan#

From RhodeCode web-interface, the last step is to run a full remap & rescan action.

  1. From the RhodeCode Web interface, open Admin ‣ Settings ‣ Remap and rescan

  2. Select Invalidate cache for all repositories to ensure we cleanup old caches from previous installs

  3. Click Rescan Repositories action

SSL Certificates#