Oracle Cloud Arm Virtual Machine with Portainer Lets Encrypt

Appreciate Oracle Cloud provides a nice free tier virtual machine with 4 CPUs and 24 GB RAM.

This article documents how to setup WordPress + Let's encrypt + Portainer on Oracle Cloud free tier plan.

Oracle Cloud Signup

  1. Signup for Oracle Cloud Free Tier
  2. Login oracle cloud
  3. Create a VM instance
  4. On Image section, select the image you are comfortable with. Select image shape, choose Ampere, and configure CPU to 4 and RAM to 24GB
  5. Download ssh key and create the VM

Docker Setup

  1. Login into the VM with ssh key
  2. Install Docker and Docker Compose, here I use oracle linux as an example
    Please update the version accordingly for docker-compose from release page
    sudo yum install docker-engine
    Don't forget to perform docker post installation steps
    sudo systemctl enable docker
    sudo curl -L "https://github.com/docker/compose/releases/download/v2.2.2/docker-compose-linux-aarch64" -o /usr/local/bin/docker-compose

    sudo chmod +x /usr/local/bin/docker-compose

Get a domain

You can prepare your domain or get a free one from freenom.com.
Update domains DNS to point to the created VM machine
eg: create the following and all point to VM machine's public IP

portainer.domain.com
www.domain.com
domain.com
wordpress.domain.com
test.domain.com

Portainer With Lets encrypt Setup

Here is the fun part, with these 2 github repositories, we can get a SSL and load balancer for free

  1. Follow nginx-proxy-automation to setup let's encrypt.
    you should be able to access portainer.domain.com with https if you run this test cmd, this will generate cert on cert and key /home/opc/proxy/data/certs/portainer.domain.com.crt, which will be used in next step
    ./ssl_test.sh portainer.domain.com

  2. Follow docker-portainer-letse ncrypt

    1. set one domain in DOMAINS=portainer.domain.com as we will use main domain for wordpress
    2. set NETWORK=proxy, not webproxy, since nginx-proxy-automation project created proxy network
    3. run docker-compose up -d, put a password for portainer
    4. access portainer.domain.com see if portainer works

MariaDB Setup

Setup maria db as it use much less memory (100MB) vs MySQL(400MB), and have arm64 docker image

  1. Login portainer, go to App templates
  2. Select MariaDB
  3. Enter root password
  4. Click Advanced Settings, enter a port
  5. In volume mapping, bind a host data folder to /var/lib/mysql. this prevents database persisted if the container is removed.
  6. In host name, type a name, we will use this name for wordpress to access DB, eg: mairadb
  7. In Network, select proxy
  8. Create container and login to create a wordpress db

WordPress Setup

  1. Create a container, not from App templates
  2. Image type wordpress:latest
  3. Env type the following, these are required so let's encrypt container and generate ssl for wordpress
    LETSENCRYPT_EMAIL   email@dmain.com
    LETSENCRYPT_HOST    wordpress.domain.com,www.domain.com,domain.com
    VIRTUAL_HOST    wordpress.domain.com,www.domain.com,domain.com
    VIRTUAL_PORT    8080
    WORDPRESS_DB_HOST   mariadb
    WORDPRESS_DB_NAME   wordpress
    WORDPRESS_DB_PASSWORD   your_db_password
    WORDPRESS_DB_USER   root
  4. Network select proxy
  5. Restart policy select always
  6. Hostname wordpress
  7. Port mapping 8080->80
  8. Volume mapping, bind /home/opc/your_wordpress_data_folder to /var/www/html
  9. Create container and wait for few seconds, access www.domain.com you can see wordpress.

All these comes from memory done few days ago, if something is wrong or outdated, please comment

Leave a Reply

Your email address will not be published.