ReinerNippes / nextcloud_on_docker

Run Nextcloud in Docker Container on various Linux Hosts
MIT License
203 stars 48 forks source link

Unclear in readme - does this install docker too - or is pre-installation of docker assumed #24

Closed james-cook closed 4 years ago

james-cook commented 4 years ago

Newbie here so excuse the question if it's obvious. If docker is installed (via ansible playbook etc.) this could be mentioned in the Readme. If docker is not installed but is a prerequisite this could be mentioned in the Readme - and a pointer to installation given (would be useful)

Where to execute e.g.:

Install Ansible and some needed tools by running the following command with a user that can sudo or is root.

curl -s https://raw.githubusercontent.com/ReinerNippes/nextcloud_on_docker/master/prepare_system.sh | /bin/bash

in the docker instance(?) or on the "containing" physical machine...

Context: I came here from https://help.nextcloud.com/t/how-to-migrate-from-existing-ubuntu-16-04-installation-to-docker/46664 My situation is "similar" I am trying to move a "traditional" non-container installation from ubuntu 16.04 to be "contained" (in this case on the same physical machine). Other existing software/services on the ubuntu machine should continue to function - e.g. there is an old Drupal installation on the machine etc. I am a docker newbie. I will not be using S3 or any other external storage.

ReinerNippes commented 4 years ago

Hi James,

the aim of this playbook is a fully automated install of nextcloud on docker with no prerequisite. Everything will installed.

prepare_system.sh will install ansible itself.

The playbook executes the following steps: https://github.com/ReinerNippes/nextcloud_on_docker/blob/f7a88d8099ade0e6f4699f6a2eb9e41d875ba309/nextdocker.yml#L7

It's not too complicate to understand the single steps. You have to look into each ../roles//tasks/main.yml. Sometimes there are tasks included depending on the OS family. These are the CentOS.yml, Ubuntu.yml, ... files. In ../roles/docker_container/tasks you'll find a file for each container. The format is similar to docker_compose.

On a system with an existing installation you have be careful. The playbook itself has root power. If any change will conflict with your drupal installation you have to know how to fix it. Most likely you want to change to ports of the traefik container. I assume 80/443 are already in use.

https://github.com/ReinerNippes/nextcloud_on_docker/blob/f7a88d8099ade0e6f4699f6a2eb9e41d875ba309/roles/docker_container/tasks/traefik.yml#L35

Maybe in your situation it's better to do a manual installation via docker-compose.

If you have the chance to setup a new server with Ubuntu 18.04 you want to look at https://github.com/ReinerNippes/selfhosted_on_docker because you install also a drupal container and migrate the new machine. In this case you would always have a fall back.

james-cook commented 4 years ago

Thanks very much for your reply. There's a great deal of information there! My "main" aim with this is to isolate php versions in particular.

You said on the page I mentioned:

each server/service in one container. web-server, php, database and nextcloud = 4 container.

I hope to learn from the way you are containerising your services :) I see your tasks install nginx. But I can't see the containerisation of php - am I missing it somewhere in your code?

Context: I have multiple installations of nextcloud (on apache)- around version 17 - and keeping Drupal and nextcloud from conflicting with each other over php versions and environment as "global" is challenging to say the least, Separation would provide great relief.

ReinerNippes commented 4 years ago

Separation would provide great relief.

that's the core feature of docker container.

Do you have any pointers on how to containerise php?

there are ready to use php container. In many different flavors. https://hub.docker.com/_/php if you have written your own php application that would be your base.

nextcloud and drupal are using this images as their base image. both apps are installed into these base images.

https://github.com/nextcloud/docker/blob/3e474524d0e94c5e1fd3eaf27467eb1dd646951e/17.0/fpm/Dockerfile#L2

https://github.com/docker-library/drupal/blob/aa0832cb02509999c0de49100e3f7661d8fe2672/8.8/fpm/Dockerfile#L2

does the nginx container contain its own php?

I use the fpm-php based nextcloud container. fpm-php can't handle static html, css, script content. So it needs a frontend server for that. That's the purpose of the nginx container. if you change the nextcloud image from fpm-alpine to latest you won't get nginx startet. because the base image of "latest" is an apache mod-php container.

https://github.com/ReinerNippes/nextcloud_on_docker/blob/f7a88d8099ade0e6f4699f6a2eb9e41d875ba309/group_vars/all.yml#L19

that is controlled here: https://github.com/ReinerNippes/nextcloud_on_docker/blob/f7a88d8099ade0e6f4699f6a2eb9e41d875ba309/roles/docker_container/tasks/main.yml#L37

in front of nginx/apache is traefik as a reverse proxy. the advandage is that it generates automatically letsencrypt or selfsigned certificates and can route your web traffic to different services.

here (nextcloud_on_docker) it's used to also provide portainer and adminer services. (if enabled in the inventory file.) i only need to tag the containers and they are reachable from outside via ssl.

https://github.com/ReinerNippes/selfhosted_on_docker is the next level. you can define a list of services (multiple joomlas) and they are automatically create for you. https://github.com/ReinerNippes/selfhosted_on_docker#some-more-apps it would be also possible to setup different joomla versions with this.

james-cook commented 4 years ago

Thanks for your great feedback. Before trying this in production I'm going to spin up a basic 16.04 droplet and follow your instructions to see how everything works,