In order to build it use theese steps:
git clone ^this_repo^
cd ^repo_folder^
# Build for alpine & fpm image
docker build --tag ^a name for your container^ -f Dockerfile --no-cache .
# Build for apache image
docker build --tag ^a name for your container^ -f Dockerfile_apache --no-cache .
In order to build it use theese steps:
git clone ^this_repo^
cd ^repo_folder^
# Build for alpine & fpm image
docker-compose build --no-cache wordpress
# Build for apache image
docker-compose build --no-cache wordpress_apache
In order to run it try the following (for development & testing purpose only):
docker create network --ip-range=172.12.0.0/19 ^network_name^
docker run --name ^a name^ --net ^network_name^ --ip 172.12.0.2 -e MYSQL_ROOT_PASSWORD=^a super strong password^ -d mariadb
docker run --name ^an another name^ --net ^network_name^ --ip 172.12.0.2 --link ^a name^:mysql -p 8080:80 -e WORDPRESS_URL=172.12.0.3 -e WORDPRESS_DB_PASSWORD=^a super strong password^ -d ^autogenerated hash from docker build or the tag^
NOTE: The value WORDPRESS_URL is recomended to be website's url that the user will type on the browser. For development purpoce please use http://0.0.0.0:^mapped_port^
Alternatively you can use docker-compose:
docker-compose up
Please have a look on: https://github.com/ellakcy/wordpress-with-plugins-deployment-recipe
Supports these extra enviromental variables:
Variable Name | Defalt Value | Description |
---|---|---|
WORDPRESS_ADMIN_USERNAME | admin | The username of the admin user |
WORDPRESS_ADMIN_PASSWORD | admin123 | The password of the admin user. PLEASE DO CHANGE WHEN ON PRODUCTION. |
WORDPRESS_ADMIN_EMAIL | [email protected] | The administrator email. (Recomended to change.) |
WORDPRESS_URL | localhost | Your site's url. PLEASE SET AS CONTAINERS IP. TESTED WITH THAT |
WORDPRESS_TITLE | My localhost site | The title to be displayed when generating the site. |
Also inherits all the enviromental varialbes from the original wordpress docker image: https://hub.docker.com/_/wordpress/
NOTE:
WORDPRESS_ADMIN_USERNAME
must have a DIFFERENT value from WORDPRESS_ADMIN_PASSWORD in order to be able to login to wordpress dashboard.
On you terminal type:
docker inspect ^container name or hash^
And on the json that has been output look for "IPAddress"
visit this ip addresss to your borwser and it will work (with broken urls for assets)
The best way to test it is to use apache2 (or another web server or web proxy) in order to achieve a multi purpose testing and deployment bedrock.
The minimal configutation for apache2 is to enaable:
And create the following virtualhost.
<VirtualHost *:80>
ProxyPass / ^container's ip^/
ProxyPassReverse ^container's ip^/ /
</Virtualhost>
Or Alternatively (for development & testing purpose):
<VirtualHost *:80>
ProxyPass /somename ^container's ip^/
ProxyPassReverse ^container's ip^/ /somename
</Virtualhost>
Note that the value that replaces ^sites' url^ or ^container's ip^ must be a valid url starting with http or https and ending with / (in order for assets to work)
For production use the following settings (with ssl redirection)
server {
listen 80;
server_name ^site_url^;
rewrite ^ https://$server_name$request_uri? permanent;
}
server {
listen 443 ssl;
ssl_certificate ^certificate_path^; # managed by Certbot
ssl_certificate_key ^certificate_key^; # managed by Certbot
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
server_name ^site_url^;
location / {
error_page 502 /502.html;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
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;
proxy_cache_bypass $http_upgrade;
proxy_pass ^container's ip^;
}
location = /502.html{
root /var/www/ellak.org;
}
}
Note that the value that replaces ^sites' url^ or ^container's ip^ must be a valid url starting with http or https and ending with / (in order for assets to work)
- When deploying always use a valid url in order to word.
- Even on testing and development please use a webserver as reverse proxy.