Local development
You can locally develop a WordPress site that is hosted at Presslabs by following a few easy steps. This will help you understand how to use Docker and the production file structure.
We’re offering Docker as a default tool for developers that need to work on the WordPress sites hosted on Presslabs.
What is Docker?
Docker is a framework through which production sites can be replicated to your local computer for development purposes. It’s simple, straightforward and works just on any platform: Mac, Windows and Linux.
How to Install and Configure Docker
There are a few easy steps to get a complete development setup on your local computer. Here they are:
Step 1: Requirements
Download and install Docker and Git . Installing them is very easy and straightforward.
Step 2: Clone and get started
Once Docker is installed and running, run these commands from your terminal window:
git clone -o gitium git@github.com:presslabs/gitium-base AWESOME_SITE
NOTE
You need to replace
AWESOME_SITE
with the name of your site
Step 3: Connect to your remote git repo
After you clone your site, move to the repo and connect to to remote version. Please use the following commands:
cd AWESOME_SITE
git remote add origin git@github.com:GITHUB_USERNAME/AWESOME_SITE
git branch main --set-upstream-to origin/main
git push origin main
Step 4: Start the local environment
docker compose up
If the above command returns errors on the Linux and Windows (with WSL), please run this:
USER_ID="$(id -u)" GROUP_ID="$(id -g)" docker compose up
Step 5: DB import
- Get a database dump from your hosting provider.
- Download it locally and unpack it into the
current repository
. - Import the database into your local MySQL:
cat database.sql | docker compose exec -T db mysql -u wordpress -pnot-so-secure wordpress
- Connect to the
wordpress
container:
docker compose exec wordpress bash
- Clear the cache from WP-CLI:
wp cache flush
- Done!
Step 6: Log in to the local development environment
Go to http://localhost:8080/wp-admin/ from your browser and log in to the local development environment.
Step 7: Runtime extensions
We offer some extensions to the default configuration that allow you to change the running mode.
Enable SSL
-
Generate a key and a certificate and place them in the root directory of the project under the names
certificate.key
andcertificate.crt
. -
Run docker compose overwriting the default ssl config like this:
docker compose -f docker-compose.yaml -f .dev/docker-compose.ssl.yaml up
Run as root
docker compose -f docker-compose.yaml -f .dev/docker-compose.run-as-root.yaml up