Compare commits

...

25 commits

Author SHA1 Message Date
7acfb09e66 Merge branch 'release/v1.0' 2019-04-15 13:23:43 +02:00
7e262e8fce Create separete dockerfiles for services 2019-04-15 13:18:46 +02:00
39009e7f22 Remove unnecessary commands from dockerfile 2019-04-15 10:38:15 +02:00
5fc718a534 Improve the installation script 2019-04-13 17:33:06 +02:00
b27b359366 Rework the files according to phpcs 2019-04-13 17:29:27 +02:00
8fec9f1dfb Rework the phpcs-ruleset 2019-04-13 16:51:46 +02:00
03ffe6e9ed Rename the phpcs rule-file according to standards 2019-04-13 16:51:22 +02:00
4962e89f4c Update all packages 2019-04-12 10:04:07 +02:00
9f8a6e65e9 Add additional info to the composer.json file 2019-04-11 10:46:37 +02:00
d598c120ae Remove installation files 2019-04-10 12:50:48 +02:00
3e4e0c8358 Improve the installation procedure 2019-04-10 12:41:33 +02:00
dd6559a4aa Adjust the directory structure 2019-04-10 12:39:55 +02:00
b1cc1cca39 Fix eol-characters of shell-scripts 2019-04-09 21:30:12 +02:00
e2e9b02bca Improve the installation-script 2019-04-09 20:53:29 +02:00
502e116849 Update all packages 2019-04-09 19:01:05 +02:00
1b88185fdc Fix the build-script 2019-04-05 11:00:54 +02:00
9d05361eee Fix execution permission 2019-04-05 10:52:57 +02:00
3fde01a434 Add release-info 2019-04-05 10:45:41 +02:00
3112b9e1cd Prevent environment-files from being deleted 2019-04-05 10:40:42 +02:00
32e8034c9f Finalize the docker build 2019-04-05 10:40:06 +02:00
050f94ae88 Adjust the docker-environment for silverstripe 2019-03-27 08:56:17 +01:00
1fc0328a8b Initialize a new silverstripe website 2019-03-27 08:55:08 +01:00
599bb7bd6d Create an install script 2019-03-25 14:25:09 +01:00
ef4aa81041 Create a docker environment for developement 2019-03-25 14:24:59 +01:00
ce4ec30fba Rework the .gitignore-file 2019-03-25 10:47:38 +01:00
30 changed files with 4531 additions and 9 deletions

11
.docker/.env Normal file
View file

@ -0,0 +1,11 @@
SS_ENVIRONMENT_TYPE="dev"
SS_BASE_URL="http://localhost"
SS_DATABASE_CLASS="MySQLPDODatabase"
SS_DATABASE_SERVER="db"
SS_DATABASE_USERNAME="root"
SS_DATABASE_PASSWORD="root"
SS_DATABASE_NAME="SilverStripe"
SS_DEFAULT_ADMIN_USERNAME="root"
SS_DEFAULT_ADMIN_PASSWORD="root"

2
.docker/date.ini Normal file
View file

@ -0,0 +1,2 @@
[date]
date.timezone="Europe/Zurich"

9
.docker/nuth.sh Normal file
View file

@ -0,0 +1,9 @@
#!/bin/bash
until nc -z db 3306
do
>&2 echo "mysql is unavailable - waiting"
sleep 1
done
sudo -u www-data ../app/scripts/install.sh
apache2-foreground

4
.docker/xdebug.ini Normal file
View file

@ -0,0 +1,4 @@
[xdebug]
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_host='host.docker.internal'

17
.dockerignore Normal file
View file

@ -0,0 +1,17 @@
Dockerfile*
docker-compose*
.dockerignore
.git
.gitignore
.env
*/bin
*/obj
README.md
LICENSE
.vscode
# SilverStripe auto-generated content
/silverstripe-cache/
/vendor/
/resources/
/public/resources/

1
.gitattributes vendored Normal file
View file

@ -0,0 +1 @@
*.sh text eol=lf

14
.gitignore vendored
View file

@ -1,4 +1,3 @@
# ---> Composer
composer.phar
/vendor/
@ -6,10 +5,9 @@ composer.phar
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock
# ---> VisualStudioCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
# SvilerStripe files
/silverstripe-cache/
/vendor/
/themes/simple/
/resources/
/public/resources/

2
.htaccess Normal file
View file

@ -0,0 +1,2 @@
RewriteEngine On
RewriteRule ^(.*)$ public/$1

33
.phpcs.xml Normal file
View file

@ -0,0 +1,33 @@
<?xml version="1.0"?>
<ruleset name="Custom">
<description>A custom coding standard</description>
<!-- Don't sniff third party libraries -->
<exclude-pattern>*/themes/simple/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/thirdparty/*</exclude-pattern>
<!-- Show progress and output sniff names on violation, and add colours -->
<arg value="sp"/>
<arg name="colors"/>
<arg name="report" value="csv"/>
<arg name="extensions" value="php/php,inc/php"/>
<!-- Use PSR-2 as a base standard -->
<rule ref="PSR2">
<!-- Allow Windows-like EOL-characters -->
<exclude name="Generic.Files.LineEndings.InvalidEOLChar"/>
<!-- Allow classes to not declare a namespace -->
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace"/>
<!-- Allow namespaces without a following EOL-character -->
<exclude name="PSR2.Namespaces.NamespaceDeclaration.BlankLineAfter"/>
<!-- Allow files to have no EOL-character at the end of the file -->
<exclude name="PSR2.Files.EndFileNewline.NoneFound"/>
<!-- Allow underscores in class names -->
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps"/>
<!-- Allow non camel cased method names -->
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
</rule>
<!-- Force files to have no EOL-character at the end of file -->
<rule ref="Generic.Files.EndFileNoNewline.Found"/>
</ruleset>

14
.vscode/extensions.json vendored Normal file
View file

@ -0,0 +1,14 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"felixfbecker.php-pack",
"neilbrayfield.php-docblocker"
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": [
]
}

17
.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,17 @@
{
// Verwendet IntelliSense zum Ermitteln möglicher Attribute.
// Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen.
// Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"pathMappings": {
"/var/www/html": "${workspaceRoot}/src"
}
}
]
}

33
.vscode/tasks.json vendored Normal file
View file

@ -0,0 +1,33 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Lint PHP-Code",
"type": "shell",
"options": {
"cwd": "${workspaceFolder}"
},
"command": "composer",
"args": [
"lint"
],
"problemMatcher": {
"owner": "phpcs",
"fileLocation": "absolute",
"pattern": [
{
"regexp": "^\"(.*)\",(\\d+),(\\d+),(.*),\"(.*)\",(.*),(\\d+),(\\d+)",
"file": 1,
"line": 2,
"column": 3,
"message": 5,
"code": 6
}
],
"severity": "warning"
}
}
]
}

View file

@ -1,3 +1,2 @@
# nuth.ch
The homepage of m@nuth

3
app/.htaccess Normal file
View file

@ -0,0 +1,3 @@
<FilesMatch "\.(php|php3|php4|php5|phtml|inc)$">
Deny from all
</FilesMatch>

9
app/_config.php Normal file
View file

@ -0,0 +1,9 @@
<?php
use SilverStripe\Security\PasswordValidator;
use SilverStripe\Security\Member;
// remove PasswordValidator for SilverStripe 5.0
$validator = PasswordValidator::create();
// Settings are registered via Injector configuration - see passwords.yml in framework
Member::set_password_validator($validator);

5
app/_config/mysite.yml Normal file
View file

@ -0,0 +1,5 @@
---
Name: m@nuth
---
SilverStripe\Core\Manifest\ModuleManifest:
project: app

8
app/_config/theme.yml Normal file
View file

@ -0,0 +1,8 @@
---
Name: mytheme
---
SilverStripe\View\SSViewer:
themes:
- '$public'
- 'simple'
- '$default'

13
app/src/Page.php Normal file
View file

@ -0,0 +1,13 @@
<?php
namespace
{
use SilverStripe\CMS\Model\SiteTree;
class Page extends SiteTree
{
private static $db = [];
private static $has_one = [];
}
}

View file

@ -0,0 +1,33 @@
<?php
namespace {
use SilverStripe\CMS\Controllers\ContentController;
class PageController extends ContentController
{
/**
* An array of actions that can be accessed via a request. Each array element should be an action name, and the
* permissions or conditions required to allow the user to access it.
*
* ```php
* [
* 'action', // anyone can access this action
* 'action' => true, // same as above
* 'action' => 'ADMIN', // you must have ADMIN permissions to access this action
* 'action' => '->checkAction' // you can only access this action if $this->checkAction() returns true
* ];
* ```
*
* @var array
*/
private static $allowed_actions = [];
protected function init()
{
parent::init();
// You can include any CSS or JS required by your project here.
// See: https://docs.silverstripe.org/en/developer_guides/templates/requirements/
}
}
}

50
cms.Dockerfile Normal file
View file

@ -0,0 +1,50 @@
FROM php:7.2.17-apache
COPY .docker/nuth.sh /usr/local/bin/nuth-start
RUN chown -R www-data:www-data /var/www
RUN apt update -y
RUN apt install --no-install-recommends -y \
libicu-dev \
libmagickwand-dev \
libtidy-dev \
libzip-dev \
mysql-client \
netcat \
rsync \
sudo \
unzip \
zip
RUN a2enmod rewrite
RUN docker-php-ext-configure intl
RUN docker-php-ext-configure zip --with-libzip
RUN docker-php-ext-install \
gd \
intl \
pdo \
pdo_mysql \
tidy \
zip
RUN pecl install \
xdebug \
imagick
RUN docker-php-ext-enable \
xdebug \
imagick
ADD https://getcomposer.org/installer composer-setup.php
RUN php composer-setup.php
RUN mv composer.phar /usr/local/bin/composer
COPY --chown=www-data:www-data ./composer.* ./
RUN sudo -u www-data mkdir public
RUN sudo -u www-data composer install
COPY .docker/xdebug.ini $PHP_INI_DIR/conf.d/
COPY .docker/date.ini $PHP_INI_DIR/conf.d/
COPY --chown=www-data:www-data .docker/.env .env
COPY --chown=www-data:www-data ./ ../app
RUN sudo -u www-data composer vendor-expose
CMD [ "nuth-start" ]

64
composer.json Normal file
View file

@ -0,0 +1,64 @@
{
"name": "manuth/nuth.ch",
"type": "silverstripe-recipe",
"version": "1.0",
"description": "The source code of nuth.ch",
"authors": [
{
"name": "Manuel Thalmann",
"email": "m@nuth.ch",
"homepage": "https://nuth.ch/"
}
],
"license": "MIT",
"keywords": [
"Homepage",
"Website",
"m@nuth",
"SilverStripe"
],
"repositories": [
{
"type": "git",
"url": "https://git.nuth.ch/manuth/nuth.ch.git"
}
],
"support": {
"issues": "https://git.nuth.ch/manuth/nuth.ch/issues"
},
"homepage": "https://nuth.ch/",
"scripts": {
"lint": "phpcs --report=csv ."
},
"config": {
"process-timeout": 600
},
"prefer-stable": true,
"minimum-stability": "dev",
"require": {
"php": ">=5.6.0",
"silverstripe/recipe-plugin": "^1.2",
"silverstripe/recipe-cms": "4.3.3@stable",
"silverstripe-themes/simple": "~3.2.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
"squizlabs/php_codesniffer": "*"
},
"extra": {
"project-files-installed": [
"app/.htaccess",
"app/_config.php",
"app/_config/mysite.yml",
"app/src/Page.php",
"app/src/PageController.php"
],
"public-files-installed": [
".htaccess",
"index.php",
"install-frameworkmissing.html",
"install.php",
"web.config"
]
}
}

4021
composer.lock generated Normal file

File diff suppressed because it is too large Load diff

1
db.Dockerfile Normal file
View file

@ -0,0 +1 @@
FROM mysql:5

26
docker-compose.yml Normal file
View file

@ -0,0 +1,26 @@
version: "2.3"
networks:
nuth:
services:
cms:
build:
context: .
dockerfile: ./cms.Dockerfile
networks:
- nuth
ports:
- 8000:80
depends_on:
- db
db:
build:
context: .
dockerfile: ./db.Dockerfile
networks:
- nuth
ports:
- 13306:3306
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: SilverStripe

54
public/.htaccess Normal file
View file

@ -0,0 +1,54 @@
### SILVERSTRIPE START ###
# Deny access to templates (but allow from localhost)
<Files *.ss>
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Files>
# Deny access to IIS configuration
<Files web.config>
Order deny,allow
Deny from all
</Files>
# Deny access to YAML configuration files which might include sensitive information
<Files ~ "\.ya?ml$">
Order allow,deny
Deny from all
</Files>
# Route errors to static pages automatically generated by SilverStripe
ErrorDocument 404 /assets/error-404.html
ErrorDocument 500 /assets/error-500.html
<IfModule mod_rewrite.c>
# Turn off index.php handling requests to the homepage fixes issue in apache >=2.4
<IfModule mod_dir.c>
DirectoryIndex disabled
DirectorySlash On
</IfModule>
SetEnv HTTP_MOD_REWRITE On
RewriteEngine On
# Enable HTTP Basic authentication workaround for PHP running in CGI mode
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Deny access to potentially sensitive files and folders
RewriteRule ^vendor(/|$) - [F,L,NC]
RewriteRule ^\.env - [F,L,NC]
RewriteRule silverstripe-cache(/|$) - [F,L,NC]
RewriteRule composer\.(json|lock) - [F,L,NC]
RewriteRule (error|silverstripe|debug)\.log - [F,L,NC]
# Process through SilverStripe if no file with the requested name exists.
# Pass through the original path as a query parameter, and retain the existing parameters.
# Try finding framework in the vendor folder first
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php
</IfModule>
### SILVERSTRIPE END ###

4
public/assets/.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
/**/*
!.gitignore
!.htaccess
!web.config

35
public/assets/.htaccess Normal file
View file

@ -0,0 +1,35 @@
#
# Whitelist appropriate assets files.
# This file is automatically generated via File.allowed_extensions configuration
# See AssetAdapter::renderTemplate() for reference.
#
# We disable PHP via several methods
# Replace the handler with the default plaintext handler
AddHandler default-handler php phtml php3 php4 php5 inc
<IfModule mod_php5.c>
# Turn the PHP engine off
php_flag engine off
</IfModule>
<IfModule mod_rewrite.c>
<IfModule mod_env.c>
SetEnv HTTP_MOD_REWRITE On
</IfModule>
RewriteEngine On
# Allow error pages
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule error[^\\/]*\.html$ - [L]
# Block invalid file extensions
RewriteCond %{REQUEST_URI} !^[^.]*\.(?i:css|js|ace|arc|arj|asf|au|avi|bmp|bz2|cab|cda|csv|dmg|doc|docx|dotx|flv|gif|gpx|gz|hqx|ico|jpeg|jpg|kml|m4a|m4v|mid|midi|mkv|mov|mp3|mp4|mpa|mpeg|mpg|ogg|ogv|pages|pcx|pdf|png|pps|ppt|pptx|potx|ra|ram|rm|rtf|sit|sitx|tar|tgz|tif|tiff|txt|wav|webm|wma|wmv|xls|xlsx|xltx|zip|zipx)$
RewriteRule .* - [F]
# Non existant files passed to requesthandler
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* ../index.php [QSA]
</IfModule>

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

19
public/index.php Normal file
View file

@ -0,0 +1,19 @@
<?php
use SilverStripe\Control\HTTPApplication;
use SilverStripe\Control\HTTPRequestBuilder;
use SilverStripe\Core\CoreKernel;
use SilverStripe\Core\Startup\ErrorControlChainMiddleware;
// Find autoload.php
require __DIR__ . '/../vendor/autoload.php';
// Build request and detect flush
$request = HTTPRequestBuilder::createFromEnvironment();
// Default application
$kernel = new CoreKernel(BASE_PATH);
$app = new HTTPApplication($kernel);
$app->addMiddleware(new ErrorControlChainMiddleware($app));
$response = $app->handle($request);
$response->output();

37
scripts/install.sh Executable file
View file

@ -0,0 +1,37 @@
#!/bin/bash
appDir=$(dirname $(dirname $0))
destinationDir=$(pwd)
tempDir=$(mktemp -d)
rsync -a --delete $appDir/ $tempDir
# Cleaning up the built website
find $tempDir \
-mindepth 1 -maxdepth 1 -and \
-name "*" -and \
-not \( \
\( \
-path "$tempDir/app" -or \
-path "$tempDir/public" -or \
-path "$tempDir/themes" \
\) \
-prune \
\) -and \
-not -name ".htaccess" -and \
-not -name "composer.*" \
-exec rm -rf {} +
# Cleaning up the destination directory
find $destinationDir \
-mindepth 1 -maxdepth 1 -and \
-name "*" -and \
-not -name ".env" \
-exec rm -rf {} +
# Copying the built website to the destination
rsync -a $tempDir/ $destinationDir
# Installing the website
cd $destinationDir
composer install
composer exec -- sake dev/build