Skip to content

AlsaceDigitale/nec-strasbourg-2022

Repository files navigation

Scalingo 12-Factor WordPress Distribution

Features

Based on Bedrock

  • Better folder structure
  • Dependency management with Composer and WordPress Packagist
  • Easy WordPress configuration with environment specific files
  • Environment variables with Dotenv
  • Autoloader for mu-plugins (use regular plugins as mu-plugins)
  • Enhanced security (separated web root and secure passwords with wp-password-bcrypt)

With few more features added by Scalingo:

  • Configurable from var environment
  • File Uploads sent to S3 Bucket by default with S3-Uploads plugin

Actual WordPress version : 5.5

Installation

The variables S3_UPLOADS_BUCKET, S3_UPLOADS_KEY, S3_UPLOADS_SECRET, S3_UPLOADS_REGION are not required when you don't want to use the WordPress image upload with S3.

In reverse, if you activate the already preinstalled S3 plugin you must specify these variables.

By default, the AWS endpoint (s3.amazonaws.com) is used.

Use Another Object Storage Provider

If you want to use another provider than AWS for your S3 bucket, you must use the environment variable named S3_UPLOADS_ENDPOINT to specify your provider URL.

Example with Scaleway provider:

S3_UPLOADS_ENDPOINT=s3.fr-par.scw.cloud

Override the Bucket URL

If you want to specify the full URL of the bucket yourself or even specify a specific folder where your uploads will go, you may must use the environment variable named S3_UPLOADS_BUCKET_URL.

Examples with Scaleway provider:

S3_UPLOADS_BUCKET_URL=your-bucket-name.s3.fr-par.scw.cloud

Example to upload the files in a specific folder:

S3_UPLOADS_BUCKET_URL=your-bucket-name.s3.fr-par.scw.cloud/wordpress/uploads

One-click installation

Deploy to Scalingo

Manual installation

  1. Clone this distribution
git clone https://github.com/Scalingo/scalingo-wordpress
cd scalingo-wordpress
  1. Use Scalingo CLI for create the app and add mysql addon
scalingo create my-wordpress
scalingo addons-add mysql mysql-sandbox
  1. Create an S3 Bucket on AWS and configure IAM user correctly (only if you want to use image upload with S3)

IAM user security policy example:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": [
        "s3:PutObject",
        "s3:PutObjectAcl",
        "s3:PutObjectAclVersion",
        "s3:AbortMultipartUpload",
        "s3:ListBucket",
        "s3:GetObject"
      ],
      "Effect": "Allow",
      "Resource": "arn:aws:s3:::bucketname-here"
    },
    {
      "Action": [
        "s3:PutObject",
        "s3:PutObjectAcl",
        "s3:PutObjectAclVersion",
        "s3:AbortMultipartUpload",
        "s3:ListBucket",
        "s3:GetObject"
      ],
      "Effect": "Allow",
      "Resource": "arn:aws:s3:::bucketname-here/*"
    }
  ]
}
  1. Update the application environment through the dashboard or with the Scalingo command line scalingo env-set VARIABLE_NAME=VALUE
  • DATABASE_URL - Connection string to the MySQL database - mysql://localhost:3306/wp-bedrock - Automatically added with the Scalingo MySQL addon
  • WP_ENV - Set to environment (development, staging, production) (required)
  • WP_HOME - Full URL to WordPress home (http://my-wordpress.scalingo.io) (required)
  • WP_SITEURL - Full URL to WordPress including subdirectory (http://my-wordpress.scalingo.io/wp) (required)
  • S3_UPLOADS_BUCKET - Name of the S3 bucket to upload files to (optional)
  • S3_UPLOADS_KEY - AWS Access Key ID for S3 authentication (optional)
  • S3_UPLOADS_SECRET - AWS Secret Key for S3 authentication (optional)
  • S3_UPLOADS_REGION - Region of the S3 bucket (optional)
  • AUTH_KEY, SECURE_AUTH_KEY, LOGGED_IN_KEY, NONCE_KEY, AUTH_SALT, SECURE_AUTH_SALT, LOGGED_IN_SALT, NONCE_SALT

You can get some random salts on the [Roots WordPress Salt Generator][roots-wp-salt].

  1. Add theme(s) in web/app/themes as you would for a normal WordPress site.

  2. Deploy the application on Scalingo

# Optionally add theme to your git repository
git add web/app/themes
git commit -m "Add themes"

# Then push to Scalingo
git push scalingo master
  1. Access WP admin at https://my-wordpress.scalingo.io/wp/wp-admin

  2. Activate S3 Uploads plugin on WordPress plugin page at https://my-wordpress.scalingo.io/wp/wp-admin/plugins.php

Use in Development

Requirements

Updating WordPress version

Update package.json to update the WordPress branch you need.

Then run:

> docker-compose run --rm web composer update

Run locally to test WordPress is working, then commit composer.json and composer.lock.

Run locally

A Docker Compose file is available to run the WordPress locally. You first need to install the dependencies with:

docker-compose run --rm composer install --prefer-source --no-interaction --ignore-platform-reqs

Then start the Nginx:

docker-compose up nginx

Install Wordpress Plugin

Simple command for install plugins:

docker-compose run --rm composer require --ignore-platform-reqs wpackagist-plugin/{PLUGIN_NAME}

You can find plugins on Wordpress Packagist

Example to install akismet plugin:

docker-compose run --rm composer require --ignore-platform-reqs wpackagist-plugin/akismet

Install Wordpress Theme

Simple command for install themes:

docker-compose run --rm composer require --ignore-platform-reqs wpackagist-theme/{THEME_NAME}

You can find themes on Wordpress Packagist

Example to install hueman theme:

docker-compose run --rm composer require --ignore-platform-reqs wpackagist-theme/hueman

Documentation

Bedrock documentation is available at https://roots.io/bedrock/docs.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published