Skip to content

Commit

Permalink
Merge branch 'release/1.0.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Feb 14, 2023
2 parents e02f7c3 + f03f7c7 commit 1b97f2e
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .docker-config/php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ RUN chmod a+x run_queue.sh \
chown -R www-data:www-data /var/www/project
COPY ./composer_install.sh .
RUN chmod a+x composer_install.sh
COPY ./banner_message.sh .
RUN chmod a+x banner_message.sh

WORKDIR /var/www/project

Expand Down
22 changes: 22 additions & 0 deletions .docker-config/php/banner_message.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

# Banner Message shell script
#
# Display a banner message to let the user know the environment is ready for use
#
# @author nystudio107
# @copyright Copyright (c) 2023 nystudio107
# @link https://nystudio107.com/
# @license MIT

# Rewrite the PRIMARY_SITE_URL env var if we're running in Codespaces
if [[ ! ${CODESPACES:-"unset"} == "unset" ]]; then
export PRIMARY_SITE_URL="https://${CODESPACE_NAME}-${DEV_SERVER_PORT}.preview.app.github.dev/"
fi
# Banner message
sleep 1
echo "### Your Craft site is ready!"
echo "Frontend URL: ${PRIMARY_SITE_URL}"
echo "CP URL: ${PRIMARY_SITE_URL}admin"
echo "CP User: ${CRAFT_CP_USER}"
echo "CP Password: ${CRAFT_CP_PASSWORD}"
9 changes: 2 additions & 7 deletions .docker-config/php/composer_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# the `vendor/` directory is not present`
#
# @author nystudio107
# @copyright Copyright (c) 2022 nystudio107
# @copyright Copyright (c) 2023 nystudio107
# @link https://nystudio107.com/
# @license MIT

Expand All @@ -28,9 +28,4 @@ if [ ! -f "composer.lock" ] || [ ! -d "vendor" ] || [ ! -f "vendor/autoload.php"
su-exec www-data php craft up
fi
# Banner message
sleep 1
echo "### Your Craft site is ready!"
echo "Frontend URL: ${PRIMARY_SITE_URL}"
echo "CP URL: ${PRIMARY_SITE_URL}admin"
echo "CP User: ${CRAFT_CP_USER}"
echo "CP Password: ${CRAFT_CP_PASSWORD}"
source '/var/www/banner_message.sh'
9 changes: 2 additions & 7 deletions .docker-config/php/run_queue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# then runs the queue listener that listens for and runs pending queue jobs
#
# @author nystudio107
# @copyright Copyright (c) 2022 nystudio107
# @copyright Copyright (c) 2023 nystudio107
# @link https://nystudio107.com/
# @license MIT

Expand All @@ -31,11 +31,6 @@ chown -R www-data:www-data /var/www/project/web/cpresources
# Run any pending migrations/project config changes
su-exec www-data php craft up
# Banner message
sleep 1
echo "### Your Craft site is ready!"
echo "Frontend URL: ${PRIMARY_SITE_URL}"
echo "CP URL: ${PRIMARY_SITE_URL}admin"
echo "CP User: ${CRAFT_CP_USER}"
echo "CP Password: ${CRAFT_CP_PASSWORD}"
source '/var/www/banner_message.sh'
# Run a queue listener
su-exec www-data php craft queue/listen 10
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# nystudio107/spin-up-craft Change Log

## 1.0.5 - 2023.02.14
### Added
* Detect when we're running in Codespaces, and swap in the dynamic URL for the `PRIMARY_SITE_URL` env var automatically

### Changed
* Refactor the banner to a separate `banner_message.sh`

## 1.0.4 - 2023.02.08
### Added
* Add PHP 8.1 as the default image
Expand Down
10 changes: 10 additions & 0 deletions config/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
use craft\config\GeneralConfig;
use craft\helpers\App;

// Rewrite the PRIMARY_SITE_URL env var if we're running in Codespaces
if (App::env('CODESPACES')) {
// putenv() only affects the OS's environment, so set it directly
$_ENV['PRIMARY_SITE_URL'] = $_SERVER['PRIMARY_SITE_URL'] = sprintf(
"https://%s-%s.preview.app.github.dev/",
App::env('CODESPACE_NAME'),
App::env('DEV_SERVER_PORT')
);
}

return GeneralConfig::create()
->runQueueAutomatically(false)
// Set the default week start day for date pickers (0 = Sunday, 1 = Monday, etc.)
Expand Down

0 comments on commit 1b97f2e

Please sign in to comment.