Skip to content

How to install Pageonex with Docker against and external database

numeroteca edited this page May 14, 2023 · 6 revisions

This tutorial is made to install a previous Pageonex instance reusing its database and images.

  1. Get the dump of the database database.dump. Have a quick look at it with less 210707_pageonex-prod-db-0707.dump
  2. Install mysql: sudo apt-get install mysql-server. Access mysql: sudo mysql
  3. Create user and database in mysql: CREATE USER and DATABASE.

As we need to access from remote, we can not use the typical 'localhost'and we need the '%' wildcard.

CREATE DATABASE pageonex;
CREATE USER 'pageonexRA'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON pageonex.* TO 'pageonexRA'@'%';


  1. Insert existing database in the created database: mysql -u pageonexRA -p pageonex < 210707_pageonex-prod-db-0707.dump
  2. Create directories for existing app directories: tmp, threads and kiosko. Create a local-pageonex directory where to store the files:
.
├── assets
│   └── images
│       ├── kiosko
│       └── threads
└── tmp

If you have the images of the newspapers from the previous installation move them to assets/images/kiosko.

If you have the images of the composites from the previous installation move them to assets/images/threads. What we've learnt while making this process is that if the images are not created they are created when visiting a thread. Big threads will take more time to load (also created are the data for downoloading).

  1. Create a env file to store all the databaes variables. Content of env:
RAILS_ENV=production
DATABASE_ADAPTER=mysql2
DATABASE_USERNAME=pageonexRA
DATABASE_PASSWORD=pageonexRA
DATABASE_HOST=172.18.0.1
DATABASE_NAME=pageonex

  1. create start-pageonex.sh with all the needed extra configuration.

It removes previous dockerimage named pageonex. Deploy new docker image from the pageonex/pageonex:latest image at ____ and names it pageonex.

#!/bin/bash
docker rm pageonex
docker run -d --name pageonex \
  -p 3000:3000 \
  --env-file env \
  -v /home/numeroteca/local-pageonex/tmp:/workspace/tmp \
  -v /home/numeroteca/local-pageonex/assets/images/kiosko:/workspace/app/assets/images/kiosko \
  -v /home/numeroteca/local-pageonex/assets/images/threads:/workspace/app/assets/images/threads \
  pageonex/pageonex:latest

Before doing this, you need to install Docker: apt install docker.io

  1. With this (https://stackoverflow.com/questions/44543842/how-to-connect-locally-hosted-mysql-database-with-the-docker-container) we saw how to give access to all the IP. We needed to change: "Also, check that your MySQL is listening to all of its interfaces. In your my.cnf search for bind-address that should be 0.0.0.0 (consider security issues if your server has public IP)". We finally changed it at /etc/mysql/mysql.conf.d/mysqld.cnf. It should be:
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address		= 127.0.0.1
#mysqlx-bind-address	= 127.0.0.1
bind-address		= 0.0.0.0
mysqlx-bind-address	= 0.0.0.0
  1. One last thing regarding the user. It gave an error (something like Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/mysql/lib/plugin/caching_sha2_password.so, 2): image not found) connecting so we had to use this (https://stackoverflow.com/questions/49194719/authentication-plugin-caching-sha2-password-cannot-be-loaded):

ALTER USER 'pageonexRA'@'%' IDENTIFIED WITH mysql_native_password BY 'youpassword';

  1. Now we are ready to run: ./start-pageonex.sh. Before we have to give it execute rights with: chmod +x start-pageonex.sh

  2. Check that docker is running in the browser: http://localhost:3000/ and with command docker ps and [complete].

If you are using another server you might access with that IP adress xxx.xxx.xxx.xxx:3000

Useful docker commands:

docker rm pageonex-debug # remove docker image

docker rm -f pageonex-debug # force and remove docker image if it is in use

docker logs pageonex # see logs of image

docker pull pageonex/pageonex #cuándo hay que correrlo

If you need to stop the container (because you need to restart the image): docker stop pageonex

If you need to update the docker container image: docker pull pageonex/pageonex

A new docker container image can be manually build or every time a version is tagged in this repository. See pageonex docker images at https://hub.docker.com/r/pageonex/pageonex/tags

/running-pageonex-in-your-environment.md

There is extra documentation at Runining pageonex in your environment