├── templates ├── .gitkeep └── index.twig ├── .docker-config ├── mysql │ └── Dockerfile ├── nginx │ ├── Dockerfile │ └── default.conf ├── spin-up-craft-base │ ├── php-8.0-alpine │ │ ├── build_and_push.sh │ │ └── Dockerfile │ ├── php-8.1-alpine │ │ ├── build_and_push.sh │ │ └── Dockerfile │ └── php-8.2-alpine │ │ ├── build_and_push.sh │ │ └── Dockerfile ├── spin-up-craft-base-dev │ ├── php-8.0-alpine │ │ ├── build_and_push.sh │ │ └── Dockerfile │ ├── php-8.1-alpine │ │ ├── build_and_push.sh │ │ └── Dockerfile │ └── php-8.2-alpine │ │ ├── build_and_push.sh │ │ └── Dockerfile └── php │ ├── banner_message.sh │ ├── composer_install.sh │ ├── Dockerfile │ └── run_queue.sh ├── config ├── project │ ├── fieldGroups │ │ └── 31006d4c-2f40-498c-9a4c-69cff4fd4279.yaml │ ├── siteGroups │ │ └── 0d89c679-f6f5-42ae-8341-4bea917c6af7.yaml │ ├── sites │ │ └── default--f255ef6d-0c55-4bdc-9ced-f610bbb3bed6.yaml │ └── project.yaml ├── redactor │ ├── Simple.json │ └── Default.json ├── license.key ├── htmlpurifier │ └── Default.json ├── routes.php ├── app.php └── general.php ├── web ├── index.php ├── .htaccess └── web.config ├── craft ├── composer.json ├── bootstrap.php ├── example.env ├── docker-compose.yml ├── Makefile ├── CHANGELOG.md └── README.md /templates/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.docker-config/mysql/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM jbergstroem/mariadb-alpine:latest 2 | -------------------------------------------------------------------------------- /config/project/fieldGroups/31006d4c-2f40-498c-9a4c-69cff4fd4279.yaml: -------------------------------------------------------------------------------- 1 | name: Common 2 | -------------------------------------------------------------------------------- /config/project/siteGroups/0d89c679-f6f5-42ae-8341-4bea917c6af7.yaml: -------------------------------------------------------------------------------- 1 | name: $CRAFT_SITE_NAME 2 | -------------------------------------------------------------------------------- /config/redactor/Simple.json: -------------------------------------------------------------------------------- 1 | { 2 | "buttons": ["bold", "italic"], 3 | "toolbarFixed": true 4 | } 5 | -------------------------------------------------------------------------------- /.docker-config/nginx/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:1.19-alpine 2 | 3 | COPY ./default.conf /etc/nginx/conf.d/default.conf 4 | -------------------------------------------------------------------------------- /.docker-config/spin-up-craft-base/php-8.0-alpine/build_and_push.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Build this image, and push it to DockerHub.com 3 | 4 | docker buildx build \ 5 | --push \ 6 | --no-cache \ 7 | --platform linux/arm64/v8,linux/amd64 \ 8 | --tag nystudio107/spin-up-craft-base:8.0-alpine . 9 | -------------------------------------------------------------------------------- /.docker-config/spin-up-craft-base/php-8.1-alpine/build_and_push.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Build this image, and push it to DockerHub.com 3 | 4 | docker buildx build \ 5 | --push \ 6 | --no-cache \ 7 | --platform linux/arm64/v8,linux/amd64 \ 8 | --tag nystudio107/spin-up-craft-base:8.1-alpine . 9 | -------------------------------------------------------------------------------- /config/license.key: -------------------------------------------------------------------------------- 1 | =+*#GPV3=ZGP/WE911*5&XZ&JGCDLRSDRA7M^2JC/VXWE3E&ZG 2 | ZRY=GS3^AFR4T91ZF!DTY35T6OUU3=^UE$JXTIY7NJ&S67&297 3 | FW9Q76094HPPWWGYJ9H8GAF%F2L%F+JLAOCE7S0=CS*H1YSEJ+ 4 | X1UC%FC^6P8YZC=O=+FU3%GS$SOLI#6C3MPD=WWP+^$&043^QX 5 | O^H2//Y+3&PUC&5ZRXE6BI7=EY06C8#F9/JYZP5JW5FYUCQ3T2 6 | -------------------------------------------------------------------------------- /.docker-config/spin-up-craft-base-dev/php-8.0-alpine/build_and_push.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Build this image, and push it to DockerHub.com 3 | 4 | docker buildx build \ 5 | --push \ 6 | --no-cache \ 7 | --platform linux/arm64/v8,linux/amd64 \ 8 | --tag nystudio107/spin-up-craft-base-dev:8.0-alpine . 9 | -------------------------------------------------------------------------------- /.docker-config/spin-up-craft-base-dev/php-8.1-alpine/build_and_push.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Build this image, and push it to DockerHub.com 3 | 4 | docker buildx build \ 5 | --push \ 6 | --no-cache \ 7 | --platform linux/arm64/v8,linux/amd64 \ 8 | --tag nystudio107/spin-up-craft-base-dev:8.1-alpine . 9 | -------------------------------------------------------------------------------- /config/project/sites/default--f255ef6d-0c55-4bdc-9ced-f610bbb3bed6.yaml: -------------------------------------------------------------------------------- 1 | baseUrl: $PRIMARY_SITE_URL 2 | enabled: true 3 | handle: default 4 | hasUrls: true 5 | language: en-US 6 | name: $CRAFT_SITE_NAME 7 | primary: true 8 | siteGroup: 0d89c679-f6f5-42ae-8341-4bea917c6af7 # $CRAFT_SITE_NAME 9 | sortOrder: 1 10 | -------------------------------------------------------------------------------- /web/index.php: -------------------------------------------------------------------------------- 1 | run(); 13 | -------------------------------------------------------------------------------- /config/htmlpurifier/Default.json: -------------------------------------------------------------------------------- 1 | { 2 | "Attr.AllowedFrameTargets": [ 3 | "_blank" 4 | ], 5 | "Attr.EnableID": true, 6 | "HTML.AllowedComments": [ 7 | "pagebreak" 8 | ], 9 | "HTML.SafeIframe": true, 10 | "URI.SafeIframeRegexp": "%^(https?:)?//(www.youtube.com/embed/|player.vimeo.com/video/)%" 11 | } 12 | -------------------------------------------------------------------------------- /config/routes.php: -------------------------------------------------------------------------------- 1 | 2 | RewriteEngine On 3 | 4 | # Send would-be 404 requests to Craft 5 | RewriteCond %{REQUEST_FILENAME} !-f 6 | RewriteCond %{REQUEST_FILENAME} !-d 7 | RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC] 8 | RewriteRule (.+) index.php?p=$1 [QSA,L] 9 | 10 | -------------------------------------------------------------------------------- /.docker-config/spin-up-craft-base-dev/php-8.2-alpine/build_and_push.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Build this image, and push it to DockerHub.com 3 | 4 | docker buildx build \ 5 | --push \ 6 | --no-cache \ 7 | --platform linux/arm64/v8,linux/amd64 \ 8 | --tag nystudio107/spin-up-craft-base-dev:8.2-alpine \ 9 | --tag nystudio107/spin-up-craft-base-dev:latest . 10 | -------------------------------------------------------------------------------- /config/redactor/Default.json: -------------------------------------------------------------------------------- 1 | { 2 | "buttons": [ 3 | "html", 4 | "formatting", 5 | "bold", 6 | "italic", 7 | "unorderedlist", 8 | "orderedlist", 9 | "link", 10 | "image", 11 | "video" 12 | ], 13 | "plugins": [ 14 | "fullscreen", 15 | "video" 16 | ], 17 | "linkNewTab": true, 18 | "toolbarFixed": true 19 | } 20 | -------------------------------------------------------------------------------- /craft: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | run(); 14 | exit($exitCode); 15 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "craftcms/cms": "^4.4.5", 4 | "vlucas/phpdotenv": "^5.4.0" 5 | }, 6 | "require-dev": { 7 | "nystudio107/craft-autocomplete": "^1.11.0" 8 | }, 9 | "autoload": { 10 | "psr-4": { 11 | "modules\\": "modules/" 12 | } 13 | }, 14 | "config": { 15 | "allow-plugins": { 16 | "craftcms/plugin-installer": true, 17 | "yiisoft/yii2-composer": true 18 | }, 19 | "sort-packages": true 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /bootstrap.php: -------------------------------------------------------------------------------- 1 | safeLoad(); 18 | } 19 | -------------------------------------------------------------------------------- /.docker-config/php/banner_message.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Banner Message shell script 4 | # 5 | # Display a banner message to let the user know the environment is ready for use 6 | # 7 | # @author nystudio107 8 | # @copyright Copyright (c) 2023 nystudio107 9 | # @link https://nystudio107.com/ 10 | # @license MIT 11 | 12 | # Rewrite the PRIMARY_SITE_URL env var if we're running in Codespaces 13 | if [[ ! ${CODESPACES:-"unset"} == "unset" ]]; then 14 | export PRIMARY_SITE_URL="https://${CODESPACE_NAME}-${DEV_SERVER_PORT}.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}/" 15 | fi 16 | # Banner message 17 | sleep 1 18 | echo "### Your Craft site is ready!" 19 | echo "Frontend URL: ${PRIMARY_SITE_URL}" 20 | echo "CP URL: ${PRIMARY_SITE_URL}admin" 21 | echo "CP User: ${CRAFT_CP_USER}" 22 | echo "CP Password: ${CRAFT_CP_PASSWORD}" 23 | -------------------------------------------------------------------------------- /.docker-config/php/composer_install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Composer Install shell script 4 | # 5 | # This shell script runs `composer install` if either the `composer.lock` file or 6 | # the `vendor/` directory is not present` 7 | # 8 | # @author nystudio107 9 | # @copyright Copyright (c) 2023 nystudio107 10 | # @link https://nystudio107.com/ 11 | # @license MIT 12 | 13 | # Ensure permissions on directories Craft needs to write to 14 | chown -R www-data:www-data /var/www/project/storage 15 | chown -R www-data:www-data /var/www/project/web/cpresources 16 | # Check for `composer.lock` & `vendor/` 17 | cd /var/www/project 18 | if [ ! -f "composer.lock" ] || [ ! -d "vendor" ] || [ ! -f "vendor/autoload.php" ]; then 19 | chown -R www-data:www-data /var/www/project 20 | su-exec www-data composer install --verbose --no-progress --no-scripts --no-interaction 21 | fi 22 | -------------------------------------------------------------------------------- /config/app.php: -------------------------------------------------------------------------------- 1 | App::env('CRAFT_APP_ID') ?: 'CraftCMS', 27 | ]; 28 | -------------------------------------------------------------------------------- /.docker-config/php/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nystudio107/spin-up-craft-base:8.2-alpine 2 | 3 | WORKDIR /var/www 4 | 5 | COPY ./run_queue.sh . 6 | RUN chmod a+x run_queue.sh \ 7 | && \ 8 | mkdir -p /var/www/project/storage \ 9 | && \ 10 | mkdir -p /var/www/project/web/cpresources \ 11 | && \ 12 | chown -R www-data:www-data /var/www/project 13 | COPY ./composer_install.sh . 14 | RUN chmod a+x composer_install.sh 15 | COPY ./banner_message.sh . 16 | RUN chmod a+x banner_message.sh 17 | 18 | WORKDIR /var/www/project 19 | 20 | # Run the composer_install.sh script that will do a `composer install`: 21 | # - If `composer.lock` is missing 22 | # - If `vendor/` is missing 23 | # ...then start up php-fpm. The `run_queue.sh` script in the queue container 24 | # will take care of running any pending migrations and apply any Project Config changes, 25 | # as well as set permissions via an async CLI process 26 | CMD /var/www/composer_install.sh \ 27 | && \ 28 | php-fpm 29 | -------------------------------------------------------------------------------- /config/project/project.yaml: -------------------------------------------------------------------------------- 1 | dateModified: 1679617195 2 | email: 3 | fromEmail: info@putyourlightson.net 4 | fromName: 'Craft Coding Challenge' 5 | transportType: craft\mail\transportadapters\Sendmail 6 | graphql: 7 | publicToken: 8 | enabled: false 9 | expiryDate: null 10 | meta: 11 | __names__: 12 | 0b13c242-c4bf-4365-b5d1-fd1fe51676d8: 'Public Schema' 13 | 0d89c679-f6f5-42ae-8341-4bea917c6af7: $CRAFT_SITE_NAME # $CRAFT_SITE_NAME 14 | 0779f354-f5d2-4f82-9a36-28a252f70ce4: 'Public Schema' # Public Schema 15 | 31006d4c-2f40-498c-9a4c-69cff4fd4279: Common # Common 16 | b55012be-3f7f-4150-b59c-5a6623c00743: 'Public Schema' # Public Schema 17 | c7c2807b-84cc-4e1f-9279-af044bc0b472: 'Public Schema' # Public Schema 18 | f255ef6d-0c55-4bdc-9ced-f610bbb3bed6: $CRAFT_SITE_NAME # $CRAFT_SITE_NAME 19 | system: 20 | edition: pro 21 | live: true 22 | name: $CRAFT_SITE_NAME 23 | retryDuration: null 24 | schemaVersion: 4.4.0.4 25 | timeZone: America/Los_Angeles 26 | users: 27 | allowPublicRegistration: false 28 | defaultGroup: null 29 | photoSubpath: null 30 | photoVolumeUid: null 31 | requireEmailVerification: true 32 | -------------------------------------------------------------------------------- /web/web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /.docker-config/spin-up-craft-base/php-8.0-alpine/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nystudio107/php-prod-base:8.0-alpine 2 | 3 | # dependencies required for running "phpize" 4 | # these get automatically installed and removed by "docker-php-ext-*" (unless they're already installed) 5 | ENV PHPIZE_DEPS \ 6 | autoconf \ 7 | dpkg-dev \ 8 | dpkg \ 9 | file \ 10 | g++ \ 11 | gcc \ 12 | libc-dev \ 13 | make \ 14 | pkgconf \ 15 | re2c \ 16 | wget 17 | 18 | # Install packages 19 | RUN set -eux; \ 20 | # Packages needed only for build 21 | apk add --no-cache --virtual .build-deps \ 22 | $PHPIZE_DEPS \ 23 | && \ 24 | # Packages to install 25 | apk add --no-cache \ 26 | su-exec \ 27 | nano \ 28 | mysql-client \ 29 | mariadb-connector-c \ 30 | && \ 31 | # Install PHP extensions 32 | docker-php-ext-install \ 33 | pdo_mysql \ 34 | soap \ 35 | && \ 36 | # Install Composer 37 | curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ 38 | && \ 39 | # Remove the build deps 40 | apk del .build-deps \ 41 | && \ 42 | # Clean out directories that don't need to be part of the image 43 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 44 | -------------------------------------------------------------------------------- /.docker-config/spin-up-craft-base/php-8.1-alpine/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nystudio107/php-prod-base:8.1-alpine 2 | 3 | # dependencies required for running "phpize" 4 | # these get automatically installed and removed by "docker-php-ext-*" (unless they're already installed) 5 | ENV PHPIZE_DEPS \ 6 | autoconf \ 7 | dpkg-dev \ 8 | dpkg \ 9 | file \ 10 | g++ \ 11 | gcc \ 12 | libc-dev \ 13 | make \ 14 | pkgconf \ 15 | re2c \ 16 | wget 17 | 18 | # Install packages 19 | RUN set -eux; \ 20 | # Packages needed only for build 21 | apk add --no-cache --virtual .build-deps \ 22 | $PHPIZE_DEPS \ 23 | && \ 24 | # Packages to install 25 | apk add --no-cache \ 26 | su-exec \ 27 | nano \ 28 | mysql-client \ 29 | mariadb-connector-c \ 30 | && \ 31 | # Install PHP extensions 32 | docker-php-ext-install \ 33 | pdo_mysql \ 34 | soap \ 35 | && \ 36 | # Install Composer 37 | curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ 38 | && \ 39 | # Remove the build deps 40 | apk del .build-deps \ 41 | && \ 42 | # Clean out directories that don't need to be part of the image 43 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 44 | -------------------------------------------------------------------------------- /.docker-config/spin-up-craft-base-dev/php-8.0-alpine/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nystudio107/php-dev-base:8.0-alpine 2 | 3 | # dependencies required for running "phpize" 4 | # these get automatically installed and removed by "docker-php-ext-*" (unless they're already installed) 5 | ENV PHPIZE_DEPS \ 6 | autoconf \ 7 | dpkg-dev \ 8 | dpkg \ 9 | file \ 10 | g++ \ 11 | gcc \ 12 | libc-dev \ 13 | make \ 14 | pkgconf \ 15 | re2c \ 16 | wget 17 | 18 | # Install packages 19 | RUN set -eux; \ 20 | # Packages needed only for build 21 | apk add --no-cache --virtual .build-deps \ 22 | $PHPIZE_DEPS \ 23 | && \ 24 | # Packages to install 25 | apk add --no-cache \ 26 | su-exec \ 27 | nano \ 28 | mysql-client \ 29 | mariadb-connector-c \ 30 | && \ 31 | # Install PHP extensions 32 | docker-php-ext-install \ 33 | pdo_mysql \ 34 | soap \ 35 | && \ 36 | # Install Composer 37 | curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ 38 | && \ 39 | # Remove the build deps 40 | apk del .build-deps \ 41 | && \ 42 | # Clean out directories that don't need to be part of the image 43 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 44 | -------------------------------------------------------------------------------- /.docker-config/spin-up-craft-base-dev/php-8.1-alpine/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nystudio107/php-dev-base:8.1-alpine 2 | 3 | # dependencies required for running "phpize" 4 | # these get automatically installed and removed by "docker-php-ext-*" (unless they're already installed) 5 | ENV PHPIZE_DEPS \ 6 | autoconf \ 7 | dpkg-dev \ 8 | dpkg \ 9 | file \ 10 | g++ \ 11 | gcc \ 12 | libc-dev \ 13 | make \ 14 | pkgconf \ 15 | re2c \ 16 | wget 17 | 18 | # Install packages 19 | RUN set -eux; \ 20 | # Packages needed only for build 21 | apk add --no-cache --virtual .build-deps \ 22 | $PHPIZE_DEPS \ 23 | && \ 24 | # Packages to install 25 | apk add --no-cache \ 26 | su-exec \ 27 | nano \ 28 | mysql-client \ 29 | mariadb-connector-c \ 30 | && \ 31 | # Install PHP extensions 32 | docker-php-ext-install \ 33 | pdo_mysql \ 34 | soap \ 35 | && \ 36 | # Install Composer 37 | curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ 38 | && \ 39 | # Remove the build deps 40 | apk del .build-deps \ 41 | && \ 42 | # Clean out directories that don't need to be part of the image 43 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 44 | -------------------------------------------------------------------------------- /example.env: -------------------------------------------------------------------------------- 1 | # Read about configuration, here: 2 | # https://craftcms.com/docs/4.x/config/ 3 | 4 | # The application ID used to to uniquely store session and cache data, mutex locks, and more 5 | CRAFT_APP_ID= 6 | 7 | # The environment Craft is currently running in (dev, staging, production, etc.) 8 | CRAFT_ENVIRONMENT=dev 9 | 10 | # The secure key Craft will use for hashing and encrypting data 11 | CRAFT_SECURITY_KEY= 12 | 13 | # Database connection settings 14 | CRAFT_DB_DRIVER=mysql 15 | CRAFT_DB_SERVER=mysql 16 | CRAFT_DB_PORT=3306 17 | CRAFT_DB_DATABASE=project 18 | CRAFT_DB_USER=project 19 | CRAFT_DB_PASSWORD=project 20 | CRAFT_DB_SCHEMA= 21 | CRAFT_DB_TABLE_PREFIX= 22 | 23 | # General settings (see config/general.php) 24 | DEV_MODE=true 25 | ALLOW_ADMIN_CHANGES=true 26 | DISALLOW_ROBOTS=true 27 | 28 | # Dev server settings 29 | # The port to start looking for unused ports from; it will increment until it finds an unused port 30 | INITIAL_SERVER_PORT=8050 31 | # Uncomment DEV_SERVER_PORT if you want to instead explicitly set the port 32 | #DEV_SERVER_PORT=8050 33 | PRIMARY_SITE_URL="http://localhost:${DEV_SERVER_PORT}/" 34 | CRAFT_CP_USER="admin" 35 | CRAFT_CP_EMAIL="info@nystudio107.com" 36 | CRAFT_CP_PASSWORD="project" 37 | CRAFT_SITE_NAME="Spin Up Craft" 38 | CRAFT_HASHED_PASSWORD="$$2y$$13$$crqJ.kzM.kBs.WsWGUxT9uUdR4Imi./d9prVKVya/MkWu/Bd/8.Ga" 39 | -------------------------------------------------------------------------------- /.docker-config/spin-up-craft-base/php-8.2-alpine/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nystudio107/php-prod-base:8.2-alpine 2 | 3 | # dependencies required for running "phpize" 4 | # these get automatically installed and removed by "docker-php-ext-*" (unless they're already installed) 5 | ENV PHPIZE_DEPS \ 6 | autoconf \ 7 | dpkg-dev \ 8 | dpkg \ 9 | file \ 10 | g++ \ 11 | gcc \ 12 | libc-dev \ 13 | make \ 14 | pkgconf \ 15 | re2c \ 16 | linux-headers \ 17 | wget 18 | 19 | # Install packages 20 | RUN set -eux; \ 21 | # Packages needed only for build 22 | apk add --no-cache --virtual .build-deps \ 23 | $PHPIZE_DEPS \ 24 | && \ 25 | # Packages to install 26 | apk add --no-cache \ 27 | su-exec \ 28 | nano \ 29 | mysql-client \ 30 | mariadb-connector-c \ 31 | && \ 32 | # Install PHP extensions 33 | docker-php-ext-install \ 34 | pdo_mysql \ 35 | soap \ 36 | && \ 37 | # Install Composer 38 | curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ 39 | && \ 40 | # Remove the build deps 41 | apk del .build-deps \ 42 | && \ 43 | # Clean out directories that don't need to be part of the image 44 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 45 | -------------------------------------------------------------------------------- /.docker-config/spin-up-craft-base-dev/php-8.2-alpine/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nystudio107/php-dev-base:8.2-alpine 2 | 3 | # dependencies required for running "phpize" 4 | # these get automatically installed and removed by "docker-php-ext-*" (unless they're already installed) 5 | ENV PHPIZE_DEPS \ 6 | autoconf \ 7 | dpkg-dev \ 8 | dpkg \ 9 | file \ 10 | g++ \ 11 | gcc \ 12 | libc-dev \ 13 | make \ 14 | pkgconf \ 15 | re2c \ 16 | linux-headers \ 17 | wget 18 | 19 | # Install packages 20 | RUN set -eux; \ 21 | # Packages needed only for build 22 | apk add --no-cache --virtual .build-deps \ 23 | $PHPIZE_DEPS \ 24 | && \ 25 | # Packages to install 26 | apk add --no-cache \ 27 | su-exec \ 28 | nano \ 29 | mysql-client \ 30 | mariadb-connector-c \ 31 | && \ 32 | # Install PHP extensions 33 | docker-php-ext-install \ 34 | pdo_mysql \ 35 | soap \ 36 | && \ 37 | # Install Composer 38 | curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ 39 | && \ 40 | # Remove the build deps 41 | apk del .build-deps \ 42 | && \ 43 | # Clean out directories that don't need to be part of the image 44 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 45 | -------------------------------------------------------------------------------- /.docker-config/nginx/default.conf: -------------------------------------------------------------------------------- 1 | # default Docker DNS server 2 | resolver 127.0.0.11; 3 | 4 | server { 5 | listen 80; 6 | listen [::]:80; 7 | 8 | server_name _; 9 | root /var/www/project/web; 10 | index index.html index.htm index.php; 11 | charset utf-8; 12 | 13 | gzip_static on; 14 | 15 | ssi on; 16 | 17 | client_max_body_size 0; 18 | 19 | error_page 404 /index.php?$query_string; 20 | 21 | access_log off; 22 | error_log /dev/stdout info; 23 | 24 | location / { 25 | try_files $uri/index.html $uri $uri/ /index.php?$query_string; 26 | } 27 | 28 | location ~ [^/]\.php(/|$) { 29 | try_files $uri $uri/ /index.php?$query_string; 30 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 31 | fastcgi_pass php:9000; 32 | fastcgi_index index.php; 33 | include fastcgi_params; 34 | fastcgi_param PATH_INFO $fastcgi_path_info; 35 | fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; 36 | fastcgi_param DOCUMENT_ROOT $realpath_root; 37 | fastcgi_param HTTP_PROXY ""; 38 | 39 | add_header Last-Modified $date_gmt; 40 | add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0"; 41 | if_modified_since off; 42 | expires off; 43 | etag off; 44 | 45 | fastcgi_intercept_errors off; 46 | fastcgi_buffer_size 16k; 47 | fastcgi_buffers 4 16k; 48 | fastcgi_connect_timeout 300; 49 | fastcgi_send_timeout 300; 50 | fastcgi_read_timeout 300; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /config/general.php: -------------------------------------------------------------------------------- 1 | aliases([ 28 | '@web' => App::env('PRIMARY_SITE_URL'), 29 | ]) 30 | // Use a unique CSRF token name, to avoid issues with CSRF validation with multiple instances of 31 | // Craft running on the same host (localhost) 32 | ->csrfTokenName(App::env('CRAFT_APP_ID')) 33 | // Don't run the queue via web request, our queue container handles it 34 | ->runQueueAutomatically(false) 35 | // Set the default week start day for date pickers (0 = Sunday, 1 = Monday, etc.) 36 | ->defaultWeekStartDay(1) 37 | // Prevent generated URLs from including "index.php" 38 | ->omitScriptNameInUrls() 39 | // Enable Dev Mode (see https://craftcms.com/guides/what-dev-mode-does) 40 | ->devMode(App::env('DEV_MODE') ?? false) 41 | // Allow administrative changes 42 | ->allowAdminChanges(App::env('ALLOW_ADMIN_CHANGES') ?? false) 43 | // Disallow robots 44 | ->disallowRobots(App::env('DISALLOW_ROBOTS') ?? false) 45 | ; 46 | -------------------------------------------------------------------------------- /.docker-config/php/run_queue.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Run Queue shell script 4 | # 5 | # This shell script runs the Craft CMS queue via `php craft queue/listen` 6 | # It waits until the database container responds, then runs any pending 7 | # migrations / project config changes via the `craft-update` Composer script, 8 | # then runs the queue listener that listens for and runs pending queue jobs 9 | # 10 | # @author nystudio107 11 | # @copyright Copyright (c) 2023 nystudio107 12 | # @link https://nystudio107.com/ 13 | # @license MIT 14 | 15 | cd /var/www/project 16 | # Wait until the `composer install` is done by looking for the `vendor/autoload.php` file 17 | echo "### Waiting for vendor/autoload.php" 18 | while [ ! -f "composer.lock" ] || [ ! -d "vendor" ] || [ ! -f "vendor/autoload.php" ] 19 | do 20 | sleep 5 21 | done 22 | # Wait until the MySQL db container responds 23 | COMMAND="mysql -h mysql -u $CRAFT_DB_USER -p$CRAFT_DB_PASSWORD $CRAFT_DB_DATABASE -se 'SELECT EXISTS(SELECT * FROM info)'" 24 | # First wait until the command runs without error 25 | until eval "$COMMAND > /dev/null 2>&1" 26 | do 27 | echo "### Waiting for MySQL database" 28 | sleep 5 29 | done 30 | # Second wait until content in the `info` table exists 31 | until [ $(eval "$COMMAND") != "0" ] 32 | do 33 | echo "### Waiting for database 'info' table" 34 | sleep 5 35 | done 36 | # Ensure permissions on directories Craft needs to write to 37 | chown -R www-data:www-data /var/www/project/storage 38 | chown -R www-data:www-data /var/www/project/web/cpresources 39 | # Create a security key if it doesn't exist already 40 | if [ -z "$CRAFT_SECURITY_KEY" ] ; then 41 | su-exec www-data php craft setup/security-key --interactive=0 42 | fi 43 | # Create an app id if it doesn't exist already 44 | if [ -z "$CRAFT_APP_ID" ] ; then 45 | su-exec www-data php craft setup/app-id --interactive=0 46 | fi 47 | # Run any pending migrations/project config changes 48 | su-exec www-data php craft up --interactive=0 49 | # Banner message 50 | source '/var/www/banner_message.sh' 51 | # Run a queue listener 52 | su-exec www-data php craft queue/listen 10 53 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.7' 2 | 3 | services: 4 | # nginx - web server 5 | nginx: 6 | build: 7 | context: ./.docker-config/nginx 8 | dockerfile: ./Dockerfile 9 | depends_on: 10 | - "php" 11 | env_file: &env_file 12 | - ./.env 13 | environment: &env 14 | DEV_SERVER_PORT: "${DEV_SERVER_PORT}" 15 | CODESPACES: "${CODESPACES}" 16 | CODESPACE_NAME: "${CODESPACE_NAME}" 17 | GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN: "${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}" 18 | init: true 19 | ports: 20 | - "${DEV_SERVER_PORT}:80" 21 | volumes: 22 | - cpresources:/var/www/project/web/cpresources:delegated 23 | - ./web:/var/www/project/web:cached 24 | # php - run php-fpm 25 | php: 26 | build: &php-build 27 | context: ./.docker-config/php 28 | dockerfile: ./Dockerfile 29 | depends_on: 30 | - "mysql" 31 | env_file: 32 | *env_file 33 | environment: 34 | *env 35 | expose: 36 | - "9000" 37 | init: true 38 | stop_grace_period: "1s" 39 | tty: true 40 | volumes: &php-volumes 41 | # Bind mount the entire project directory 42 | - ./:/var/www/project:cached 43 | # Directories we want to persist as volumes 44 | - cpresources:/var/www/project/web/cpresources:delegated 45 | - storage:/var/www/project/storage:delegated 46 | # Specific directories that need to be bind mounted inside the volumes 47 | - ./storage/logs:/var/www/project/storage/logs:delegated 48 | - ./storage/runtime/compiled_templates:/var/www/project/storage/runtime/compiled_templates:delegated 49 | - ./storage/runtime/compiled_classes:/var/www/project/storage/runtime/compiled_classes:delegated 50 | # mysql - database 51 | mysql: 52 | build: 53 | context: ./.docker-config/mysql 54 | dockerfile: ./Dockerfile 55 | cap_add: 56 | - SYS_NICE # CAP_SYS_NICE 57 | environment: 58 | MYSQL_ROOT_PASSWORD: secret 59 | MYSQL_DATABASE: project 60 | MYSQL_USER: project 61 | MYSQL_PASSWORD: project 62 | init: true 63 | expose: 64 | - "3306" 65 | volumes: 66 | - db-data:/var/lib/mysql 67 | - ./db-seed:/docker-entrypoint-initdb.d 68 | # queue - runs queue jobs via php craft queue/listen 69 | queue: 70 | build: 71 | *php-build 72 | command: /var/www/run_queue.sh 73 | depends_on: 74 | - "mysql" 75 | env_file: 76 | *env_file 77 | environment: 78 | *env 79 | init: true 80 | stop_grace_period: "1s" 81 | tty: true 82 | volumes: 83 | *php-volumes 84 | volumes: 85 | db-data: 86 | cpresources: 87 | storage: 88 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Export the `.env` variables to sub-commands 2 | include .env 3 | export $(shell sed 's/=.*//' .env) 4 | INITIAL_SERVER_PORT?=8050 5 | # Dummy empty values for Codespaces to avoid warnings from Docker 6 | CODESPACES?= 7 | CODESPACE_NAME?= 8 | GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN?= 9 | export CODESPACES 10 | export CODESPACE_NAME 11 | export GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN 12 | 13 | .PHONY: db-admin-reset db-export db-import clean composer craft dev nuke ssh up 14 | 15 | # Reset the admin password, user name, and email address 16 | db-admin-reset: up 17 | docker compose exec -it php su-exec www-data mysql \ 18 | -h mysql -u "${CRAFT_DB_USER}" -p"${CRAFT_DB_PASSWORD}" "${CRAFT_DB_DATABASE}" \ 19 | -e 'UPDATE users SET username=${CRAFT_CP_USER}, email=${CRAFT_CP_EMAIL}, password=${CRAFT_HASHED_PASSWORD} WHERE id=1;' 20 | # Clean the `db-seed` directory and export the database to it 21 | db-export: up 22 | rm -rf db-seed/* 23 | docker compose exec -it php su-exec www-data php craft \ 24 | db/backup /var/www/project/db-seed 25 | # Import the db from db-seed/ into the mysql container 26 | db-import: up 27 | docker compose exec -it php su-exec www-data /bin/sh \ 28 | -c 'cat /var/www/project/db-seed/*.sql | mysql -h mysql -u "${CRAFT_DB_USER}" -p"${CRAFT_DB_PASSWORD}" "${CRAFT_DB_DATABASE}"' 29 | # Remove `vendor/` & `composer.lock` 30 | clean: 31 | rm -f composer.lock 32 | rm -rf vendor/ 33 | # Execute a composer command in the PHP container 34 | composer: up 35 | docker compose exec -it php su-exec www-data composer \ 36 | $(filter-out $@,$(MAKECMDGOALS)) $(MAKEFLAGS) 37 | # Execute a craft command in the PHP container 38 | craft: up 39 | docker compose exec -it php su-exec www-data php craft \ 40 | $(filter-out $@,$(MAKECMDGOALS)) $(MAKEFLAGS) 41 | # Start the dev server 42 | dev: up 43 | # Remove the Docker volumes & start clean 44 | nuke: clean 45 | cp -n example.env .env; \ 46 | docker compose down -v 47 | if ! command -v nc &>/dev/null ; then \ 48 | DEV_SERVER_PORT="$${DEV_SERVER_PORT:=$(INITIAL_SERVER_PORT)}"; \ 49 | export DEV_SERVER_PORT; \ 50 | else \ 51 | port=$(INITIAL_SERVER_PORT); \ 52 | while [ -z "$$DEV_SERVER_PORT" ] ; do \ 53 | nc -z localhost $$port &>/dev/null || export DEV_SERVER_PORT=$$port; \ 54 | ((port++)); \ 55 | done; \ 56 | echo "### Using port: $$DEV_SERVER_PORT"; \ 57 | fi; \ 58 | docker compose up --build --force-recreate 59 | # Open up a shell in the PHP container 60 | ssh: 61 | docker compose exec -it php su-exec www-data /bin/sh 62 | up: 63 | if [ ! "$$(docker compose ps --services | grep php)" ]; then \ 64 | if ! command -v nc &>/dev/null ; then \ 65 | DEV_SERVER_PORT="$${DEV_SERVER_PORT:=$(INITIAL_SERVER_PORT)}"; \ 66 | export DEV_SERVER_PORT; \ 67 | else \ 68 | port=$(INITIAL_SERVER_PORT); \ 69 | while [ -z "$$DEV_SERVER_PORT" ] ; do \ 70 | nc -z localhost $$port &>/dev/null || export DEV_SERVER_PORT=$$port; \ 71 | ((port++)); \ 72 | done; \ 73 | echo "### Using port: $$DEV_SERVER_PORT"; \ 74 | fi; \ 75 | cp -n example.env .env; \ 76 | docker compose up; \ 77 | fi 78 | %: 79 | @: 80 | # ref: https://stackoverflow.com/questions/6273608/how-to-pass-argument-to-makefile-from-command-line 81 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # nystudio107/spin-up-craft Change Log 2 | 3 | ## 1.0.15 - 2023.07.24 4 | ### Added 5 | * Use PHP 8.2 as the base for `spin-up-craft-base` Docker images 6 | 7 | ## 1.0.14 - 2023.04.25 8 | ### Fixed 9 | * Wait not just for the database to be available, but also that the `info` table has been populated before proceeding with the `queue` container ([#2](https://github.com/nystudio107/spin-up-craft/issues/2)) 10 | 11 | ### Changed 12 | * Remove PHP platform version 13 | 14 | ## 1.0.13 - 2023.03.30 15 | ### Changed 16 | * Clean up the `Makefile` by using `docker compose` api 17 | * Fully switch from the old `docker-compose` api to the new `docker compose` api 18 | 19 | ## 1.0.12 - 2023.03.23 20 | ### Changed 21 | * Updated to `craftcms/cms` `^4.4.5` 22 | * Switch to `jbergstroem/mariadb-alpine` for the db container, for a much smaller image size, and a much faster startup time 23 | * Run `php craft up` and display the banner message only from the queue container 24 | 25 | ## 1.0.11 - 2023.03.02 26 | ### Fixed 27 | * Use a unique CSRF token name, to avoid issues with CSRF validation with multiple instances of Craft running on the same host (localhost) 28 | 29 | ## 1.0.10 - 2023.03.02 30 | ### Changed 31 | * Ship with empty `CRAFT_APP_ID` & `CRAFT_SECURITY_KEY` env vars, and generate them via the `run_queue.sh` script, so each instance will have unique values 32 | * Move the copying of the `.env` file to the beginning of `make nuke` to handle the case where it isn't present 33 | 34 | ## 1.0.9 - 2023.02.26 35 | ### Added 36 | * Added the `INITIAL_SERVER_PORT` env var so that we can scan for an open port, rather than just using a fixed port 37 | 38 | ### Changed 39 | * Remove the `composer.lock` so people will always start with the latest 40 | * Explicitly set the `@web` alias from the `PRIMARY_SITE_URL` env var 41 | 42 | ## 1.0.8 - 2023.02.23 43 | ### Added 44 | * Add `spin-up-craft-base-dev` image that includes XDebug 45 | 46 | ### Changed 47 | * Remove any `.` from container names, because Docker strips them when creating containers 48 | 49 | ### Fixed 50 | * Run `php craft up` with `--interactive=0` so it's not waiting for user input 51 | 52 | ## 1.0.7 - 2023.02.17 53 | ### Changed 54 | * Added `stop_grace_period: "1s"` to the services that have long-running processes in the `docker-compose.yaml` 55 | * Add dummy empty values for Codespaces in the Makefile, to avoid warnings from Docker 56 | * Updated to `"craftcms/cms": "^4.3.10"` 57 | 58 | ## 1.0.6 - 2023.02.15 59 | ### Changed 60 | * Use the `GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN` env var 61 | * Use `env_file` & `env` aliases in the docker-compose.yaml 62 | 63 | ## 1.0.5 - 2023.02.14 64 | ### Added 65 | * Detect when we're running in Codespaces, and swap in the dynamic URL for the `PRIMARY_SITE_URL` env var automatically 66 | 67 | ### Changed 68 | * Refactor the banner to a separate `banner_message.sh` 69 | 70 | ## 1.0.4 - 2023.02.08 71 | ### Added 72 | * Add PHP 8.1 as the default image 73 | 74 | ### Changed 75 | * Use `#!/bin/sh` for the scripts shebang 76 | * Updated to `"craftcms/cms": "^4.3.8"` 77 | 78 | ## 1.0.3 - 2023.02.05 79 | ### Added 80 | * Added `nystudio107/craft-autocomplete` to allow for Craft API autocomplete in PhpStorm 81 | 82 | ### Changed 83 | * Updated to `"craftcms/cms": "^4.3.7.1"` 84 | * Removed `craftcms/generator` to lighten the dependency graph 85 | * Removed `yiisoft/yii2-shell` to lighten the dependency graph 86 | * Use `PHPIZE_DEPS` in `spin-up-craft-base` Docker image 87 | 88 | ## 1.0.2 - 2023.02.04 89 | ### Added 90 | * Build docker images via Github Actions CI 91 | 92 | ### Changed 93 | * Use a pre-built `spin-up-craft-base` for faster cold starts 94 | * Removed vestigial `redis` container for faster cold starts 95 | 96 | ## 1.0.1 - 2023.02.02 97 | ### Fixed 98 | * Fixed an issue with the default database seed and the `make db-admin-reset` had the wrong password 99 | 100 | ## 1.0.0 - 2023.02.02 101 | ### Added 102 | * Initial release 103 | 104 | Brought to you by [nystudio107](https://nystudio107.com/) 105 | -------------------------------------------------------------------------------- /templates/index.twig: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Welcome to Craft CMS 7 | 8 | 9 | 153 | 154 | 155 |
156 | 189 |
190 | 191 | 192 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Spin Up Craft 2 | 3 | Allows you to create your own self-contained Craft CMS project complete with a seeded database, template files, assets, and devops shrink-wrapped with Docker, which you can distribute to others or use yourself. 4 | 5 | Use it for: 6 | - Spinning up a Craft CMS site in a browser in Github Codespaces 7 | - Shipping a self-contained Craft CMS site to others 8 | - Providing working example code & projects to others 9 | - Spinning up a local Craft project using someone else's `composer.json` & database, for support 10 | 11 | **N.B.:** This is _not_ intended to be a fully functional local development environment for client sites (there is no `buildchain`, for example). 12 | 13 | ## Making a new Craft CMS project 14 | 15 | This is a template repository. Click on **Use this template** on [github](https://github.com/nystudio107/spin-up-craft) and select **Create a new repository**. 16 | 17 | You will then be able to name the new repository, and a clone of this repo will be created there. 18 | 19 | The project you'll get is the default Craft starter you might create with `composer create-project craftcms/craft`, with the Spin Up Craft scaffolding around it. 20 | 21 | If you intend to use this as a [Template Repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-template-repository) (like Spin Up Craft is), you'll want to go to the repo **Settings** and check the **Template repository** checkbox. 22 | 23 | You can also consider [adding an **Open in Codespaces**](https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/setting-up-your-repository/adding-a-codespaces-badge) button. 24 | 25 | ## Using your Craft CMS project in a browser via Github Codespaces 26 | 27 | 1. Go to your repo in Github 28 | 2. Click on **Use this template** and select **Open in a codespace** if your repository is a Template Repository. If it is a regular repository, click on **Code**, then click on the **Codespaces** tab, and click on the **Creat codespace on ...** button 29 | 3. In the resulting Terminal window, type `make dev` to start the project up 30 | 4. Wait until you see output like this, and then access the site via the credentials that are output on the console: 31 | 32 | ``` 33 | queue_1 | ### Your Craft site is ready! 34 | queue_1 | Frontend URL: https://khalwat-opulent-xylophone-q59g6p5vqj3rvr-8050.preview.app.github.dev/ 35 | queue_1 | CP URL: https://khalwat-opulent-xylophone-q59g6p5vqj3rvr-8050.preview.app.github.dev/admin 36 | queue_1 | CP User: admin 37 | queue_1 | CP Password: project 38 | ``` 39 | 40 | This lets anyone use the project without having to do _any_ local setup. 41 | 42 | You can use the Codespaces editor to edit Twig files, load the site frontend, or log into the Craft CP, all from within a browser! 43 | 44 | The first time you start up your project in Codespaces, it'll take some time to set everything up. However, subsequent startups will be very quick. 45 | 46 | You can access your existing Codespaces here: 47 | 48 | https://github.com/codespaces 49 | 50 | Click on one to resume it. If you don't see a Terminal window, go to the hamburger menu in the top-left, and click on **Terminal > New Terminal** 51 | 52 | You are limited to 15 active Codespaces on the free plan, but you can go in and delete any older Codespaces you're not using at any time. 53 | 54 | ## Using your Craft CMS project in local dev 55 | 56 | 1. Have [Docker Desktop](https://www.docker.com/products/docker-desktop/) installed 57 | 2. Clone your newly created repo down to your computer 58 | 3. `cd` to your repo in your terminal 59 | 4. Get the project up and running with `make dev` 60 | 5. Wait until you see output like this, and then access the site via the credentials that are output on the console: 61 | 62 | ``` 63 | spin-up-craft-queue-1 | ### Your Craft site is ready! 64 | spin-up-craft-queue-1 | Frontend URL: http://localhost:8050/ 65 | spin-up-craft-queue-1 | CP URL: http://localhost:8050/admin 66 | spin-up-craft-queue-1 | CP User: admin 67 | spin-up-craft-queue-1 | CP Password: project 68 | ``` 69 | 70 | Hit `Control-C` to terminate the project and spin down the containers 71 | 72 | The first time you start up your project, it'll take some time to set everything up. However, subsequent startups will be very quick. 73 | 74 | ## Available `make` commands 75 | 76 | This project uses `make` to execute various commands in the appropriate containers. Here's a list of available commands: 77 | 78 | * `make dev` - Start the dev server 79 | * `make composer xxx` - Execute a composer command in the PHP container 80 | * `make craft xxx` - Execute a `craft` CLI command in the PHP container 81 | * `make ssh` - Open up a shell in the PHP container 82 | * `make db-admin-reset` - Reset the admin (user with the `ID=1`) to the defaults in from the `.env` file; useful after importing a foreign database 83 | * `make db-export` - Clean the `db-seed/` directory and export the database to it 84 | * `make db-import` - Import the db from `db-seed/` directory into the mysql container 85 | 86 | If the project is already running via `make dev` you can use a second terminal tab/window to execute additional commands. 87 | 88 | ## Creating your Craft CMS project 89 | 90 | Develop the site as you normally would by editing templates, adding content, adding assets, etc. 91 | 92 | Commit your changes to the repository. 93 | 94 | To update the database dump in `db-seed/` directory, use the command: 95 | ``` 96 | make db-export 97 | ``` 98 | ... and then commit the new database dump to your repository. Ensure there is no confidential data in the database dump before doing so. 99 | 100 | People wanting to use the project will simply need to `git clone` the repo down, and get up and running with `make dev` 101 | 102 | ## Using Spin Up Craft for support 103 | 104 | If you're using Spin Up Craft to try to replicate an issue someone else is having: 105 | 106 | 1. Clone a clean version of your repo down 107 | 2. Copy their `composer.json` and their `composer.lock` files to overwrite the project's respective files 108 | 3. Delete the repo's database dump from `db-seed/` and copy their database dump into it as an uncompressed `.sql` file 109 | 110 | Then start the project up with: 111 | ``` 112 | make dev 113 | ``` 114 | 115 | If you need to re-import their db at any time, you can use: 116 | ``` 117 | make db-import 118 | ``` 119 | 120 | If you don't have a login, or the client doesn't wish to share their password, you can then use: 121 | ``` 122 | make db-admin-reset 123 | ``` 124 | 125 | ...which will reset the admin user (`ID=1`) to the defaults specified in the `.env` file 126 | 127 | Usually the `composer.json`, `composer.lock`, and database dump are all you need to replicate issues. But if additional config/template files are needed, obtain them as well. 128 | 129 | 130 | ## Random notes 131 | 132 | - The `.env` file is created by copying `example.env` file when you start the project up 133 | - The server will use the `INITIAL_SERVER_PORT` in the `.env` file for the initial port to start looking for unused ports from. It will increment it until it finds and unused port, and then use it 134 | - If instead you want to used a fixed port, you can explicitly set the `DEV_SERVER_PORT` in the `.env` file 135 | - The Docker containers will be named after the project directory, so give it a unique name for each project 136 | 137 | ## To Do 138 | 139 | - Await orders from Ben & Ryan 140 | 141 | Brought to you by [nystudio107](https://nystudio107.com/) 142 | --------------------------------------------------------------------------------