Levelup base WordPress Dockerfiles
338
This is the base Dockerfiles for hosted Levelup projects.
Make sure your wp-config.php file are set up like this. Further changes can be done to the file, but be careful and consult Levelup if you are not 100% confident with the changes you want to do.
<?php
define( 'WP_HOME', $_ENV["WP_HOME"] );
define( 'WP_SITEURL', $_ENV["WP_SITEURL"] );
define('DB_NAME', $_ENV["DB_NAME"]);
define('DB_USER', $_ENV["DB_USER"]);
define('DB_PASSWORD', $_ENV["DB_PASSWORD"]);
define('DB_HOST', $_ENV["DB_HOST"]);
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
define('AUTH_KEY', 'put your unique phrase here');
define('SECURE_AUTH_KEY', 'put your unique phrase here');
define('LOGGED_IN_KEY', 'put your unique phrase here');
define('NONCE_KEY', 'put your unique phrase here');
define('AUTH_SALT', 'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT', 'put your unique phrase here');
define('NONCE_SALT', 'put your unique phrase here');
$table_prefix = 'wp_';
define('FORCE_SSL_ADMIN', false);
define('WP_DEBUG', $_ENV["WP_DEBUG"]);
define( 'WP_AUTO_UPDATE_CORE', false );
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
require_once(ABSPATH . 'wp-settings.php');
Place this file in the root of your repository:
FROM levelupify/wordpress:php5.6-apache
# Copy the project files into the default "hosted" area in
COPY . /var/www/html/.
# Create folder for uploads if it does not already exist
RUN mkdir -p /var/www/html/wp-content/uploads
# Make sure the default mount is the uploads folder
VOLUME /var/www/html/wp-content/uploads
# Make sure the right access is set
RUN chown -R www-data:www-data /var/www/html/
EXPOSE 80
Make sure you place the WP install in the root of your repository alongside the Dockerfile etc.
| Env name | Description |
|---|---|
| WP_SITEURL | WP CORE url: Ex: http://localhost:8080/ |
| WP_HOME | What you want your visitors to type: Ex: http://localhost:8080/ |
| WP_DEBUG | Debug on or of? 1 for true or 0 for false |
| DB_NAME | The name of your DB |
| DB_USER | The username for your DB |
| DB_PASSWORD | The password for your DB |
| DB_HOST | The host of your DB |
Make sure you have a .htaccess file located in the root of your repository.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
node_modules/
.DS_Store
*.sublime-workspace
config/local.js
*.log
# Uploads folder
wp-content/uploads
Be sure to mount a volume to store the persistent files
Make sure to always place "persistent" data/media inside the /var/www/html/wp-content/uploadsfolder
It's very important that WordPress is not updated "in production" with the "auto update" logic built into WordPress. This is because of how Docker works. On next deployment, the update will be gone.
Read more about updating WordPress further down in this document.
Make sure to add this to your functions.php file
function remove_core_updates(){
global $wp_version;return(object) array('last_checked'=> time(),'version_checked'=> $wp_version,);
}
add_filter('pre_site_transient_update_core','remove_core_updates');
add_filter('pre_site_transient_update_plugins','remove_core_updates');
add_filter('pre_site_transient_update_themes','remove_core_updates');
version: '3.2'
services:
wordpress:
build: .
restart: always
ports:
- 8080:80
volumes:
- .:/var/www/html/
environment:
WP_SITEURL: http://localhost:8080/
WP_HOME: http://localhost:8080/
WP_DEBUG: 1
DB_HOST: db
DB_USER: exampleuser
DB_PASSWORD: examplepass
DB_NAME: exampledb
db:
image: mysql:5.7
restart: always
ports:
- 3306:3306
volumes:
- mysql-volume:/var/lib/mysql
environment:
MYSQL_DATABASE: exampledb
MYSQL_USER: exampleuser
MYSQL_PASSWORD: examplepass
MYSQL_ROOT_PASSWORD: foobar
volumes:
mysql-volume:
docker-compose upThe general idea is to build the tags like this:
php5.6-apache
Where php6.5 is the php version, and apache is the HTTP server
Tags and master is automatically built with Docker HUB
Make sure to push to the right branch (based on tags)
Master should always be the "latest".
Make sure to update the WordPress core locally, and then push the updated source code to production.
Go to the site and finish up the database changes if necessary.
Nb: DO NOT update WordPress core files in production. These changes will be lost in the next deployment.
Content type
Image
Digest
Size
125.9 MB
Last updated
over 7 years ago
docker pull levelupify/wordpress