Skip to content

Commit

Permalink
Merge branch 'release/2.2.2' into craft-webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Welch committed Mar 18, 2020
2 parents 6e13043 + 8cb34e3 commit e93acbb
Show file tree
Hide file tree
Showing 13 changed files with 2,256 additions and 48 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# nystudio107/craft Change Log

## 2.2.2 - 2020.03.18
### Added
* Added `seed_db.sql` to seed the initial database

### Changed
* Numerous setup changes/tweaks

## 2.2.1 - 2020.03.17
### Changed
* Switch base config setup to MariaDB instead of Postgres
Expand Down
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ This is an alternate scaffolding package for Craft 3 CMS projects to Pixel & Ton

The project is based on [Craft CMS](https://CraftCMS.com) using a unique `templates/_boilerplate` system for web/AJAX/AMP pages, and implements a number of technologies/techniques:

* [Docker](https://www.docker.com/) Docker is used for local development; see **Setting Up Local Dev** below for details
* A base Twig templating setup as described in [An Effective Twig Base Templating Setup](https://nystudio107.com/blog/an-effective-twig-base-templating-setup)
* [webpack](https://webpack.js.org/) is used for the build system as per [An Annotated webpack 4 Config for Frontend Web Development](https://nystudio107.com/blog/an-annotated-webpack-4-config-for-frontend-web-development)
* [VueJS](https://vuejs.org/) is used for some of the interactive bits on the website as per
* [Tailwind CSS](https://tailwindcss.com/) for the site-wide CSS
* JSON-LD structured data as per [Annotated JSON-LD Structured Data Examples](https://nystudio107.com/blog/annotated-json-ld-structured-data-examples)
* [Google AMP](https://developers.google.com/amp/) versions of the podcast episode and other pages
* Static assets are stored in AWS S3 buckets with CloudFront as the CDN, as per the [Setting Up AWS S3 Buckets + CloudFront CDN for your Assets](https://nystudio107.com/blog/using-aws-s3-buckets-cloudfront-distribution-with-craft-cms) article
* Implements a Service Worker via Google's [Workbox](https://developers.google.com/web/tools/workbox/) as per [Service Workers and Offline Browsing](https://nystudio107.com/blog/service-workers-and-offline-browsing)
* Critical CSS as per [Implementing Critical CSS on your website](https://nystudio107.com/blog/implementing-critical-css)
* Frontend error handling as per [Handling Errors Gracefully in Craft CMS](https://nystudio107.com/blog/handling-errors-gracefully-in-craft-cms)
Expand Down Expand Up @@ -46,25 +48,34 @@ Make sure that `PATH` is the path to your project, including the name you want f

## Setting Local Dev

You'll need Docker desktop for your platform installed to run devMode in local development
You'll need Docker desktop for your platform installed to run the project in local development

* Set up a `.env` file in the `cms/` directory, based off of the provided `example.env`
* Set up a `.env.sh.` file in the `scripts/` directory, based off of the provided `example.env.sh`
* Start up the site with `docker-composer up` (the first build will be somewhat lengthy)
* Import the remote db the first time from the `scripts/` dir with `./docker_pull_db.sh`
* On the first time setting it up, the `craft_php_1` container will fail; this is normal
* Import the `seed_db.sql` database dump the first time from the `scripts/` dir with `./docker_restore)db.sh seed_db.sql`
* Then hit ^C (Control-C) to stop the Docker containers, and restart them with `docker-compose up` and `craft_php_1` should then work properly, since the db has been seeded
* Navigate to `http://localhost:8000` to use the site; the `webpack-dev-server` runs off of `http://localhost:8080`

**N.B.:** Without authorization & credentials (which are private), the `./docker_pull_db.sh` will not work. It's provided here for instructional purposes, and for devMode.fm hosts
The CP login credentials are initially set as follows:

Login: `[email protected]`
Password: `letmein`

Obviously change these to whatever you like as needed

**N.B.:** Without authorization & credentials (which are private), the `./docker_pull_db.sh` will not work. It's provided here for instructional purposes

To update to the latest Composer packages (as constrained by the `cms/composer.json` semvers), do:
```
rm cms/composer.lock
docker-compose up
```

To update to the latest npm packages (as constrained by the `docker-config/webpack-dev-devmode/package.json` semvers), do:
To update to the latest npm packages (as constrained by the `docker-config/webpack-dev-craft/package.json` semvers), do:
```
rm docker-config/webpack-dev-devmode/package-lock.json
rm docker-config/webpack-dev-craft/package-lock.json
docker-compose up
```

Expand Down
13 changes: 8 additions & 5 deletions cms/config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@
* Edit this file at your own risk!
*
* The array returned by this file will get merged with
* vendor/craftcms/cms/src/config/app.php and app.[web|console].php, when
* vendor/craftcms/cms/src/config/app/main.php and [web|console].php, when
* Craft's bootstrap script is defining the configuration for the entire
* application.
*
* You can define custom modules and system components, and even override the
* built-in system components.
*
* If you want to modify the application config for *only* web requests or
* *only* console requests, create an app.web.php or app.console.php file in
* your config/ folder, alongside this one.
*/

return [
Expand All @@ -37,11 +33,18 @@
'cache' => [
'class' => yii\redis\Cache::class,
'redis' => [
'hostname' => getenv('REDIS_HOSTNAME'),
'port' => getenv('REDIS_PORT'),
'database' => getenv('REDIS_CRAFT_DB'),
],
],
'session' => [
'class' => \yii\redis\Session::class,
'redis' => [
'hostname' => getenv('REDIS_HOSTNAME'),
'port' => getenv('REDIS_PORT'),
'database' => getenv('REDIS_CRAFT_DB'),
],
'as session' => [
'class' => \craft\behaviors\SessionBehavior::class,
],
Expand Down
69 changes: 38 additions & 31 deletions cms/example.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,50 @@
ALLOW_UPDATES=1
ALLOW_ADMIN_CHANGES=1
BACKUP_ON_UPDATE=0
DEV_MODE=0
ENABLE_TEMPLATE_CACHING=1
ENVIRONMENT="dev"
DEV_MODE=1
ENABLE_TEMPLATE_CACHING=0
ENVIRONMENT=dev
IS_SYSTEM_LIVE=1
RUN_QUEUE_AUTOMATICALLY=1
SECURITY_KEY=""
SITE_NAME=""
SECURITY_KEY=
SITE_NAME=

# Craft database settings
DB_DRIVER="mysql"
DB_SERVER="mariadb"
DB_USER="project"
DB_PASSWORD="project"
DB_DATABASE="project"
DB_SCHEMA="public"
DB_TABLE_PREFIX=""
DB_PORT=""
DB_DRIVER=mysql
DB_SERVER=mariadb
DB_USER=project
DB_PASSWORD=project
DB_DATABASE=project
DB_SCHEMA=public
DB_TABLE_PREFIX=
DB_PORT=

# URL & path settings
ASSETS_URL=""
SITE_URL=""
WEB_ROOT_PATH=""
ASSETS_URL=http://localhost:8000
SITE_URL=http://localhost:8000
WEB_ROOT_PATH=/var/www/project/cms/web

# Craft & Plugin Licenses
LICENSE_KEY=
PLUGIN_RETOUR_LICENSE=
PLUGIN_SEOMATIC_LICENSE=
PLUGIN_TRANSCODER_LICENSE=
PLUGIN_WEBPERF_LICENSE=

# S3 settings
S3_KEY_ID=""
S3_SECRET=""
S3_BUCKET=""
S3_REGION=""
S3_SUBFOLDER=""
S3_KEY_ID=
S3_SECRET=
S3_BUCKET=
S3_REGION=
S3_SUBFOLDER=

# CloudFront settings
CLOUDFRONT_URL=""
CLOUDFRONT_DISTRIBUTION_ID=""
CLOUDFRONT_PATH_PREFIX=""
CLOUDFRONT_URL=
CLOUDFRONT_DISTRIBUTION_ID=
CLOUDFRONT_PATH_PREFIX=

# Redis settings
REDIS_HOSTNAME="localhost"
REDIS_HOSTNAME=redis
REDIS_PORT=6379
REDIS_DEFAULT_DB=0
REDIS_CRAFT_DB=1
Expand All @@ -52,15 +59,15 @@ DEVSERVER_PORT=8080
DEVSERVER_HTTPS=0

# Twigpack settings
TWIGPACK_DEV_SERVER_MANIFEST_PATH="http://localhost:8080/"
TWIGPACK_DEV_SERVER_PUBLIC_PATH="http://localhost:8080/"
TWIGPACK_DEV_SERVER_MANIFEST_PATH=http://webpack:8080/
TWIGPACK_DEV_SERVER_PUBLIC_PATH=http://webpack:8080/

# Disqus settings
DISQUS_PUBLIC_KEY=""
DISQUS_SECRET_KEY=""
DISQUS_PUBLIC_KEY=
DISQUS_SECRET_KEY=

# Google Analytics settings
GA_TRACKING_ID=""
GA_TRACKING_ID=

# FastCGI Cache Bust settings
FAST_CGI_CACHE_PATH=""
FAST_CGI_CACHE_PATH=
3 changes: 3 additions & 0 deletions cms/web/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
Dotenv\Dotenv::create(CRAFT_BASE_PATH)->load();
}

// Set license key via .env
define('CRAFT_LICENSE_KEY', getenv('LICENSE_KEY'));

// Load and run Craft
define('CRAFT_ENVIRONMENT', getenv('ENVIRONMENT') ?: 'production');
$app = require CRAFT_VENDOR_PATH.'/craftcms/cms/bootstrap/web.php';
Expand Down
3 changes: 1 addition & 2 deletions docker-config/php-dev-craft/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ RUN apt-get update \
&& \
# Install PHP extensions
docker-php-ext-install \
pdo_pgsql \
pgsql \
pdo_mysql \
&& \
# Install Composer
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer
Expand Down
3 changes: 3 additions & 0 deletions docker-config/webpack-dev-craft/webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ const configurePostcssLoader = (buildType) => {
{
loader: 'postcss-loader',
options: {
config: {
path: path.resolve(__dirname),
},
sourceMap: true
}
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/docker_pull_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ function pull_pgsql_ssh() {
copy_db_dump_locally
}
function restore_local_from_remote_mysql() {
${DB_ZCAT_CMD} "${TMP_DB_PATH}.gz" | docker exec -i devmode_postgres_1 ${LOCAL_MYSQL_CMD} ${LOCAL_DB_CREDS}
${DB_ZCAT_CMD} "${TMP_DB_PATH}.gz" | docker exec -i ${LOCAL_DB_CONTAINER} ${LOCAL_MYSQL_CMD} ${LOCAL_DB_CREDS}
echo "*** Restored docker MySQL database from ${TMP_DB_PATH}.gz"
}
function restore_local_from_remote_pgsql() {
${DB_ZCAT_CMD} "${TMP_DB_PATH}.gz" | docker exec -i devmode_postgres_1 ${LOCAL_PSQL_CMD} --output /dev/null --quiet ${LOCAL_DB_CREDS}
${DB_ZCAT_CMD} "${TMP_DB_PATH}.gz" | docker exec -i ${LOCAL_DB_CONTAINER} ${LOCAL_PSQL_CMD} --output /dev/null --quiet ${LOCAL_DB_CREDS}
echo "*** Restored docker Postgres database from ${TMP_DB_PATH}.gz"
}

Expand Down
4 changes: 2 additions & 2 deletions scripts/docker_restore_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ esac
# Functions
function restore_local_from_dump_mysql() {
# Restore the local db from the passed in db dump
$CAT_CMD "${SRC_DB_PATH}" | docker exec -i devmode_postgres_1 ${LOCAL_MYSQL_CMD} ${LOCAL_DB_CREDS}
$CAT_CMD "${SRC_DB_PATH}" | docker exec -i ${LOCAL_DB_CONTAINER} ${LOCAL_MYSQL_CMD} ${LOCAL_DB_CREDS}
echo "*** Restored docker MySQL database from ${SRC_DB_PATH}"
}
function restore_local_from_dump_pgsql() {
# Restore the local db from the passed in db dump
$CAT_CMD "${SRC_DB_PATH}" | docker exec -i devmode_postgres_1 ${LOCAL_PSQL_CMD} --output /dev/null --quiet ${LOCAL_DB_CREDS}
$CAT_CMD "${SRC_DB_PATH}" | docker exec -i ${LOCAL_DB_CONTAINER} ${LOCAL_PSQL_CMD} --output /dev/null --quiet ${LOCAL_DB_CREDS}
echo "*** Restored docker Postgres database from ${SRC_DB_PATH}"
}

Expand Down
4 changes: 4 additions & 0 deletions scripts/example.env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
# The database driver for this Craft install ('mysql' or 'pgsql')
GLOBAL_DB_DRIVER="mysql"

# -- LOCAL settings --

LOCAL_DB_CONTAINER="REPLACE_ME"

# -- REMOTE settings --

# Remote ssh credentials, [email protected] and Remote SSH Port
Expand Down
Loading

0 comments on commit e93acbb

Please sign in to comment.