Local Docker development environment for {{name}}. Started with rebirth.
- Docker & Docker Compose
- Composer
- Node.js, Npm & Nvm
- ACF Pro. ACF subscription key can be found from advancedcustomfields.com/my-account. Password can be an existing site that is already active for the license key or your new site url.
- SSH access (RSA Key Pair) and rsync for deploying theme and for syncing assets, repositories and databases from remote locations
git clone {{git-ssh}} && cd {{name}}
- Copy auth.example.json to
auth.json
and add ACF Pro credentials - Optionally copy .env to
.env.local
and make sure that all thePRODUCTION_*
vars are set - Make sure your Docker is running, ports
8000
and13306
are not in use and you're using node version14.16.0
. Then run:
make start
If you're unable to run this, please refer to the Makefile and run the scripts manually. Alternatively clone production to your local development environment with make start-clone
.
Login to the WordPress Admin dashboard to see that everything works properly. Setup WordPress, activate ACF and other plugins, add ACF license key and sync theme's ACF fields if these are not already configured. Assets such as images may be broken, so if you need them you can download them with make assets-pull
.
Go to web/wp-content/themes/{{theme-dir}} and run:
composer install && npm install
Start you theme development with npm run dev
and navigate to localhost:8000.
These scripts work in web/wp-content/themes/{{theme-dir}}. Note that the theme uses a different node version.
npm run dev
: Navigate to http://localhost:8000 (=VITE_DEVELOPMENT_HOST
and not to the port that is Vite prints in the console)npm run preview
: Preview and watch the built production version of the theme locallynpm run build
: Build the production version of the themenpm run deploy
: Build the theme and deploy it to the server
You need SSH access to run some of the scripts. All the scripts are near equivalents to docker-compose
commands and npm
scripts. If you are unable to run these scripts, please refer to the Makefile, package.json, Docker compose reference and Docker CLI.
make start
: Start your project. Builds, creates and starts Docker containers, imports database fromdatabase/wordpress.sql
and installs all dependencies.make start-clone
: Clone production environment to your local development environment. Builds, creates and starts Docker containers, updates all dependencies, pulls assets, pulls MySQL dump, replaces local database with the remote database. Make sure database server credentials are set in the.env.local
file. Note that this could be very heavy process, so do it with caremake up
: Starts Docker containers. Use this to resume developing after installing the project.make stop
: Stop Docker containersmake update
: Update Composer dependenciesmake rebuild
: Rebuilds and reinstall containers, including your MySQL container. Note that you will lose your current data.make web-bash
: Connect to WordPress (web
) containermake db-bash
: Connect to MySQL (db
) containermake assets-pull
: Pull uploaded files from production environment (uploads/
directory) to your local environment.make db-backup
: Creates dump todatabase/local/wordpress-<date>.sql
from your local database.make db-pull
: Create and pull MySQL dump from the production environment todatabase/remote
directory and place the pulled dump ready for replacing in/database/remote/wordpress.sql
. Note that this could be very heavy process, so do it with care.make db-replace
: Backups current database and replaces it withdatabase/remote/wordpress.sql
dump if there is one.make db-replace-clone
: Shorcut formake db-pull
&make db-replace
make db-clean
: Cleans up dumps fromdatabase/local
anddatabase/remote
to save disk spacemake db-commit
: Creates dump todatabase/wordpress.sql
from your local database. Idea here is to update database to git for other developers to use. Make sure everything works fine before doing this and then commit the new dumpmake db-reset
: Reset your local database by replacing it withdatabase/wordpress.sql
make replace-special-characters
: Replace common invalid characters in database with WP-CLI (ä
->ä
etc.)make regenerate-thumbnails
: Regenerate WordPress thumbnails with WP-CLIs
Be careful with the remote commands or you may break the server configuration. You need SSH access to use remote commands.
make production-db-replace-clone
: Creates dump of your local database and replaces production database with the newly created dumpmake production-update
: Update WordPress Composer dependencies. Note that if you have private repositories, you need to configure SSH key pair with the server and git remote.make production-assets-push
: Push your local assets to the production servermake production-theme-deploy
: Wrapper command for deploying thememake production-deploy
: Deploy and update everything. Shorcut formake production-update
&make production-theme-deploy
.
Install WordPress and plugins to the production server. This is most likely required only once, so be careful not to reinstall accidentally. You may want to:
- Deploy your theme first
- Add production database credentials and unique keys and salts temporarily in wp/wp-config.php so they can copied to the server (Do not commit)
make production-db-replace-clone
: Replace remote database with your local one. Make sure the database name matches with the remote in.env.local
(PRODUCTION_DB_NAME
).make production-assets-push
to sync your local materials to the server
If you want to add new new server environments you need to modify flightplan.remote.js, flightplan.config.js, Makefile, package.json and .env files.
You need to have define('WP_ENVIRONMENT_TYPE', 'production');
in wp-config.php to preview the production version locally. Alternatively you can add ?production
to the url to preview the production version. Note that .env.development is also loaded in preview but with lower priority than .env.production.
- Make sure you have SSH access to the remove server
- Add PRODUCTION_SSH
- Run
npm run deploy
which runs the shipit deployment script. Note that the shipit deployment runs locally but checks the latest commit from the git remote which it will then deploy. - Sync possible ACF fields after the deployment
- Change
DEVELOPMENT_URL
in .env.local to match your LAN address (e.g.DEVELOPMENT_URL=http://192.168.1.190:8000
) and restart Docker - Change
VITE_HOST
andVITE_DEVELOPMENT_HOST
in .env.local to match your LAN address (e.gVITE_DEVELOPMENT_HOST=http://192.168.1.190:8000
,VITE_HOST=http://192.168.1.190:5173
) - Start Vite dev server
npm run dev
and navigate to theVITE_DEVELOPMENT_HOST
you defined
You may learn more about the project at Rebirth.