/blh-dev-env

docker dev env for blh site

Primary LanguageDockerfile

WordPress Local Development: with Nginx + Mariadb in Docker

Before Start

Proper file permissions

Setup proper file permissions of wp-content folder so that you can use your favorite editor

There is a default USER environment variable which hold the user name of current logged-in user. We will use these variables in our docker-compose.yml file and create two environment variables to be used inside wordpress container.

Find out your user name and id by

id YOUR_USERNAME

and copy and paste the the value in .env-sample

LOCAL_USER_ID=sample_id
LOCAL_USER_NAME=sample_user

Replace the domain name in ngin.conf file

Use mkcert if you want SSL cert on localhost

  • (For ubuntu) install homebrew to be able to install [mkcert]
  • install mkcert for creating the SSL cert
  • Create SSL cert
cd cli
chmod +x create-cert.sh
./create-cert.sh

Start

  • Edit the .env-sample file with custom value, change its name to .env
  • change the server_name in nginx.conf file to your custom domain
docker-compose build 
docker-compose up -d
  • after containers up run
mkcert -install

Useful commands for debug

docker-compose build --no-cache
docker-compose up -d db
docker-compose up -d wp
docker-compose up -d nginx
docker-compose up -d php-myadmin
docker container logs CONTAINER_NAME

Reference Link about file permissions in host machine and docker container

Reference Link about mkcert