From build to pre-build docker image


#1

Hi,

Until now, I used to build the docker image according to the documentation for each new version of Mastodon.

Now, I notice in the documentation that a prebuild image is available (documentation/Docker-Guide.md at master · tootsuite/documentation · GitHub).

Is it possible to migrate from built to pre-built image easily? Should I simply edit the file docker-compose.yml, run docker-compose build and then docker-compose up -d ?

Anything I should know before starting the upgrade/migration?

Thanks,
JF


#2

Most important is to keep your data intact. Make sure the same copy of PostgreSQL database is available, this is crucial. I would also make sure the Mastodon configuration is the same.


#3

I would run the prebuilt image in the same folder than the current ‘self-built’ image, so, I assume it’ll use the same db (thanks to docker volumes) and configuration file. Is it correct?

Here is my current docker-compose file:

version: '3'
services:

  db:
    restart: always
    image: postgres:9.6-alpine
    networks:
      - internal_network
    volumes:
      - ./postgres:/var/lib/postgresql/data

  redis:
    restart: always
    image: redis:4.0-alpine
    networks:
      - internal_network
    volumes:
      - ./redis:/data
  web:
    build: .
    image: tootsuite/mastodon
    restart: always
    env_file: .env.production
    command: bundle exec rails s -p 3000 -b '0.0.0.0'
    networks:
      - external_network
      - internal_network
    ports:
      - "127.0.0.1:3000:3000"
    depends_on:
      - db
      - redis
    volumes:
      - ./public/assets:/mastodon/public/assets
      - ./public/packs:/mastodon/public/packs
      - ./public/system:/mastodon/public/system

  streaming:
    build: .
    image: tootsuite/mastodon
    restart: always
    env_file: .env.production
    command: yarn start
    networks:
      - external_network
      - internal_network
    ports:
      - "127.0.0.1:4000:4000"
    depends_on:
      - db
      - redis

  sidekiq:
    build: .
    image: tootsuite/mastodon
    restart: always
    env_file: .env.production
    command: bundle exec sidekiq -q default -q mailers -q pull -q push
    depends_on:
      - db
      - redis
    networks:
      - external_network
      - internal_network
    volumes:
      - ./public/packs:/mastodon/public/packs
      - ./public/system:/mastodon/public/system

networks:
  external_network:
  internal_network:
    internal: true

According to the documentation, I should remove all build: . lines, and replace image: tootsuite/mastodonwith image: tootsuite/mastodon:lastest.
I don’t think I should modify the file .env.production as it already contains the settings and key for my currently running instance.

The documentation assumes that we use the prebuilt image for a new instance, but I’m not sure I can switch from a self -built image to a prebuilt.


#4

Hello,

I did not have the time to go further with this upgrade since my message.
But… does anybody have any information about this?


#5

Hello !

Ok, I tried it and it worked perfectly!
I did a full backup of the instance before the upgrade, of course.
Then, i followed the instructions here : documentation/Docker-Guide.md at master · tootsuite/documentation · GitHub :

  • Comment all build: . lines
  • Add the version for the images : image: tootsuite/mastodon -> image: tootsuite/mastodon:v2.4.5
  • Follow the standard upgrade instruction (migrate db and precompile assets)
  • Restart the instance ( docker-compose up -d)

And that’s it!