diff --git a/.gitignore b/.gitignore index ee6f7993f1..5a344fe2c7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,30 @@ -# exclude everything by default (this is a CMS!), and whitelist the safe stuff +# Exclude everything by default (this is a CMS!), and whitelist the safe stuff /* +!/README.md +!/ISSUE_TEMPLATE.md +!/LICENSE.txt + +# Vim +*.swp +*.swo + +# Git stuff +!.gitattributes +!.gitignore + +# October CMS packed node_modules conf.json -!.gitattributes -!.gitignore -!LICENSE.txt + +# Plugins !/plugins /plugins/october/demo + +# Themes !/themes /themes/demo + +# Docker +!/docker +/docker/mariadb/storage diff --git a/README.md b/README.md index 639e4fdd03..af3aa9e6fa 100644 --- a/README.md +++ b/README.md @@ -7,36 +7,39 @@ October instance. ### Dependencies -- PHP 5 (version used in production) -- [October](https://octobercms.com/) -- Some database (MySQL is recommended) +- [Docker](https://docker.com) - [Node.js](https://nodejs.org/) (6.x or newer) - If you cannot get a recent version from your distribution's repositories, try using [nvm](https://github.com/creationix/nvm). - [Yarn](https://yarnpkg.com/) -### Installing October and the Godot theme & plugins +### Running the site -- Download and install [October](http://octobercms.com/). - - Note that you don't need to install Apache or nginx, as PHP has a built-in - development server. You can start it with `php -S localhost:8080` which - will host a server in the current directory. -- If you have trouble with the installer, try to clone the repositories instead. - Running `composer install` then editing `config/database.php` with your - database credentials should get it up and running. -- Once installed, clone this repository into your October directory (you'll have - to clone into an empty directory and then move it into the October directory). -- Reassign the `active_theme` variable in `config/cms.php` to `godotengine`. -- You may have some errors at this point, these are most likely due to plugins. - If an error is thrown, it should tell you which plugin caused it. Replace - `authorname` and `pluginname` with the plugin you wish to run the command on. - - Try installing the new plugin like so: - `php artisan plugin:install authorname.pluginname` - - Or refreshing the plugin like so: - `php artisan plugin:refresh authorname.pluginname` - (warning, this will erase all the database entries!) - - Plugins which might need these commands run on them are `RainLab.Blog` and - `PaulVonZimmerman.Patreon` +- Clone this repo +- Put a database dump (if you have one) into the `/docker/mariadb/init` folder + - Make sure that your script starts with the line `USE october;` and that the file extension is `.sql` +- Run the `./docker/restart.sh` script (this will take a while the first time) +- You might need to reinstall some plugins `/docker/php/install-plugin.sh author.name` + - Replace `author.name` with the names in the `/plugins/[author]/[name]` folders +- See the website at [http://localhost:8080](http://localhost:8080) + +### Restoring a database + +- `mv /your/dump/backup-file.sql ./docker/mariadb/init` +- `./docker/mariadb/bash.sh` +- `cd /docker-entrypoint-initdb.d/` +- `mysql < 000-setup.sql` +- `mysql < backup-file.sql` + +### Interfacing with the Docker containers + +You can use the standard `docker exec -it godotengine-org--[php|mariadb] [command]` syntax or the following scripts: +- `./docker/php/bash.sh` +- `./docker/php/install-plugin.sh` +- `./docker/php/log.sh` +- `./docker/mariadb/bash.sh` +- `./docker/mariadb/log.sh` +- `./docker/mariadb/mysql.sh` ### Setting up the theme diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000000..f9998e2600 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,34 @@ +version: "3.4" + +networks: + godotengine-org--network: ~ + +services: + php: + build: + context: ./php + container_name: "godotengine-org--php" + depends_on: + - mariadb + networks: + - godotengine-org--network + restart: unless-stopped + ports: + - "8080:80" + volumes: + - ../plugins:/var/www/html/plugins + - ../themes/godotengine:/var/www/html/themes/godotengine + + mariadb: + image: mariadb + container_name: "godotengine-org--mariadb" + networks: + - godotengine-org--network + restart: unless-stopped + environment: + - MYSQL_ALLOW_EMPTY_PASSWORD=true + - MYSQL_USER=godot + - MYSQL_PASSWORD=godot + volumes: + - ./mariadb/storage:/var/lib/mysql + - ./mariadb/init:/docker-entrypoint-initdb.d diff --git a/docker/mariadb/bash.sh b/docker/mariadb/bash.sh new file mode 100755 index 0000000000..2ddecba832 --- /dev/null +++ b/docker/mariadb/bash.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker exec -it godotengine-org--mariadb /bin/bash diff --git a/docker/mariadb/init/000-setup.sql b/docker/mariadb/init/000-setup.sql new file mode 100644 index 0000000000..bf8db27975 --- /dev/null +++ b/docker/mariadb/init/000-setup.sql @@ -0,0 +1,4 @@ +CREATE USER IF NOT EXISTS 'godot'@'localhost' IDENTIFIED BY 'godot'; +CREATE DATABASE IF NOT EXISTS october; + +GRANT ALL PRIVILEGES ON october.* TO 'godot'@'%'; diff --git a/docker/mariadb/log.sh b/docker/mariadb/log.sh new file mode 100755 index 0000000000..e94d22a375 --- /dev/null +++ b/docker/mariadb/log.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +sudo docker logs -f godotengine-org--mariadb diff --git a/docker/mariadb/mysql.sh b/docker/mariadb/mysql.sh new file mode 100755 index 0000000000..cbad547492 --- /dev/null +++ b/docker/mariadb/mysql.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker exec -it godotengine-org--mariadb mysql diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile new file mode 100644 index 0000000000..99be7ca409 --- /dev/null +++ b/docker/php/Dockerfile @@ -0,0 +1,36 @@ +FROM php:apache + +# Settings +WORKDIR /var/www/html +ENV COMPOSER_ALLOW_SUPERUSER=1 + +# Install server dependencies +RUN apt-get update &&\ + apt-get install -y git unzip vim zlib1g-dev libzip-dev libpng-dev + +# Install PHP extensions +RUN docker-php-ext-install mysqli pdo pdo_mysql zip gd + +# Enable PHP modules +RUN a2enmod rewrite + +# Install composer +RUN curl -sS https://getcomposer.org/installer -o composer-setup.php &&\ + php composer-setup.php --install-dir=/usr/local/bin --filename=composer + +# Install OctoberCMS +RUN git init . &&\ + git remote add origin https://github.com/octobercms/october.git &&\ + git pull origin master &&\ + composer install + +# Config +RUN sed -i "s/'host' => 'localhost'/'host' => 'mariadb'/g" config/database.php +RUN sed -i "s/'database' => 'database'/'database' => 'october'/g" config/database.php +RUN sed -i "s/'username' => 'root'/'username' => 'godot'/g" config/database.php +RUN sed -i "s/'password' => ''/'password' => 'godot'/g" config/database.php + +RUN sed -i "s/'activeTheme' => 'demo'/'activeTheme' => 'godotengine'/g" config/cms.php + +# Set permissions +RUN chown www-data:www-data -R . diff --git a/docker/php/bash.sh b/docker/php/bash.sh new file mode 100755 index 0000000000..f90cd56cc6 --- /dev/null +++ b/docker/php/bash.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +sudo docker exec -it godotengine-org--php /bin/bash diff --git a/docker/php/install-plugin.sh b/docker/php/install-plugin.sh new file mode 100755 index 0000000000..b605147f97 --- /dev/null +++ b/docker/php/install-plugin.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker exec -it godotengine-org--php /usr/local/bin/php artisan plugin:install "$1" diff --git a/docker/php/log.sh b/docker/php/log.sh new file mode 100755 index 0000000000..e1ab72ba59 --- /dev/null +++ b/docker/php/log.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +sudo docker logs -f godotengine-org--php diff --git a/docker/restart.sh b/docker/restart.sh new file mode 100755 index 0000000000..e8b2ca9ae0 --- /dev/null +++ b/docker/restart.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +sudo docker-compose down && sudo docker-compose up --build -d