Skip to content

Repository files navigation

Docker WordPress

Docker PullsDocker StarsDocker Image Size

The provided Docker image allows you to deploy your WordPress website in production with a powerful configuration, an integrated SMTP relay, and support for PHP Redis.

Key features:

  • All images are based on inrage/docker-php
  • Docker Hub
  • Includes an SMTP server for outgoing emails
  • Supports PHP Redis
  • Advanced configuration for optimal performance
  • Easy deployment and scalability with Docker

Supported tags:

Installation

To install, you need to either mount a directory into /var/www/html or customize the destination directory according to your needs. Here's how to proceed:

Dockerfile

FROM inrage/docker-wordpress:8.4
COPY --chown=inr . .

Docker Swarm Configuration

We are using a Docker Swarm configuration with Traefik as a reverse proxy. Here's an example of a docker-compose.yml file:

version: "3.8"services:
redis:
hostname: mywebsite.redisimage: redis:7.2.0healthcheck:
test: ["CMD-SHELL", "redis-cli --raw incr ping"]networks:
- internal-networkcommand: redis-server --maxmemory 1024mb --maxmemory-policy allkeys-lru --appendonly yesenvironment:
TZ: "Europe/Paris"volumes:
- /etc/localtime:/etc/localtime:ro
- redis_data:/dataweb:
image: inrage/mycustomimagenetworks:
database:
traefik-public:
internal-network:
environment:
WORDPRESS_DB_HOST: db-master.dbWORDPRESS_DB_USER: mywebsiteWORDPRESS_DB_PASSWORD: "mywebsitepassword"WORDPRESS_DB_NAME: mywebsiteWORDPRESS_TABLE_PREFIX: gr_WORDPRESS_CONFIG_EXTRA: | define( 'DISALLOW_FILE_MODS', true );	 define( 'WP_MEMORY_LIMIT', '512M' ); define( 'WP_REDIS_HOST', 'mywebsite.redis');TZ: "Europe/Paris"volumes:
- /host/website/mywebsite/uploads:/var/www/html/wp-content/uploadsdeploy:
replicas: 1labels:
- traefik.enable=true
- traefik.docker.network=traefik-public
- traefik.constraint-label=traefik-public
- traefik.http.routers.mywebsite-http.rule=Host(`www.inrage.fr`, `inrage.fr`)
- traefik.http.routers.mywebsite-http.entrypoints=http
- traefik.http.routers.mywebsite-http.middlewares=https-redirect
- traefik.http.routers.mywebsite-https.rule=Host(`www.inrage.fr`, `inrage.fr`)
- traefik.http.routers.mywebsite-https.entrypoints=https
- traefik.http.routers.mywebsite-https.tls=true
- traefik.http.routers.mywebsite-https.tls.certresolver=le
- traefik.http.services.mywebsite.loadbalancer.server.port=80volumes:
redis_data:
networks:
internal-network:
database:
external: truetraefik-public:
external: true

Environment Variable

WordPress

VariableDescriptionDefault
WORDPRESS_NO_CREATE_CONFIGDo not create a config filefalse
WORDPRESS_DB_HOSTDatabase hostmysql
WORDPRESS_DB_USERDatabase userexample username
WORDPRESS_DB_PASSWORDDatabase passwordexample password
WORDPRESS_DB_NAMEDatabase namewordpress
WORDPRESS_TABLE_PREFIXDatabase table prefixwp_
WORDPRESS_DEBUGEnable debug modefalse
WORDPRESS_CONFIG_EXTRAAdditional configurationempty
WORDPRESS_DB_CHARSETDatabase charsetutf8
WORDPRESS_DB_COLLATEDatabase collateempty
WORDPRESS_AUTH_KEYAuthentication keyempty
WORDPRESS_SECURE_AUTH_KEYSecure authentication keyempty
WORDPRESS_LOGGED_IN_KEYLogged in keyempty
WORDPRESS_NONCE_KEYNonce keyempty
WORDPRESS_AUTH_SALTAuthentication
WORDPRESS_SECURE_AUTH_SALTSecure authentication saltempty
WORDPRESS_LOGGED_IN_SALTLogged in saltempty
WORDPRESS_NONCE_SALTNonce saltempty

For WORDPRESS_NO_CREATE_CONFIG: Do not create a new configuration file (default: false)

By default, the image will use a new configuration file which is generated at runtime and after you can use WordPress environnement.

If you want to use your own configuration file, set this variable to true.

For WORDPRESS_CONFIG_EXTRA, you can use the following variables:

WORDPRESS_CONFIG_EXTRA: |
define( 'DISALLOW_FILE_MODS', true );
define( 'WP_MEMORY_LIMIT', '511M' );
define( 'WP_REDIS_HOST', 'mysite.redis');

From inrage/docker-php image

Refer to the inrage/docker-php documentation for more information.

Running User

  • INRAGE_USER_ID: UID of the user to run the application as (default: 1000)
  • INRAGE_GROUP_ID: GID of the user to run the application as (default: 1000)

Tools

  • wp: WordPress CLI
  • sr: allow you to replace in the database (wp search-replace $1 $2 --precise --all-tables --skip-columns=guid)

Daily Usage

About

Docker WordPress images optimized for production

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Used by

Contributors

Languages