├── wp-cli.yml ├── config ├── environments │ ├── development.php │ ├── staging.php │ └── production.php └── application.php ├── package.json ├── .env.lando ├── .lando.example ├── README-SITE.md ├── .gitignore ├── composer.json ├── setup ├── .gitlab-ci.yml └── README.md /wp-cli.yml: -------------------------------------------------------------------------------- 1 | path: web/wp 2 | -------------------------------------------------------------------------------- /config/environments/development.php: -------------------------------------------------------------------------------- 1 | load(); 21 | $dotenv->required(['DB_NAME', 'DB_USER', 'DB_PASSWORD', 'WP_HOME', 'WP_SITEURL']); 22 | } 23 | 24 | /** 25 | * Set up our global environment constant and load its config first 26 | * Default: production 27 | */ 28 | define('WP_ENV', env('WP_ENV') ?: 'production'); 29 | 30 | $env_config = __DIR__ . '/environments/' . WP_ENV . '.php'; 31 | 32 | if (file_exists($env_config)) { 33 | require_once $env_config; 34 | } 35 | 36 | /** 37 | * URLs 38 | */ 39 | define('WP_HOME', env('WP_HOME')); 40 | define('WP_SITEURL', env('WP_SITEURL')); 41 | 42 | /** 43 | * Custom Content Directory 44 | */ 45 | define('CONTENT_DIR', '/app'); 46 | define('WP_CONTENT_DIR', $webroot_dir . CONTENT_DIR); 47 | define('WP_CONTENT_URL', WP_HOME . CONTENT_DIR); 48 | 49 | /** 50 | * DB settings 51 | */ 52 | define('DB_NAME', env('DB_NAME')); 53 | define('DB_USER', env('DB_USER')); 54 | define('DB_PASSWORD', env('DB_PASSWORD')); 55 | define('DB_HOST', env('DB_HOST') ?: 'localhost'); 56 | define('DB_CHARSET', 'utf8mb4'); 57 | define('DB_COLLATE', ''); 58 | 59 | $table_prefix = env('DB_PREFIX') ?: 'wp_'; 60 | 61 | /** 62 | * Custom Settings 63 | */ 64 | define('AUTOMATIC_UPDATER_DISABLED', true); 65 | define('DISABLE_WP_CRON', env('DISABLE_WP_CRON') ?: false); 66 | define('DISALLOW_FILE_EDIT', true); 67 | 68 | /** 69 | * Bootstrap WordPress 70 | */ 71 | if (!defined('ABSPATH')) { 72 | define('ABSPATH', $webroot_dir . '/wp/'); 73 | } -------------------------------------------------------------------------------- /setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | printf "\n" 3 | echo "**********************************" 4 | echo "** Obsidian WordPress Installer **" 5 | echo "**********************************" 6 | 7 | if [ -f .lando.yml ]; then 8 | printf "\nA .lando.yml file already exists in this directory. Please delete all files and containers from the previous installation if you want to start over.\n\n" 9 | exit 10 | fi 11 | 12 | printf "\n1. Enter the lando site local subdomain Name (it will generate url http://your-subdomain.lndo.site):\n" 13 | read -e sitename 14 | 15 | printf "\n2. Enter your WordPress username:\n" 16 | read -e username 17 | 18 | printf "\n3. Enter your WordPress password:\n" 19 | read -e password 20 | 21 | printf "\n4. Enter your WordPress user email address:\n" 22 | read -e email 23 | 24 | printf "\nOk! Time to setup your new WordPress website!\n\n" 25 | 26 | # Site local url 27 | url="http://$sitename.lndo.site" 28 | 29 | # Generate .lando.yml file 30 | cp .lando.example .lando.yml 31 | sed -i -e "s/demosite/$sitename/g" .lando.yml 32 | 33 | # Start up the site 34 | lando start 35 | 36 | # Install dependencies 37 | lando composer install 38 | 39 | # Copy and adjust the env file 40 | cp .env.lando .env 41 | sed -i -e "s#demosite#$url#g" .env 42 | 43 | # Install WordPress 44 | lando wp core install --url="$url" --title="$sitename" --admin_user="$username" --admin_password="$password" --admin_email="$email" 45 | 46 | # Replace obisian readme with site specific readme (only with lando start info) 47 | rm README.md 48 | mv README-SITE.md README.md 49 | 50 | # Remove .git directory, this is now a standalone project, no need for obsidian repo info 51 | rm -rf .git 52 | 53 | # TODO pick a default theme, add it to composer.json and activate it here 54 | # lando wp theme activate DEFAULT_THEME_HERE 55 | 56 | # Install the node modules. 57 | # npm i 58 | # TODO Setup Default Theme 59 | # cd web/app/themes/DEFAULT_THEME_HERE && lando npm i && lando gulp 60 | 61 | printf "\nYour new WordPress site is ready!.\n" 62 | echo "Username: $username" 63 | echo "Password: $password" 64 | echo "Email: $email" -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | # Instructions: 2 | # - set 'SSH_PASS' as secret variable on the repository (url: https://gitlab.com/USERNAME/REPOSITORY_NAME/settings/ci_cd ) 3 | # - set the appropriate values for the variables defined in this yaml file 4 | # - enjoy! 5 | variables: 6 | SSH_USER: DEFINE_ME # e.g. "project_ssh_user" 7 | SSH_HOST: DEFINE_ME # e.g. "project.com" 8 | STAGING_DIR: DEFINE_ME # e.g. "staging.project.com" 9 | PRODUCTION_DIR: DEFINE_ME # e.g. "httpdocs" 10 | THEME_DIR: DEFINE_ME # e.g. "project-theme" 11 | 12 | stages: 13 | - build 14 | - deploy 15 | 16 | download_composer_dependencies: 17 | stage: build 18 | image: php:7.0 19 | only: 20 | - staging 21 | - master 22 | artifacts: 23 | untracked: true 24 | script: 25 | - apt-get -qq -y update && apt-get -qq -y install wget zip git 26 | - wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > installer.sig 27 | - php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" 28 | - php -r "if (hash_file('SHA384', 'composer-setup.php') === file_get_contents('installer.sig')) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" 29 | - php composer-setup.php 30 | - php -r "unlink('composer-setup.php'); unlink('installer.sig');" 31 | - php composer.phar install --no-ansi --no-dev --no-interaction --no-progress --optimize-autoloader --no-scripts 32 | 33 | build_theme: 34 | stage: build 35 | image: node:6.10.3 36 | only: 37 | - staging 38 | - master 39 | artifacts: 40 | untracked: true 41 | script: 42 | - cd "web/app/themes/$THEME_DIR" 43 | - npm config set loglevel warn 44 | - npm install && npm install -g bower && npm install -g gulp && bower install --allow-root && gulp --production 45 | 46 | deploy_staging: 47 | stage: deploy 48 | image: ubuntu:latest 49 | only: 50 | - staging 51 | script: 52 | - apt-get -qq -y update && apt-get -qq -y install sshpass rsync 53 | - rm -rf .bundle 54 | - rm composer.phar 55 | - rm -rf "web/app/uploads" 56 | - ln -s ../shared/staging/.env .env 57 | - ln -s ../../../shared/staging/uploads web/app/uploads 58 | - sshpass -p "$SSH_PASS" rsync --delete --exclude web/.htaccess -rzl -e 'ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' . $SSH_USER@$SSH_HOST:$STAGING_DIR 59 | 60 | deploy_production: 61 | stage: deploy 62 | image: ubuntu:latest 63 | only: 64 | - master 65 | script: 66 | - apt-get -qq -y update && apt-get -qq -y install sshpass rsync 67 | - rm -rf .bundle 68 | - rm composer.phar 69 | - rm -rf "web/app/uploads" 70 | - ln -s ../shared/production/.env .env 71 | - ln -s ../../../shared/production/uploads web/app/uploads 72 | - sshpass -p "$SSH_PASS" rsync --delete --exclude web/.htaccess -rzl -e 'ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' . $SSH_USER@$SSH_HOST:$PRODUCTION_DIR -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Obsidian — A WordPress Starter Kit For The Modern Web 2 | 3 | *Please note: this project is a work in progress. The CI script is customised around my personal needs and would require you to update it in order to fit yours. I have no reliable timeline for it, but I do plan to standardise Obsidian to the point that most people can not only use it to quickly setup a local development environment, but to also be able to deploy via SSH/RSYNC or SFTP to any server of their choosing.* 4 | 5 | Obsidian is a WordPress starter kit that allows you to easily provision local development environments and setup CI/CD for WordPress websites. This project is based on: 6 | 7 | * **[Bedrock](https://github.com/roots/bedrock):** a WordPress boilerplate which turns WordPress into a [12 Factor App](https://12factor.net/). 8 | * **[Lando](https://docs.devwithlando.io/):** a Docker based local development environment that you can provision through a simple `.lando.yml` file, in a similar way to what's done for services like Travis CI. 9 | * **[GitLab CI](https://about.gitlab.com/features/gitlab-ci-cd/):** The CI/CD pipelines service from GitLab, i.e. if you want to use this starter kit as is, you must host your repository on GitLab or at least have a GitLab remote you push to for your CI/CD needs. 10 | 11 | ## How to Start a New Project With Obsidian 12 | 13 | Before diving into Obsidian, make sure you have [Docker](https://www.docker.com/community-edition#/download) and [Lando](https://docs.devwithlando.io/installation/installing.html) installed. 14 | 15 | Once that's done, clone this repository and run the `npm run setup` command inside the repository directory. 16 | 17 | This will let you setup the project directly through command line by taking your input and then generating the `.lando.yml` file, creating and starting the docker containers, downloading the dependencies, initialising the database etc. 18 | 19 | Once this process is completed, your local WordPress website will be available at the `subdomain.lndo.site` address you specified during the setup (`.lndo.site` is static, you get to pick the subdomain). 20 | 21 | ## How to Stop and Start an existing Obsidian Project 22 | 23 | To stop a running project, run this command inside the project's directory: 24 | 25 | ``` 26 | lando stop 27 | ``` 28 | 29 | To start the project again, run this command inside the project's directory: 30 | 31 | ``` 32 | lando start 33 | ``` 34 | 35 | If you want to know more about what you can do with Lando, read the [documentation](https://docs.devwithlando.io/). 36 | 37 | ## Did You See Red URLs? A Note on DNS Rebinding 38 | 39 | This is taken directly from the Lando documentation you can find [here](https://docs.devwithlando.io/issues/dns-rebind.html). 40 | 41 | If you are using Lando proxying (which is enabled by default) some Routers and Firewalls may prevent Lando from properly routing yourapp.lndo.site to your local environment through DNS Rebinding protection. DD-WRT router firmware enables this protection by default. 42 | 43 | If you are seeing failed URLs (they show up in red) after app start up and you are unable to look up the url (nslookup .lndo.site), DNS rebinding protection may be the cause. We recommend you consult your router documentation or system administrator to whitelist *.lndo.site domains. 44 | 45 | If you can't or don't want to remove this protection, you can alternatively: 46 | 47 | * Use the steps in Working Offline to bypass. 48 | * Disable proxying and rely on the Lando produced localhost address. 49 | 50 | ### DD-WRT Solution 51 | 52 | If you use DNSMasq on the DD-WRT firmrware: 53 | 54 | 1. Open the services page of the DD-WRT administration panel 55 | 2. Go to the "Additional DNSMasq Options" section 56 | 3. Add the following line in the textarea `rebind-domain-ok=/lndo.site/` 57 | 58 | If you already had the rebind-domain-ok line for other domains, you can add multiple ones like this: 59 | 60 | `rebind-domain-ok=/domain1.com/domain2.com/domain3.com/` 61 | 62 | # Credits 63 | 64 | As mentioned in the introduction, this project is just an aggregator of other people's work with a few modifications and extra things added by me. Here's a list of people you should thank if you end up using Obsidian: 65 | 66 | * **[The Roots team](https://roots.io/):** they are the authors of the Bedrock WordPress boilerplate. 67 | * **[The ThinkTandem team](https://thinktandem.io/):** the authors of Lando. Also, the setup script triggered by the `npm run setup` is a slightly modified version of a script available in their [WP-Boilerplate](github.com/thinktandem/wp-boilerplate). I created Obsidian when I stumbled upon Lando and their WP-Boilerplate and wanted to have a version of all that to work with my own default plugins/theme and CI/CD setup. 68 | * **Plugin Authors:** take the time to see who makes the plugins I use in this starter kit, each developer/team behind them deserves a huge thanks for making them available to everyone for free. 69 | * **[The GitLab team](https://gitlab.com/):** the pipelines feature is awesome and available to everyone for free even for private repositories. 70 | 71 | #### Why Is it Called Obsidian? 72 | 73 | The biggest piece of this starter kit is the `Bedrock` WordPress boilerplate, which I assume was named after "*the lithified rock that lies under a loose softer material called regolith at the surface of the Earth or other terrestrial planets*". Since Obsidian is "*a naturally occurring volcanic glass formed as an extrusive igneous rock*", i.e. a rock that I think is [a lot cooler](http://awoiaf.westeros.org/index.php/Dragonglass), I just named after it to keep the rocks theme going. 74 | --------------------------------------------------------------------------------