Download && install docker
Download && install docker compose
Just run:
cd docker/production
# without ssl
bash docker.sh up
# with ssl
bash docker.sh up secure
The docker configuration is explained in detail below.
Go from console to the docker/production
folder:
cd docker/production
In docker/production
there is a bash script in the docker.sh
file that can be run like this:
./docker.sh parameters
# Or
bash docker.sh parameters // If you have a different bash shell like oh my zsh
There are serveral files with environment variables or config files to consider:
docker/production/.env
# Environment variables needed to run the bash scriptdocker/production/ghost/.env
# Ghost service environment variablesdocker/production/mysql/.env
# Mysql service environment variablesdocker/production/nginx/.env
# Nginx service environment variablesdocker/production/nginx/site.template
# Nginx config site without ssldocker/production/nginx/site.template.ssl
# Nginx config site with ssl
Files with environment variables .env
and other config files mentioned below are ignored and will be created automatically from the *.example
files.
Notes:
- Params between {} are optional, except {}*.
- Service names available:
Service names: ghost | mysql | nginx | cerbot
The following describes each of the parameters::
Usage: docker.sh [up|start|restart|stop|rm|sh|bash|logs|ps]
deploy
--> Build and run services.server.up {secure}
--> Build and run server (nginx) services; "secure" parameter is optional for ssl configurationup {secure}
--> Build && deploy services; "secure" parameter is optional for ssl configuration.start {service}
--> Start services.restart {service}
--> Restart services.stop {service}
--> Stop services.rm {service}
--> Remove services.sh {service}*
--> Connect to "service" shell.bash {service}*
--> Connect to "service" bash shelllogs {service}* {n_last_lines}
--> Show "service" server logsmachine.[details|create|start|restart|stop|rm|ip|ssh]
--> Machine actions
Followup similar steps for one site using the folder:
- Go to folder:
cd docker/production_multi_sites
- Setup
.env
vars - Deploy containers:
bash docker.sh up
- Setup mysql second database
- Re deploy containers:
bash docker.sh up
Create database for second site:
To create a new database with a new user in MySQL, you can follow these steps:
- Log in to MySQL as the root user:
mysql -u root -p
- Enter your root password when prompted.
- Create a new database:
CREATE DATABASE dbname;
- Create a new user:
CREATE USER 'username'@'%' IDENTIFIED BY 'password';
- Grant privileges to the new user for the new database:
GRANT ALL PRIVILEGES ON dbname.* TO 'username'@'%';
- Flush the privileges to apply the changes:
FLUSH PRIVILEGES;
Replace "dbname" with the name of your new database, "username" with the name of your new user, and "password" with a secure password for your new user. Once you have completed these steps, you should be able to log in to MySQL using your new user credentials and access your new database.