Hello,
i am trying to migrate my VM to an Docker container install. I am not able to locate the postgresql.conf file, where can it be found? I am sorry having to ask this question here...
thanks a lot
Thank you!
Sorry, my error, update removed it...
Hey,
If you succeed making it a docker, maybe you could post the steps here?
Thanks!
nc_change_docker.zip
Hey, i have done it
the files included are: docker-compose.yml and two patch files (postgres and nc config)
the patch files are for illustration purposes only!!! (passwords are from a fresh nc_vm v20 install)
YOU WILL HAVE TO CHANGE THESE PATCH FILES TO MATCH YOUR CONFIGURATION
//create folders
mkdir nc && cd nc
mkdir db
mkdir config
//if you are running postgresql < v13, upgrade the cluster to v13
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresql-13
sudo pg_dropcluster 13 main --stop
sudo pg_upgradecluster -m upgrade 12 main
//copy db files
cp -r /var/lib/postgresql/13/main db
cp /etc/postgresql/13/main/pg_hba.conf db
cp /etc/postgresql/13/main/pg_ident.conf db
cp /etc/postgresql/13/main/postgresql.conf db
//patch postgres config file
patch db/postgresql.conf postgres.patch
//add authorization to pg-hba.conf file
echo "host all all all md5" >> db/pg_hba.conf
//copy nc config
cp -R /var/www/nextcloud/config/* config
//copy configuration data in thes files:
//nextcloud_admin_password.txt # put admin password to this file
//nextcloud_admin_user.txt # put admin username to this file
//postgres_db.txt # put postgresql db name to this file
//postgres_password.txt # put postgresql password to this file
//postgres_user.txt # put postgresql username to this file
//patch nc config
patch config/config.php config.patch
//change config directory ownership if not already the case (tofind out the needed id: docker exec -it nc id www-data)
chown -R www-data:www-data
docker-compose up -d
what does the patch files do:
1. postgres.patch
uncomment
data_directory
hba_file
ident_file
external_pid_file
port
unix_socket_directories
ssl, ssl_cert_file
ssl_key_file
log_line_prefix
cluster_name
stats_temp_directory
include_dir
change:
listen_addresses = '*'
2. config.patch
change:
'datadirectory' => '/var/www/html/data'
'dbhost' => 'db'
uncomment
redis section
memcache configs
here is the docker-compose.yml
version: '3.2'
volumes:
nextcloud:
db:
services:
db:
image: postgres
container_name: db
restart: always
volumes:
- ./db:/var/lib/postgresql/data
environment:
- POSTGRES_DB_FILE=/run/secrets/postgres_db
- POSTGRES_USER_FILE=/run/secrets/postgres_user
- POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password
secrets:
- postgres_db
- postgres_password
- postgres_user
app:
image: nextcloud
container_name: nc
restart: always
ports:
- 8080:80
volumes:
- ./config:/var/www/html/config:rw
- /mnt/ncdata:/var/www/html/data
environment:
- POSTGRES_HOST=db
- POSTGRES_DB_FILE=/run/secrets/postgres_db
- POSTGRES_USER_FILE=/run/secrets/postgres_user
- POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password
- NEXTCLOUD_ADMIN_PASSWORD_FILE=/run/secrets/nextcloud_admin_password
- NEXTCLOUD_ADMIN_USER_FILE=/run/secrets/nextcloud_admin_user
depends_on:
- db
secrets:
- nextcloud_admin_password
- nextcloud_admin_user
- postgres_db
- postgres_password
- postgres_user
secrets:
nextcloud_admin_password:
file: ./nextcloud_admin_password.txt # put admin password to this file
nextcloud_admin_user:
file: ./nextcloud_admin_user.txt # put admin username to this file
postgres_db:
file: ./postgres_db.txt # put postgresql db name to this file
postgres_password:
file: ./postgres_password.txt # put postgresql password to this file
postgres_user:
file: ./postgres_user.txt # put postgresql username to this file
Great, thanks!
You know, you could make variables out of the password and config stuff to automated this. If you succeed I'll make this configuration file public in this repo, and you can take credit for it. :1st_place_medal:
FYI @szaimen
So... What is the idea here? Migrate the VM to Docker?
Migrate the VM to Docker?
No, but maybe make it possible to run as Docker as well. We have Vagrant already.
Or, simply just use the dockerfile provided to help migrate to Docker for those who want that.
Here is a docker-compose file I started a while ago with but didn't finish (also it uses traefik which is not recommended, afaik)
Maybe some components could be reused?
The aim is/was to migrate an existing nextcloud-vm installation (with file encryption enabled) to a Nextcloud docker.
I will create a script for automation today or tomorrow, will keep you updated
Great, thanks!
You know, you could make variables out of the password and config stuff to automated this. If you succeed I'll make this configuration file public in this repo, and you can take credit for it. 馃
FYI @szaimen
Here you go:
https://github.com/JackGlobetrotter/Migrate-Nextcloud-VM
and here's your PR: https://github.com/nextcloud/vm/pull/1629
I'll add you as maintainer @JackGlobetrotter if you're up for the task?
Hey thank you, that's fine with me
Please review the PR.
Thanks!
Most helpful comment
The aim is/was to migrate an existing nextcloud-vm installation (with file encryption enabled) to a Nextcloud docker.
I will create a script for automation today or tomorrow, will keep you updated