These notes are for people who are new to Linux, Docker, and Caddy starting from a base Ubuntu 20.04 installation on a remote VM or remote Server. This will assume you have root access and can access the shell or terminal via SSH.
You should have some basic linux knowledge such as being able to create folders, create files, edit files, and run scripts. Example basic commands you should understand are `cd, ls, pwd, mkdir, nano somefilename.txt, ./runscript`
Some very useful bash tips for newbies are:
* Use up or down arrows to cycle thru your last used commands.
* Type `history` and Enter to list all your last used commands.
* Type `!1` to enter the first command on the `history` list. `!777` would enter in the 777th command on the `history list`
* Use the tab button to complete commands. For example, lets say you have a file called ThisNameIsTooLong in your current folder and you want to edit it... You can type `nano This` and press **TAB** to auto-complete the filename.
If you are an **experienced user** and want to blaze thru steps 1 and 8. You can use my scripts just make sure you modify your username, hostname, [public-key](https://github.com/StarWhiz/docker_deployment_notes/tree/master/initial%20ubuntu%20setup/putty%20keys%20tutorial), and timezone. Scripts here: [part-1-ubuntu-initial-setup.sh](https://github.com/StarWhiz/docker_deployment_notes/blob/master/initial%20ubuntu%20setup/part-1-ubuntu-initial-setup.sh) and [part-2-docker-scripts](https://github.com/StarWhiz/docker_deployment_notes/blob/master/initial%20ubuntu%20setup/part-2-docker-scripts.sh)
This is a basic firewall on ubuntu. If you install this remember to unblock the specific ports you need open for some of your applications. In the example above we allow our own SSH connection, and open TCP ports 80 & 443 in order for Caddy v2 to work.
If you'd like to learn how to create an SSH key do so [here](https://github.com/StarWhiz/docker_deployment_notes/tree/master/initial%20ubuntu%20setup/putty%20keys%20tutorial)
It allows you to host multiple applications based on the same or different hostname: such as nextcloud.yourwebsite.com, seafile.yourwebsite.com, rocketchat.yourwebsite.com, and yourwebsite.com.
### Requirements
* **Port 80 and 443 forwarded** on the router/firewall to the docker host machine. If you're using a remote server, we already did this with ufw. But if you're running a local server, you will need to open ports 80/tcp and 443/tcp on your router as well and point them to your local server.
* **A domain name** like `example.com` you can buy one for cheap on namecheap.
* After buying your domain you need to set custom DNS records.
* Create type A records that point to the Public IP of your server. So if you made a chat.{$MY_DOMAIN} entry in Caddyfile create a "Type A" record for chat.yourdomain.com and point it to the Public IP of your server.
To achieve this a part of this folder structure do the following below.
```
cd ~
mkdir docker
cd docker
mkdir caddy
cd caddy
```
So now you're inside the caddy folder.
At minimum you will need a **.env**, **Caddyfile** and **docker-compose.yml**. the config/ and data/ folders are automatically generated by docker-compose later.
Do this with `nano .env` and add the following lines in the .env file. Do not use subdomain. Just use yourrootdomain.com, in this example I'm using example.com
A small explanation about this can be found [here](https://github.com/StarWhiz/docker_deployment_notes#commonly-added-lines-added-to-app-specific-docker-composeyml-files)
Congrats you are now ready to deploy applications. The other applications will be deployed the same way you just deployed Caddy! I recommend you deploy [wordpress](https://github.com/StarWhiz/docker_deployment_notes/tree/master/wordpress) first if you are new to this.
1. Find an application specific [guide](https://github.com/StarWhiz/docker_deployment_notes#application-specific-deployment-guides)
2. Make a new app specific folder in `/home/sammy/docker/` with `mkdir newapp`
3. Navigate inside the new app specific folder with `cd newapp`
4. Create the mimimum files as mentioned in the app specific guides, but don't worry about creating folders inside the newapp folder as they are auto generated in docker-compose.yml
5. Use nano to add the app specific blocks to your Caddyfile in ` /home/sammy/docker/caddy/Caddyfile` and save.