This guide provides detailed instructions for deploying a academykit application on a Linux server, including setting up MySQL database, Docker, application server, SSL certificate deployment, and MinIO file server setup. Below is the step-by-step guide:

Prerequisites:

  • MySQL database
  • Ubuntu 20.04 (server)
  • Docker installed on Ubuntu server
  • Access to Elastic Container Registry (ECR) for pulling images
  • Permissions on the server with sudo access

MySQL Database Setup:

  1. Update package manager:
    sudo apt update
    
  2. Install MySQL server:
    sudo apt install mysql-server
    
  3. Secure MySQL installation (optional):
    sudo mysql_secure_installation
    
  4. Start MySQL service:
    sudo systemctl start mysql
    
  5. Enable MySQL on startup:
    sudo systemctl enable mysql
    
  6. Access MySQL:
    mysql -u root
    
  7. Create database:
    CREATE DATABASE academykit;
    
  8. Create user for the database:
    CREATE USER 'academykit'@'%' IDENTIFIED BY 'password';
    
  9. Grant privileges to the user:
    GRANT ALL PRIVILEGES ON academykit.* TO 'academykit'@'%';
    
  10. Flush privileges:
    FLUSH PRIVILEGES;
    EXIT;
    

Docker Installation:

  1. Update package manager:
    sudo apt update
    
  2. Install Docker:
    sudo systemctl start docker
    
  3. Enable Docker on startup:
    sudo systemctl enable docker
    
  4. Verify Docker installation:
    docker --version
    
  5. Test Docker:
    sudo docker run hello-world
    

Application Server Setup and Configuration:

  1. Obtain SSL certificate and private key.
  2. Place the SSL certificate and private key in nginx/nginx.cert and nginx/sssl.key directories.
  3. Update Dockerfile in the nginx folder.
  4. Create docker-compose.yml file in the root directory of the application.
  5. Update the docker-compose.yml file with necessary configurations.
  6. Deployment Commands:
    sudo docker-compose build
    sudo docker-compose up -d
    

Certificate Deployment Guide:

  1. Create docker-compose-certificate.yml file.
  2. Update the docker-compose-certificate.yml file with necessary configurations.
  3. Deployment Commands:
    sudo docker-compose -f docker-compose-certificate.yml build
    sudo docker-compose -f docker-compose-certificate.yml up -d
    

File Server (MinIO) Setup Guide:

MinIO is an object storage solution that provides an Amazon Web Services S3-compatible API and supports all core S3 features. MinIO is built to deploy anywhere - public or private cloud, baremetal infrastructure, orchestrated environments, and edge infrastructure.

  1. Create a docker-compose-minio.yaml file and copy the content
version: '3.7'

# Settings and configurations that are common for all containers
x-minio-common: &minio-common
  image: minio/minio
  command: server --console-address ":9001"
  expose:
    - "9000"
    - "9001"
  environment:
    MINIO_ROOT_USER: ${user}
    MINIO_ROOT_PASSWORD: ${password}
  healthcheck:
    test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
    interval: 30s
    timeout: 20s
    retries: 3

# starts 8 docker containers running MinIO server instances.
# using nginx reverse proxy, load balancing, you can access
# it through port 9000.
services:
  minio1:
    <<: *minio-common
    hostname: minio1
    volumes:
      - data1-1:/data1
      - data1-2:/data2
  minio2:
    <<: *minio-common
    hostname: minio2
    volumes:
      - data2-1:/data1
      - data2-2:/data2
  minio3:
    <<: *minio-common
    hostname: minio3
    volumes:
      - data3-1:/data1
      - data3-2:/data2
  minio4:
    <<: *minio-common
    hostname: minio4
    volumes:
      - data4-1:/data1
      - data4-2:/data2
  minio5:
    <<: *minio-common
    hostname: minio5
    volumes:
      - data5-1:/data1
      - data5-2:/data2
  minio6:
    <<: *minio-common
    hostname: minio6
    volumes:
      - data6-1:/data1
      - data6-2:/data2
  minio7:
    <<: *minio-common
    hostname: minio7
    volumes:
      - data7-1:/data1
      - data7-2:/data2
  minio8:
    <<: *minio-common
    hostname: minio8
    volumes:
      - data8-1:/data1
      - data8-2:/data2
  nginx:
    image: nginx:1.19.2-alpine
    hostname: nginx
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
    ports:
      - "9000:9000"
      - "9001:9001"
    depends_on:
      - minio1
      - minio2
      - minio3
      - minio4
      - minio5
      - minio6
      - minio7
      - minio8

# By default this config uses default local driver,
# For custom volumes replace with volume driver configuration.
volumes:
  data1-1:
  data1-2:
  data2-1:
  data2-2:
  data3-1:
  data3-2:
  data4-1:
  data4-2:
  data5-1:
  data5-2:
  data6-1:
  data6-2:
  data7-1:
  data7-2:
  data8-1:
  data8-2:

  1. Update the docker-compose-minio.yaml file with necessary configurations.

Environment variable:

  • user : Login username for application
  • password : Login password
  1. Deployment Commands:
    sudo docker-compose -f docker-compose-minio.yml build
    sudo docker-compose -f docker-compose-minio.yml up -d
    
  2. Verification:
    1. Open in web browser.
    2. Enter the domain name or IP address associated with the deployed application and add :9000 at the end or map a new domain with this port.
    3. Verify the site is running or not.

File Server Setup Manual:

  1. Login to the MinIO server using the above credentials and create a bucket named academykit.

  2. After creating open detail of that bucket and click on access policy. Select custom and write below policy:

{
"Version": "2012-10-17",
"Statement": [
{

"Effect": "Allow",
"Principal": {
"AWS": [
"*"
]
},
"Action": [
"s3:ListBucket",
"s3:ListBucketMultipartUploads",
"s3:GetBucketLocation"
],
"Resource": [
"arn:aws:s3:::academykit"
]
},
{
"Effect": "Allow",
"Principal": {
"AWS": [
"*"
]
},
"Action": [
"s3:AbortMultipartUpload",
"s3:DeleteObject",
"s3:ListMultipartUploadParts",
"s3:PutObject"
],
"Resource": [
"arn:aws:s3:::academykit/private/*"
]
},
{
"Effect": "Allow",
"Principal": {
"AWS": [
"*"
]
},
"Action": [
"s3:ListMultipartUploadParts",
"s3:PutObject",
"s3:AbortMultipartUpload",
"s3:DeleteObject",

"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::academykit/public/*"
]
}
]
}
  1. Create public and private paths in the academykit bucket for storing files.
  2. MinIO setup is complete.
  3. After setting up the file server, add the access key and the server URL in the application file storage section. To add the configuration, you need to login to the application and navigate to the setings>Admin>filestorage and change to the server.

This guide provides a comprehensive approach to deploying a academykit application on a Linux server with MySQL database, Docker, SSL certificate, and MinIO file server setup. Make sure to follow each step carefully for successful deployment.