Compare commits

..

5 Commits

Author SHA1 Message Date
Tai 5bcd630529
Update README.md 4 months ago
Tai e0169beb6a
Update README.md 4 months ago
Tai fed2b8de6d
Update README.md 4 months ago
Tai 21e68fd1a5
Update README.md 4 months ago
Tai bb3815219e
Update README.md 4 months ago
  1. 17
      README.md
  2. 43
      initial ubuntu setup/README.md

17
README.md

@ -1,3 +1,20 @@
> [!NOTE]
> ever since docker compose v2 some of the commands in this guide are outdated
>
> For example we no longer do `docker-compose up -d` we do `docker compose up -d`
>
> There's no longer a need for version section required in any `docker-compose.yml`
>
> The docker network `caddy_net` is defined differently now and the end of all `docker-compose.yml` files
> ```
> networks:
> - caddy_net
>
> networks:
> caddy_net:
> external: true
> ```
# Introduction # Introduction
Caddy v2 is the easiest reverse proxy ever! You'll be able to host multiple dockerized applications with one VM and one domain name! I learned from [DoTheEvo](https://github.com/DoTheEvo/selfhosted-apps-docker/tree/master/caddy_v2), but their guide assumes you already installed docker and docker-compose. From my [A-Z guide](https://github.com/StarWhiz/docker_deployment_notes/tree/master/initial%20ubuntu%20setup)... you be handheld from the beginning. In addition to the app specific guides on DoTheEvo's page I also added some of my own! Caddy v2 is the easiest reverse proxy ever! You'll be able to host multiple dockerized applications with one VM and one domain name! I learned from [DoTheEvo](https://github.com/DoTheEvo/selfhosted-apps-docker/tree/master/caddy_v2), but their guide assumes you already installed docker and docker-compose. From my [A-Z guide](https://github.com/StarWhiz/docker_deployment_notes/tree/master/initial%20ubuntu%20setup)... you be handheld from the beginning. In addition to the app specific guides on DoTheEvo's page I also added some of my own!

43
initial ubuntu setup/README.md

@ -14,8 +14,8 @@ If you are an **experienced user** and want to blaze thru steps 1 and 8. You can
**The references I used to write the rest of these notes are bulleted below:** **The references I used to write the rest of these notes are bulleted below:**
* Initial Server Setup: https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-20-04 * Initial Server Setup: https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-20-04
* How to install Docker: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04 * How to install Docker: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04
* How to install docker-compose: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-compose-on-ubuntu-20-04 * How to install docker compose: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker compose-on-ubuntu-20-04
* How to install Caddy: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-compose-on-ubuntu-20-04 * How to install Caddy: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker compose-on-ubuntu-20-04
**Now on to the Main Installation Guide** **Now on to the Main Installation Guide**
@ -105,13 +105,13 @@ id -nG
``` ```
This should return: **sammy** sudo docker This should return: **sammy** sudo docker
### 8. Install Docker-Compose ### 8. Install docker compose
``` ```
sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker compose
sudo chmod +x /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker compose
docker-compose --version docker compose --version
``` ```
### 9. Create a docker network called caddy_net ### 9. Create a docker network called caddy_net
@ -141,7 +141,7 @@ It allows you to host multiple applications based on the same or different hostn
├── data/ ├── data/
├── .env ├── .env
├── Caddyfile ├── Caddyfile
└── docker-compose.yml └── docker compose.yml
``` ```
To achieve this a part of this folder structure do the following below. To achieve this a part of this folder structure do the following below.
``` ```
@ -153,23 +153,21 @@ cd caddy
``` ```
So now you're inside the caddy folder. 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. At minimum you will need a **.env**, **Caddyfile** and **docker compose.yml**. the config/ and data/ folders are automatically generated by docker compose later.
#### Creating .env #### Creating .env
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 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
The purpose of the .env file is to substitute variables in your docker-compose.yml in the same directory. The purpose of the .env file is to substitute variables in your docker compose.yml in the same directory.
**.env** **.env**
``` ```
MY_DOMAIN=example.com MY_DOMAIN=example.com
DOCKER_MY_NETWORK=caddy_net
``` ```
**Ctrl+O** to save file. **Ctrl+O** to save file.
#### Creating docker-compose.yml #### Creating docker compose.yml
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) 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)
**docker-compose.yml** **docker compose.yml**
``` ```
version: "3.7"
services: services:
caddy: caddy:
@ -186,11 +184,12 @@ services:
- ./Caddyfile:/etc/caddy/Caddyfile:ro - ./Caddyfile:/etc/caddy/Caddyfile:ro
- ./data:/data - ./data:/data
- ./config:/config - ./config:/config
networks:
- caddy_net
networks: networks:
default: caddy_net:
external: external: true
name: $DOCKER_MY_NETWORK
``` ```
#### Create Caddyfile #### Create Caddyfile
@ -230,9 +229,9 @@ For now your Caddyfile can be the same as the example above if you plan on deplo
Make sure you're in /home/sammy/docker/caddy Make sure you're in /home/sammy/docker/caddy
Then do Then do
``` ```
docker-compose up -d docker compose up -d
``` ```
to start caddy. To bring it down you can do `docker-compose down`. to start caddy. To bring it down you can do `docker compose down`.
### Time to deploy Applications ### Time to deploy Applications
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. 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.
@ -242,13 +241,13 @@ The general flow for adding new application like wordpress for example is:
1. Find an application specific [guide](https://github.com/StarWhiz/docker_deployment_notes#application-specific-deployment-guides) 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` 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` 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 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. 5. Use nano to add the app specific blocks to your Caddyfile in ` /home/sammy/docker/caddy/Caddyfile` and save.
6. Reload caddy `docker exec -w /etc/caddy caddy caddy reload` 6. Reload caddy `docker exec -w /etc/caddy caddy caddy reload`
7. Change back to your app specific folder ` /home/sammy/docker/newapp` 7. Change back to your app specific folder ` /home/sammy/docker/newapp`
8. `docker-compose up -d` to start the new application 8. `docker compose up -d` to start the new application
9. Test your app by visiting yourappsubdomain.yourwebsite.com 9. Test your app by visiting yourappsubdomain.yourwebsite.com
That's it! As you do this more often, the more you'll appreciate how fast it is to deploy applications with docker and docker-compose with caddy v2! That's it! As you do this more often, the more you'll appreciate how fast it is to deploy applications with docker and docker compose with caddy v2!
Refer to the readme at: https://github.com/StarWhiz/docker_deployment_notes for command references Refer to the readme at: https://github.com/StarWhiz/docker_deployment_notes for command references

Loading…
Cancel
Save