Launching a container

First of all, let's prepare the catalogs:

 # mkdir /var/melbis
# mkdir /var/melbis/db
# mkdir /var/melbis/www
# mkdir /var/melbis/certs
# mkdir /var/melbis/certbot

Let's create SSL certificate keys so that the site is accessible via the HTTPS protocol:

 # openssl req -x509 -newkey rsa:4096 -keyout /var/melbis/certs/privkey.pem -out /var/melbis/certs/fullchain.pem -days 3650 -nodes

Let's go to the Melbis Shop server directory:

 # cd /var/melbis

Let's create a container builder configuration file, like this:

 # nano docker-compose.yml
 version: '3'
services:
  db:
    image: mysql:8.4
    environment:
      MYSQL_ROOT_PASSWORD: mysql_passkey
      MYSQL_DATABASE: melbis
      MYSQL_USER: melbis
      MYSQL_PASSWORD: melbis_pass
      MYSQL_CHARACTER_SET_SERVER: utf8mb4
      MYSQL_COLLATION_SERVER: utf8mb4_unicode_ci
    volumes:
      - /var/melbis/db:/var/lib/mysql
    restart: always

  web:
    depends_on:
      - db
    image: kasdim/melbis-shop:latest
    volumes:
      - /var/melbis/www/:/var/www/html/
      - /var/www/html/core
    restart: always

  nginx:
    image: nginx:latest
    volumes:
      - /var/melbis/nginx.conf:/etc/nginx/nginx.conf
      - /var/melbis/certs:/etc/nginx/certs
      - /var/melbis/certbot:/etc/nginx/certbot
    ports:
      - 80:80
      - 443:443
    depends_on:
      - web
    restart: always

Next, let's configure the Ngnix proxy server:

 # nano nginx.conf
 events {}
http {
    server {
        listen 80;
        listen[::]:80;
        listen 443 ssl;
        listen [::]:443 ssl;
        client_max_body_size 64M;
        ssl_certificate /etc/nginx/certs/fullchain.pem;
        ssl_certificate_key /etc/nginx/certs/privkey.pem;
        location /.well-known/ {
            root /etc/nginx/certbot;
        }

        location / {
            proxy_pass http://web:80;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }
    }
}

The Docker image contains only the Melbis Shop core, this is the core folder. Therefore, to start, we need to download the scripts of the minimal demo store from the GitHub website:

 wget https://github.com/melbis/melbis-shop/archive/refs/heads/master.zip

Unpack and copy the files to the root directory of the site:

 unzip master.zip
 rsync -a melbis-shop-master/ /var/melbis/www/

Delete unnecessary files:

 rm -r melbis-shop-master
 rm master.zip

Launch containers:

 # docker-compose up -d

At this stage, the store is already available and can be opened in the browser. This can be done by specifying in the address bar either the domain name of the site or the external IP address of the server. When opening the site, an error message will appear. For now, this is normal, since only the Melbis Shop server scripts were installed and then it is necessary to install the database .