Dockpress is a Docker-based basic LEMP development environment designed for WordPress applications.
Looking for a similar Docker environment for Laravel? Then give a try to Laradhoc!
Preferisci leggere in italiano? 🇮🇹
- Nginx
- PHP (7.2 / 7.3 / 7.4) with OPCache
- MySQL / MariaDB
- Mailhog
- Redis
- Custom domain name (e.g.
http://mydockpress.test)
You can choose which version of PHP (for example, 7.4) to run by setting ${PHP_VERSION} variable in your
.env file (see .env.example for details).
Likewise, you can choose your database (for example, MariaDB 10.2) by setting ${DATABASE_IMAGE} variable in your
.env file (see .env.example for details)
In case you want to customize your Docker configuration (e.g. adding some mount),
just run cp docker-compose.yml docker-compose.override.yml then edit your
docker-compose.override.yml. It will be used by Docker.
- MacOS, Linux or Windows with WSL
- Docker
Just clone this repo.
Let's pretend your WordPress application will be accessible at mydockpress.test:
git clone [email protected]:eleftrik/dockpress.git mydockpress.test
cd mydockpress.testCreate an .env file from .env.example
cp .env.example .env
# Customize every variable according to your needs
# See comments to each variable in .env.example file According to the value of ${APP_HOST}, add your test domain (e.g. mydockpress.test) to your hosts file
sudo /bin/bash -c 'echo -e "127.0.0.1 mydockpress.test" >> /etc/hosts'Build all Docker containers and start them
.docker/scripts/initNew WordPress project starting from the scratch? No problem, just run:
.docker/scripts/wp-installA fresh WordPress installation will be downloaded in ${APP_SRC}, configured and available at http://${APP_HOST}
or https://${APP_HOST}
Finished working? Just stop everything:
.docker/scripts/stopNext time you need to run your application, if you haven't changed any setting, just run
.docker/scripts/startWhen updating from a previous version, follow these steps:
-
update your code
- via
git pullif you're still referencing this repository, a fork or a private one - manually downloading the desired release
In both cases, the
src/folder won't be affected - via
-
see
CHANGELOG.md -
update your
./.envfile according to./.env.example(new variables may have been introduced) -
if you have overridden
docker-compose.ymlusingdocker-compose.override.yml, seedocker-compose.ymlto check if something has added, changed or deleted, compared to the previous version ofdocker-compose.ymlyou were using before updating -
launch
.docker/scripts/start --build
Dockpress provides some useful script, located in .docker/scripts.
Run them from your Dockpress base folder.
.docker/scripts/initIt's a shortcut to
docker-compose up -d --buildIt will build and start the containers
.docker/scripts/startIt's a shortcut to
docker-compose up -dYou can add the flag --build if you want to build the images, otherwise
.docker/scripts/startis enough to bring up the environment
Tired of working? Stop the environment
.docker/scripts/stopIt's useful to bring up a new WordPress project.
It will prepare a fresh WordPress installation in your ${APP_SRC},
create a ${APP_SRC}/.env file holding the same values which are in the main .env file,
create a ${APP_SRC}/wp-config.php file which uses the aforementioned .env file
.docker/scripts/wp-installWant to throw away anything?
This command will stop all containers, delete volumes and the entire $APP_SRC.
So, before executing this command, BE SURE you understood very well that you're going to lose all your WordPress codebase and the related database!
.docker/scripts/nahTo throw away anything and start again from the scratch, use
.docker/scripts/nah && .docker/scripts/init && .docker/scripts/wp-installYou can connect to your database via command line or using a tool.
For example, from the command line:
source .env
mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -h127.0.0.1 $MYSQL_DATABASEI bet you prefer to use your favorite tool, for example:
- TablePlus
- SequelPro
- HeidiSQL
etc.
Just use the parameters stored in your .env file.
To catch all outgoing emails via MailHog, install a WordPress plugin (e.g. WP Mail SMTP) and use this configuration:
- SMTP host=mailhog
- SMTP port=1025
- SMTP username=(leave blank)
- SMTP password=(leave blank)
MailHog web interface is available at
http://${APP_HOST}:${MAILHOG_PORT}
For example: http://mydockpress.test:8081
Suggestions, reviews, bug reports are very welcome. We never stop learning :-)
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Thanks to Mauro Cerone for the inspiration