-
-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into wip/support-uploading-packages
- Loading branch information
Showing
140 changed files
with
2,976 additions
and
788 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Listen for Xdebug", | ||
"type": "php", | ||
"request": "launch", | ||
"port": 9003 | ||
}, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM php:8.3-apache-bookworm | ||
|
||
# Install PHP extensions | ||
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ | ||
|
||
RUN install-php-extensions @composer gd intl zip xdebug | ||
|
||
# Enable Apache2 rewrite module | ||
RUN a2enmod rewrite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Welcome to the Winter development environment | ||
|
||
<p align="center"> | ||
<img src="https://github.com/wintercms/winter/raw/develop/.github/assets/Github%20Banner.png?raw=true" alt="Winter CMS Logo" width="100%" style="max-width: 600px" /> | ||
</p> | ||
|
||
This development environment container sets up a fully-functional installation of Winter CMS, running on Apache 2 with PHP 8.3, and makes it simple to start working with Winter CMS in VSCode, PHPStorm and online code-editing suites such as GitHub Codespaces. | ||
|
||
If you opted to use the `bootstrap-winter` feature, which is enabled by default, Winter CMS will be automatically configured and an administrator account will be generated with the credentials **admin / admin** for you to quickly sign in. It is recommended once you have done so that you change this password immediately. | ||
|
||
The following plugins and themes will be installed automatically with this feature: | ||
|
||
- Workshop theme (https://github.com/wintercms/wn-workshop-theme) | ||
- Pages plugin (https://github.com/wintercms/wn-pages-plugin) | ||
- Blog plugin (https://github.com/wintercms/wn-blog-plugin) | ||
- Test plugin (https://github.com/wintercms/wn-test-plugin) | ||
|
||
## Using this environment | ||
|
||
When this environment is built, the Apache 2 service is automatically started, with the root folder of the Winter project being used. A preview of the website will be opened immediately - if you do not see this, you can open the **Ports** tab in VSCode to view the URL generated for viewing the project. | ||
|
||
XDebug is enabled by default, and allows you to quickly use step debugging. It will be available in the **Debug** tab of VSCode or similar screen in other IDEs. | ||
|
||
By default, when using the `bootstrap-winter` feature, changes to certain folders and locations will be ignored by Git to keep the change list clean. This includes the `plugins` and `themes` folders, the `config/app.php` file and the `composer.json` file in the root folder. If you wish to use this environment for your own projects, it is recommended that you do not use this feature. Please see the **Using in your own projects** section below for using this environment outside of Winter development. | ||
|
||
## Environment platform | ||
|
||
The following software is installed in this environment. | ||
|
||
- Apache 2.4 | ||
- PHP 8.3 with the following extensions: | ||
- `intl` | ||
- `gd` | ||
- `xdebug` | ||
- Composer | ||
- NodeJS 22 (including `npm`) | ||
- Git | ||
|
||
## Using in your own projects | ||
|
||
You may use this development environment for your own projects, making it a great starting point to hit the ground running with Winter. It is recommended that you *disable* the `bootstrap-winter` feature when using this environment for your own projects. | ||
|
||
You may disable this feature by modifying the `.devcontainer/devcontainer.json` file before running the container and commenting out the feature: | ||
|
||
```json5 | ||
"ghcr.io/devcontainers/features/git:1": {}, | ||
"./local-features/apache-config": "latest", | ||
// Comment the following feature if you wish to bootstrap and configure Winter manually (ie. you wish to use this for your own project) | ||
//"./local-features/bootstrap-winter": "latest" | ||
}, | ||
"overrideFeatureInstallOrder": [ | ||
``` | ||
|
||
If this feature is disabled, you must bootstrap your project manually. This includes: | ||
|
||
- Downloading the Composer dependencies. | ||
- Generating the configuration for the project, either as an `.env` file or in the `config` folder. | ||
- Finally, Running the database migrations. | ||
|
||
You may view the `.devcontainer/local-features/bootstrap-winter/bootstrap.sh` file to see how we bootstrap Winter, and run these commands manually. You will only need to do this once per project container. | ||
|
||
If you wish to mount your own volumes, use your own databases or any other complex usages, please review the [Docker documentation](https://docs.docker.com/) to set this up on the container. | ||
|
||
## Troubleshooting | ||
|
||
### Preview website missing styles / assets on Codespaces | ||
|
||
By default, ports that are forwarded in Codespaces are private by default. While we have tried to fix this automatically in the Winter bootstrap process by making the port public through the GitHub CLI, it unfortunately is not consistently applied. | ||
|
||
If you find that your preview website is missing assets or styling, open the **Ports** tab by opening the Action Palette in Codespaces (`F1`) and using the **View: Toggle Ports** action. Right click on the **Preview Winter installation** port, right click on it and choose **Port Visiblity -> Public**. This should resolve the issue. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/debian | ||
{ | ||
"name": "Winter on PHP 8.3", | ||
"build": { | ||
"dockerfile": "./Dockerfile", | ||
"context": "." | ||
}, | ||
"features": { | ||
"ghcr.io/devcontainers/features/common-utils:2": { | ||
"installZsh": "true", | ||
"configureZshAsDefaultShell": true, | ||
"username": "vscode", | ||
"userUid": "1000", | ||
"userGid": "1000", | ||
"upgradePackages": "true" | ||
}, | ||
"ghcr.io/devcontainers/features/node:1": { | ||
"version": "22" | ||
}, | ||
"ghcr.io/devcontainers/features/git:1": {}, | ||
"ghcr.io/devcontainers/features/github-cli:1": {}, | ||
"./local-features/apache-config": "latest", | ||
// Comment the following feature if you wish to bootstrap and configure Winter manually (ie. you wish to use this for your own project) | ||
"./local-features/bootstrap-winter": "latest" | ||
}, | ||
"overrideFeatureInstallOrder": [ | ||
"ghcr.io/devcontainers/features/common-utils" | ||
], | ||
"containerEnv": { | ||
"DB_CONNECTION": "sqlite", | ||
"DB_DATABASE": "${containerWorkspaceFolder}/storage/database.sqlite" | ||
}, | ||
"postStartCommand": "sudo rm -rf /var/www/html && sudo ln -s ${containerWorkspaceFolder} /var/www/html && service apache2 start", | ||
"forwardPorts": [8080], | ||
"portsAttributes": { | ||
"8080": { | ||
"label": "Preview Winter installation", | ||
"onAutoForward": "openPreview" | ||
}, | ||
"9003": { | ||
"label": "Xdebug", | ||
"onAutoForward": "notify" | ||
} | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"settings": { | ||
"php.validate.executablePath": "/usr/local/bin/php", | ||
"phpcs.executablePath": "${containerWorkspaceFolder}/vendor/bin/phpcs" | ||
}, | ||
"extensions": [ | ||
"xdebug.php-debug", | ||
"bmewburn.vscode-intelephense-client", | ||
"shevaua.phpcs", | ||
"swordev.phpstan", | ||
"wintercms.winter-cms" | ||
] | ||
}, | ||
"codespaces": { | ||
"openFiles": [ | ||
".devcontainer/README.md" | ||
] | ||
} | ||
}, | ||
"remoteUser": "vscode" | ||
} |
4 changes: 4 additions & 0 deletions
4
.devcontainer/local-features/apache-config/devcontainer-feature.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"id": "apache-config", | ||
"name": "Apache configuration changes" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env bash | ||
#------------------------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. | ||
#------------------------------------------------------------------------------------------------------------- | ||
|
||
USERNAME="vscode" | ||
|
||
set -e | ||
|
||
if [ "$(id -u)" -ne 0 ]; then | ||
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' | ||
exit 1 | ||
fi | ||
|
||
# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies. | ||
export DEBIAN_FRONTEND=noninteractive | ||
|
||
apt-get update && apt-get -y install --no-install-recommends lynx | ||
usermod -aG www-data ${USERNAME} | ||
echo "Listen 8080" > /etc/apache2/ports.conf | ||
apt-get clean -y && rm -rf /var/lib/apt/lists/* | ||
|
||
echo "Done!" |
46 changes: 46 additions & 0 deletions
46
.devcontainer/local-features/bootstrap-winter/bootstrap.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
echo "### Updating Composer dependencies" | ||
php ${PWD}/.devcontainer/local-features/bootstrap-winter/update-composer.php | ||
composer update --no-interaction --no-scripts --no-audit | ||
|
||
if [ ! -f "${PWD}/.env" ]; then | ||
echo "### Generating .env file" | ||
php artisan winter:env -q | ||
php artisan key:generate -q | ||
fi | ||
|
||
if [ "${DB_CONNECTION}" = "sqlite" ] && [ "${DB_DATABASE}" = "${PWD}/storage/database.sqlite" ] && [ ! -f "${PWD}/storage/database.sqlite" ]; then | ||
SETUP_ADMIN=true | ||
echo "### Creating SQLite database" | ||
touch storage/database.sqlite | ||
fi | ||
|
||
echo "### Run migrations" | ||
php artisan migrate | ||
|
||
if [ "${SETUP_ADMIN}" = true ]; then | ||
echo "### Setup admin" | ||
php artisan winter:passwd admin admin | ||
fi | ||
|
||
echo "### Switch theme" | ||
php artisan theme:use workshop | ||
|
||
echo "### Ignoring files in Git" | ||
echo "plugins/*" >> "${PWD}/.git/info/exclude" | ||
echo "themes/*" >> "${PWD}/.git/info/exclude" | ||
echo "composer.json" >> "${PWD}/.git/info/exclude" | ||
git update-index --assume-unchanged composer.json | ||
git restore config | ||
|
||
cp ${PWD}/.devcontainer/.vscode/launch.json ${PWD}/.vscode/launch.json | ||
|
||
if [ "${CODESPACES}" = "true" ]; then | ||
echo "### Configure for Codespaces" | ||
php ${PWD}/.devcontainer/local-features/bootstrap-winter/codespaces.php | ||
git update-index --assume-unchanged config/app.php | ||
gh codespace ports visibility 8080:public -c $CODESPACE_NAME | ||
fi |
25 changes: 25 additions & 0 deletions
25
.devcontainer/local-features/bootstrap-winter/codespaces.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
$root = dirname(__DIR__, 3); | ||
|
||
require_once $root . '/vendor/autoload.php'; | ||
|
||
use Winter\LaravelConfigWriter\ArrayFile; | ||
use Winter\LaravelConfigWriter\EnvFile; | ||
|
||
$config = ArrayFile::open($root . '/config/app.php'); | ||
|
||
$config->set('trustedHosts', [ | ||
'localhost', | ||
'^(.+\.)?app.github.dev', | ||
]); | ||
$config->set('trustedProxies', '*'); | ||
|
||
$config->write(); | ||
|
||
$env = EnvFile::open($root . '/.env'); | ||
|
||
$env->set('APP_URL', 'https://' . $_ENV['CODESPACE_NAME'] . '.app.github.dev'); | ||
$env->set('LINK_POLICY', 'force'); | ||
|
||
$env->write(); |
6 changes: 6 additions & 0 deletions
6
.devcontainer/local-features/bootstrap-winter/devcontainer-feature.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"id": "bootstrap-winter", | ||
"name": "Bootstrap Winter", | ||
"description": "Bootstrap and configure Winter CMS automatically for development on Winter itself", | ||
"postCreateCommand": "sh ./.devcontainer/local-features/bootstrap-winter/bootstrap.sh" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
echo "Done" |
22 changes: 22 additions & 0 deletions
22
.devcontainer/local-features/bootstrap-winter/update-composer.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
$composerPath = dirname(__DIR__, 3) . '/composer.json'; | ||
$composer = json_decode(file_get_contents($composerPath), true); | ||
|
||
$packages = [ | ||
'winter/wn-test-plugin' => 'dev-main', | ||
'winter/wn-blog-plugin' => 'dev-main', | ||
'winter/wn-blog-plugin' => 'dev-main', | ||
'winter/wn-workshop-theme' => 'dev-main', | ||
]; | ||
|
||
// Install Winter packages | ||
foreach ($packages as $package => $version) { | ||
if (!in_array($package, array_keys($composer['require']))) { | ||
$composer['require'][$package] = $version; | ||
} | ||
} | ||
|
||
file_put_contents( | ||
$composerPath, | ||
json_encode($composer, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ sftp-config.json | |
nbproject | ||
.idea | ||
.vscode | ||
!.devcontainer/.vscode | ||
_ide_helper.php | ||
|
||
# Other ignores | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.