diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..b6d7807 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "css.validate": false +} diff --git a/docs/deploy-blobfishes-to-digitalocean.md b/docs/deploy-blobfishes-to-digitalocean.md index 66ded32..c79a8f4 100644 --- a/docs/deploy-blobfishes-to-digitalocean.md +++ b/docs/deploy-blobfishes-to-digitalocean.md @@ -5,19 +5,21 @@ * Introduction * Reference documents * Prerequisites -* Deploy blobfishes to DigitalOcean using Droplets +* Deploy blobfishes to DigitalOcean in a Droplet - Create a new Project on DigitalOcean - - Spin a MongoDB cluster on DigitalOcean - - Create a Droplet on DigitalOcean - - Login to the VM via SSH - - Install Docker and `docker-compose` - - Clone blobfishes sources from GitHub - - Create file `.env` with connection info to the MongoDB instance - - Bring up blobfish webapp using `docker-compose` + - Spin a MongoDB cluster + - Create a Droplet + - Login via SSH and update OS + - (Optional) Register a DNS A record + - Install Docker + - Install Docker Compose + - Check out blobfishes sources + - Create and customize the `.env` file + - Bring up the blobfish webapp - Test blobfish webapp locally - Open incoming ports on the VM - - Test webapp remotely using a browser -* Deploy blobfishes to DigitalOcean inside an App + - Test webapp remotely using a browser + * See also @@ -51,7 +53,7 @@ This document explains how to perform a deployment of the blobfishes project to * A valid login to [DigitalOcean cloud](https://cloud.digitalocean.com/) * Access to blobfishes sources on GitHub -## Deploy blobfishes to DigitalOcean using Droplets +## Deploy blobfishes to DigitalOcean in a Droplet > Droplets? Are we spreading COVID-19 disease again??? @@ -98,7 +100,7 @@ Click "Skip for now". Click "Remind me later". -### Spin a MongoDB cluster on DigitalOcean +### Spin a MongoDB cluster Logged into the DigitalOcean console, expand section "MANAGE", then click "Databases". @@ -193,9 +195,8 @@ Then click "Create a Database Cluster". -TODO -### Create a Droplet on DigitalOcean +### Create a Droplet @@ -352,14 +353,14 @@ As soon as the Droplet is created you should find its name with a green icon and -### Login to the VM via SSH +### Login via SSH and update OS Log in to the VM instance via SSH ```bash -ssh -i root@ +ssh -i root@ ``` Result: @@ -404,51 +405,353 @@ applicable law. root@ubuntu-s-1vcpu-1gb-fra1-01:~# ``` -TODO +Update the OS and reboot if requested -### Install Docker and `docker-compose` +```bash +sudo apt update && sudo apt -y dist-upgrade && sudo apt -y autoremove --purge +sudo reboot +``` -TODO +### (Optional) Register a DNS A record -### Clone blobfishes sources from GitHub + -TODO +If you have edit permissions on some DNS zones you may register an A record for the public IP address of the Droplet which you have just created. + +Example: "blobfishes.aquariophilie.fun" --> 64.225.96.211 + +Notice that the DNS zone propagation may take a few minutes. + +Test that DNS update was successful + +```bash +ping blobfishes.aquariophilie.fun +``` + +Result: + +```text +gmacario@gmpowerhorse:~ $ ping blobfishes.aquariophilie.fun +PING blobfishes.aquariophilie.fun (64.225.96.211) 56(84) bytes of data. +64 bytes from 64.225.96.211 (64.225.96.211): icmp_seq=1 ttl=49 time=25.3 ms +64 bytes from 64.225.96.211 (64.225.96.211): icmp_seq=2 ttl=49 time=24.0 ms +64 bytes from 64.225.96.211 (64.225.96.211): icmp_seq=3 ttl=49 time=24.5 ms +^C +--- blobfishes.aquariophilie.fun ping statistics --- +3 packets transmitted, 3 received, 0% packet loss, time 2003ms +rtt min/avg/max/mdev = 24.021/24.590/25.282/0.522 ms +gmacario@gmpowerhorse:~ $ +``` + +Login to the VM via SSH to perform the next steps + +```bash +ssh -i root@blobfishes.aquariophilie.fun +``` + +Result: + +```text +gmacario@gmpowerhorse:~ $ ssh -i ~/.ssh/gmacario-gmail-com root@blobfish.aquariophilie.fun +Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-77-generic x86_64) + + * Documentation: https://help.ubuntu.com + * Management: https://landscape.canonical.com + * Support: https://ubuntu.com/advantage + + System information as of Tue Jul 20 20:02:58 UTC 2021 + + System load: 0.0 Users logged in: 0 + Usage of /: 7.5% of 24.06GB IPv4 address for eth0: 64.225.96.211 + Memory usage: 17% IPv4 address for eth0: 10.19.0.5 + Swap usage: 0% IPv4 address for eth1: 10.114.0.4 + Processes: 109 + +0 updates can be applied immediately. + + +Last login: Tue Jul 20 20:02:12 2021 from 93.43.242.87 +root@ubuntu-s-1vcpu-1gb-fra1-01:~# +``` + + +### Install Docker + +Follow the instructions at + +Prerequisites: Logged in on the VM + + + +```bash +ssh -i root@blobfishes.aquariophilie.fun +``` + +Update packages and install Docker + +```bash +sudo apt update +sudo apt install apt-transport-https ca-certificates curl software-properties-common +curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - +sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" +sudo apt update +apt-cache policy docker-ce +``` + +Result: + +```text +docker-ce: + Installed: (none) + Candidate: 5:20.10.7~3-0~ubuntu-focal + Version table: + 5:20.10.7~3-0~ubuntu-focal 500 + 500 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages + 5:20.10.6~3-0~ubuntu-focal 500 + 500 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages + 5:20.10.5~3-0~ubuntu-focal 500 + 500 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages + 5:20.10.4~3-0~ubuntu-focal 500 + 500 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages + 5:20.10.3~3-0~ubuntu-focal 500 + 500 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages + 5:20.10.2~3-0~ubuntu-focal 500 + 500 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages + 5:20.10.1~3-0~ubuntu-focal 500 + 500 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages + 5:20.10.0~3-0~ubuntu-focal 500 + 500 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages + 5:19.03.15~3-0~ubuntu-focal 500 + 500 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages + 5:19.03.14~3-0~ubuntu-focal 500 + 500 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages + 5:19.03.13~3-0~ubuntu-focal 500 + 500 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages + 5:19.03.12~3-0~ubuntu-focal 500 + 500 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages + 5:19.03.11~3-0~ubuntu-focal 500 + 500 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages + 5:19.03.10~3-0~ubuntu-focal 500 + 500 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages + 5:19.03.9~3-0~ubuntu-focal 500 + 500 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages +root@ubuntu-s-1vcpu-1gb-fra1-01:~# +``` + +Finally, install Docker: + +```bash +sudo apt install docker-ce +``` + +Docker should now be installed, the daemon started, and the process enabled to start on boot. Check that it’s running: + +```bash +sudo systemctl status docker +``` + +The output should be similar to the following, showing that the service is active and running: + +``` +root@ubuntu-s-1vcpu-1gb-fra1-01:~# sudo systemctl status docker +● docker.service - Docker Application Container Engine + Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled) + Active: active (running) since Tue 2021-07-20 20:12:51 UTC; 15min ago +TriggeredBy: ● docker.socket + Docs: https://docs.docker.com + Main PID: 2914 (dockerd) + Tasks: 8 + Memory: 41.8M + CGroup: /system.slice/docker.service + └─2914 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock + +Jul 20 20:12:50 ubuntu-s-1vcpu-1gb-fra1-01 dockerd[2914]: time="2021-07-20T20:12:50.841032999Z" level=warning msg="Your kernel does not support CPU realtime scheduler" +Jul 20 20:12:50 ubuntu-s-1vcpu-1gb-fra1-01 dockerd[2914]: time="2021-07-20T20:12:50.841357547Z" level=warning msg="Your kernel does not support cgroup blkio weight" +Jul 20 20:12:50 ubuntu-s-1vcpu-1gb-fra1-01 dockerd[2914]: time="2021-07-20T20:12:50.841554439Z" level=warning msg="Your kernel does not support cgroup blkio weight_device" +Jul 20 20:12:50 ubuntu-s-1vcpu-1gb-fra1-01 dockerd[2914]: time="2021-07-20T20:12:50.842164586Z" level=info msg="Loading containers: start." +Jul 20 20:12:51 ubuntu-s-1vcpu-1gb-fra1-01 dockerd[2914]: time="2021-07-20T20:12:51.034045414Z" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip c> +Jul 20 20:12:51 ubuntu-s-1vcpu-1gb-fra1-01 dockerd[2914]: time="2021-07-20T20:12:51.146664996Z" level=info msg="Loading containers: done." +Jul 20 20:12:51 ubuntu-s-1vcpu-1gb-fra1-01 dockerd[2914]: time="2021-07-20T20:12:51.233915455Z" level=info msg="Docker daemon" commit=b0f5bc3 graphdriver(s)=overlay2 version=20.10.7 +Jul 20 20:12:51 ubuntu-s-1vcpu-1gb-fra1-01 dockerd[2914]: time="2021-07-20T20:12:51.234615393Z" level=info msg="Daemon has completed initialization" +Jul 20 20:12:51 ubuntu-s-1vcpu-1gb-fra1-01 systemd[1]: Started Docker Application Container Engine. +Jul 20 20:12:51 ubuntu-s-1vcpu-1gb-fra1-01 dockerd[2914]: time="2021-07-20T20:12:51.350939489Z" level=info msg="API listen on /run/docker.sock" +lines 1-21/21 (END) +``` -### Create file `.env` with connection info to the MongoDB instance +Test: ```bash +docker version +``` + +Result: + +```text +root@ubuntu-s-1vcpu-1gb-fra1-01:~# docker version +Client: Docker Engine - Community + Version: 20.10.7 + API version: 1.41 + Go version: go1.13.15 + Git commit: f0df350 + Built: Wed Jun 2 11:56:38 2021 + OS/Arch: linux/amd64 + Context: default + Experimental: true + +Server: Docker Engine - Community + Engine: + Version: 20.10.7 + API version: 1.41 (minimum version 1.12) + Go version: go1.13.15 + Git commit: b0f5bc3 + Built: Wed Jun 2 11:54:50 2021 + OS/Arch: linux/amd64 + Experimental: false + containerd: + Version: 1.4.8 + GitCommit: 7eba5930496d9bbe375fdf71603e610ad737d2b2 + runc: + Version: 1.0.0 + GitCommit: v1.0.0-0-g84113ee + docker-init: + Version: 0.19.0 + GitCommit: de40ad0 +root@ubuntu-s-1vcpu-1gb-fra1-01:~# +``` + +### Install Docker Compose + +Follow the instructions at + +Prerequisites: Docker already installed on your VM + +Logged in on the VM, install Docker Compose + +```bash +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 +``` + +Verify that the installation was successful + +```bash +docker-compose --version +``` + +Result + +```text +root@ubuntu-s-1vcpu-1gb-fra1-01:~# docker-compose --version +docker-compose version 1.27.4, build 40524192 +root@ubuntu-s-1vcpu-1gb-fra1-01:~# +``` + + +### Check out blobfishes sources + +Check out the blobfishes sources from GitHub: + +```bash +mkdir -p ~/github/aquariophilie +cd ~/github/aquariophilie +git clone https://github.com/aquariophilie/blobfishes +``` + +Result + +```text +root@ubuntu-s-1vcpu-1gb-fra1-01:~# mkdir -p ~/github/aquariophilie +root@ubuntu-s-1vcpu-1gb-fra1-01:~# cd ~/github/aquariophilie +root@ubuntu-s-1vcpu-1gb-fra1-01:~/github/aquariophilie# git clone https://github.com/aquariophilie/blobfishes +Cloning into 'blobfishes'... +remote: Enumerating objects: 593, done. +remote: Counting objects: 100% (593/593), done. +remote: Compressing objects: 100% (441/441), done. +remote: Total 593 (delta 272), reused 376 (delta 122), pack-reused 0 +Receiving objects: 100% (593/593), 277.73 KiB | 16.34 MiB/s, done. +Resolving deltas: 100% (272/272), done. +root@ubuntu-s-1vcpu-1gb-fra1-01:~/github/aquariophilie# +``` + + +### Create and customize the `.env` file + + + +Create the `.env` file starting from `.env.example`: + +```bash +cd ~/github/aquariophilie/blobfishes cp .env.example .env vi .env ``` -Edit the `MONGODB_xxx` variables - example: +Edit the `MONGODB_xxx` variables with the information for connecting to the MongoDB instance - example: ```text -MONGODB_NAME=TODO +MONGODB_NAME=blobfishes MONGODB_PASS=dbpass MONGODB_URI=TODO MONGODB_USER=dbuser ``` -TODO -### Bring up blobfish webapp using `docker-compose` +### Bring up the blobfish webapp -TODO + + +Bring up the blobfish webapp using `docker-compose up` ```bash +cd ~/github/aquariophilie/blobfishes docker-compose up -d ``` Result: ```text -TODO +root@ubuntu-s-1vcpu-1gb-fra1-01:~# cd ~/github/aquariophilie/blobfishes +root@ubuntu-s-1vcpu-1gb-fra1-01:~/github/aquariophilie/blobfishes# docker-compose up -d +Creating network "blobfishes_default" with the default driver +Building static-pages +Step 1/7 : FROM node:14.17.3-alpine +14.17.3-alpine: Pulling from librar +... +Successfully built 469fe99d09b2 +Successfully tagged blobfishes_server:latest +WARNING: Image for service server was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`. +Creating blobfishes_static-pages_1 ... done +Creating blobfishes_server_1 ... done +root@ubuntu-s-1vcpu-1gb-fra1-01:~/github/aquariophilie/blobfishes# +``` + +Verify that the services are up and running + +```bash +docker-compose ps ``` +Result: + +``` +root@ubuntu-s-1vcpu-1gb-fra1-01:~/github/aquariophilie/blobfishes# docker-compose ps + Name Command State Ports +-------------------------------------------------------------------------------------------------------------- +blobfishes_server_1 docker-entrypoint.sh node ... Up 0.0.0.0:3000->3000/tcp,:::3000->3000/tcp +blobfishes_static-pages_1 docker-entrypoint.sh ls -l ... Exit 0 +root@ubuntu-s-1vcpu-1gb-fra1-01:~/github/aquariophilie/blobfishes# +``` + +You can use "docker-compose logs ..." for troubleshooting services startup errors + +```bash +docker-compose logs +``` + + ### Test blobfish webapp locally -TODO + ```bash curl -v http://localhost:3000/ @@ -457,25 +760,50 @@ curl -v http://localhost:3000/ Result: ```text -TODO +root@ubuntu-s-1vcpu-1gb-fra1-01:~# curl -v http://localhost:3000/ +* Trying 127.0.0.1:3000... +* TCP_NODELAY set +* Connected to localhost (127.0.0.1) port 3000 (#0) +> GET / HTTP/1.1 +> Host: localhost:3000 +> User-Agent: curl/7.68.0 +> Accept: */* +> +* Mark bundle as not supporting multiuse +< HTTP/1.1 404 Not Found +< Vary: Origin +< Content-Type: text/plain; charset=utf-8 +< Content-Length: 9 +< Date: Tue, 20 Jul 2021 21:00:08 GMT +< Connection: keep-alive +< Keep-Alive: timeout=5 +< +* Connection #0 to host localhost left intact +root@ubuntu-s-1vcpu-1gb-fra1-01:~# ``` ### Open incoming ports on the VM -TODO +**NOTE**: This step is not necessary with DigitalOcean. -### Test webapp remotely using a browser -TODO +### Test webapp remotely using a browser + +Open from your favourite browser. + + + + ## See also -TODO +* diff --git a/docs/submit-blobfishes-to-do-hackathon.md b/docs/submit-blobfishes-to-do-hackathon.md new file mode 100644 index 0000000..8293889 --- /dev/null +++ b/docs/submit-blobfishes-to-do-hackathon.md @@ -0,0 +1,33 @@ +# Submit Blobfishes project entry to DigitalOcean MongoDB hackathon + +Fill in in the ["DigitalOcean MongoDB Hackathon Submission" form](https://docs.google.com/forms/d/e/1FAIpQLSewoy9wPZ892wg1cf87eeEgL5XmbvGZ4csrULegIoL0w5tJ_A/viewform?usp=sf_link): + +TODO + +(2021-07-xx xx:xx CEST) + +> **DigitalOcean MongoDB Hackathon Submission** +> +> Submit the awesome app you built and get a shirt and sticker pack!
+> \* Required +> +> * Email * +> - `gmacario@gmail.com` +> * What I built for this hackathon * +> - `Blobfishes - The ugliest project participating to the DigitalOcean MongoDB Hackathon` +> * Link to my live app *
+> Deploy your app to DigitalOcean and add the link here: +> - `TODO` +> * Link to my GitHub repo *
+> Make sure the repo is public and the license is MIT, Apache, BSD-2, BSD-3, or Commons Clause. +> - `https://github.com/aquariophilie/blobfish` +> * Articles I wrote about my app
+> Add a link on a new line +> - `https://gmacario.github.io/posts/2021-07-17-our-journey-to-do-mongodb-hackathon` +> - `https://gmacario.github.io/posts/2021-07-20-blobfishes-submitted-to-mongodb-hackathon` + +Click "Next". + +TODO + +