Preparing for the installation
The web application (site) of the customizable "online store" can be installed in any environment that supports Docker containerization.
Here, a step-by-step guide for deploying and configuring the site "online store" based on the Ubuntu 20.04 operating system (a variant of Linux) will be discussed.
If you do not have the Ubuntu 20.04 operating system installed, you can install it on your home computer for testing. It is distributed for free. If you already have another operating system, such as Windows, installed on your home computer, you can install Ubuntu 20.04 for testing on a virtual machine without compromising the integrity of the main operating system. Ubuntu 20.04 can be installed on a virtual machine using VMware Workstation, VirtualBox, or any other virtualization software.
You can set up a website on your home computer. But we recommend that after testing on your home computer, you deploy the site on a cloud server. The advantages of a cloud server, unlike a home server, include the ability to operate 24 hours a day, 7 days a week, independence from factors affecting home energy consumption, restricted access to unauthorized individuals, a dedicated IP address, high-speed internet, and other benefits. There are many services that provide cloud servers; we can recommend one of them where you can find a very advantageous rate, price – quality:
DigitalOcean
After you have installed the server operating system Ubuntu 20.04 on your home computer or on a dedicated cloud server, you need to install Docker on this operating system. Since the site 'online store' and the database associated with it are distributed in a Docker container. Installing Docker on the Ubuntu 20.04 operating system is very easy; you just need to execute the set of commands listed below:
Information taken from the source DigitalOcean
Docker is an application that simplifies the process of managing application processes in containers. Containers allow applications to run in processes with isolated resources. They are similar to virtual machines, but containers are more portable, more resource-efficient, and more dependent on the host operating system.
Step 1 - Installing Docker
The Docker installation package available in the official Ubuntu repository may not be the latest version. To ensure that we get the latest version, we will install Docker from the official Docker repository. To do this, we will add a new package source, add the GPG key from Docker to ensure that the downloads are valid, and then install the package.
First, update the existing package list:
sudo apt update
Next, install several required packages that will allow apt to use packages over HTTPS:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
Then add the GPG key for the official Docker repository to your system:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Add the Docker repository to the APT sources:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
This will also update our package database with Docker packages from the newly added repository.
Make sure you are going to install from the Docker repository, not from the default Ubuntu repository:
apt-cache policy docker-ce
You will see output similar to this, although the version number of Docker may be different:
docker-ce:
Installed: (none)
Candidate: 5:19.03.9~3-0~ubuntu-focal
Version table:
5:19.03.9~3-0~ubuntu-focal 500
500 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
Finally, install Docker:
sudo apt install docker-ce
Docker must now be installed, the daemon running, and the process enabled to start at boot. Check that it is running:
sudo systemctl status docker
The output should look similar to the following, showing that the service is active and running:
Output
●docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2020-05-19 17:00:41 UTC; 17s ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 24321 (dockerd)
Tasks: 8
Memory: 46.4M
CGroup: /system.slice/docker.service
└─24321 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
If the status is active (Active: active), then the Docker service is successfully installed!
Step 2 - Running Docker commands without Sudo (optional)
If you want to avoid entering sudo with every docker command, add your username to the docker group:
sudo usermod -aG docker ${USER}
Where USER is your username in the operating system. To apply the new group membership, log out of the server and log back in.
Step 3 — Installing Docker Compose
Docker Compose is a tool that allows you to run multi-container application environments based on definitions specified in a YAML file. It uses service definitions to create fully customizable environments with multiple containers that can share networks and data volumes.
The following command will download the 1.29.2 release and save the executable file to /usr/local/bin/docker-compose, making this software globally accessible as docker-compose:
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Next, set the correct permissions so that the docker-compose command becomes executable:
sudo chmod +x /usr/local/bin/docker-compose
To ensure that the installation was successful, you can run:
docker-compose --version
You will see output similar to this:
docker-compose version 1.29.2, build 5becea4c
If all steps (except for the second step, which is optional) are completed, the preparation of the operating system for deploying the site "online store" is done! You can proceed to the second part:
Deploying the site "online store"