amos2021ws03-teams-to-nextcloud

Deployment

This documentation has the following structure:

  1. Prerequisites
  2. Technical details of the deployment
  3. How to use
  4. Release

0. Prerequisites

In order to execute the deployment the following technologies need to be installed:

  1. Docker - Installation Guide
  2. Docker Compose - Installation Guide
  3. NodeJS and npm - for windows and linux use nvm, for mac use n

After installing docker, you need to checkout this repository and open the deployment folder. You can do this using the following commands:

git clone git@github.com:amosproj/amos2021ws03-teams-to-nextcloud.git
cd amos2021ws03-teams-to-nextcloud/deployment

Important: The deployment is created for deploying on a live instance with a public IP and a registered top level domain.

1. Technical Details

For the deployment we use docker compose with the following services:

db: This service is an instance of MariaDB. It uses a volume for persisting the data and creates a database and an user by using the db.env file.

redis: This service runs a redis, which is used by Nextcloud for caching.

proxy and letsencrypt-companion are the two services responsible for exposing the applications to the world. The nginx proxy adds a proxy layer between Nextcloud and the internet. The proxy service uses the nginx-proxy image, which runs an nginx reverse proxy setup and automatically registers containers running on the same docker daemon and routes traffic to them. It is designed to serve multiple sites on the same host machine. The advantage in adding this layer is the ability to add a container for Let’s Encrypt certificate handling. You can find more information also here.

app: this services uses the Nextcloud image, which is in turn based on the apache web server. It is automatically registered to the reverse proxy using the environment variables mentioned in the next section.

frontend: this service runs our frontend. It is also registered to the reverse proxy.

2. How to use

As already mentioned the deployment setup is created using a docker compose file. Before starting the deployment you need to configure the properties for the containers.

2.1. Configuration

In the docker-compose.yml you need to set the following properites:

The db container is where the data base is running.

The app container represents the Nextcloud instance.

The frontend container requires the same properties as the app container.

In the db.env file you need to set the following properties:

In order for the containers to persistantly store the data on the host machine, you need to setup the volumes bindings in the docker-compose file.

2.2. Building the frontend

In order to build the frontend you need NodeJS version 14^.

Open a terminal in the main directory of the repository.

To install the required pacakges run:

npm install

To build the frontend run:

npm run build

When the build is finished the frontend can be found in the dist folder. In the docker-compose.yml edit the volume in the frontend service, so that it points to the dist folder.

2.3. Starting the deployment

Once everything is set up, you can start the deployment using the following command:

docker-compose up -d

You should now be able to reach the Nextcloud instance and the frontend using the domains you have set up for them.

3. Release

In order to release a new version of the software enter the live instance where it is running and open the folder of the project in the terminal. Then run the following commands:

Checkout new version:

git fetch
git checkout tags/<new version>

Build frontend:

npm install
npm run build

Restart the frontend container:

docker ps # to get id of frontend container
docker restart <frontend container id>