├── .gitignore
├── composer.json
├── conf
├── .htaccess
├── launch.json
├── client.cnf
├── apache.env.sh
├── mysql-bashrc-launch.sh
├── php.ini
├── mysql.cnf
├── apache.conf
├── wp-config.php
└── .bashrc.sh
├── package.json
├── .init.sh
├── main.php
├── .gitpod.yml
├── LICENSE
├── .gitpod.dockerfile
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | /vendor/
2 | /node_modules/
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vendor/app"
3 | }
4 |
--------------------------------------------------------------------------------
/conf/.htaccess:
--------------------------------------------------------------------------------
1 | # php.ini local settings
2 | php_value memory_limit 256M
3 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@vendor/app",
3 | "version": "1.0.0",
4 | "license": "MIT"
5 | }
6 |
--------------------------------------------------------------------------------
/conf/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | "configurations": [
3 | {
4 | "name": "Listen for XDebug",
5 | "type": "php",
6 | "request": "launch",
7 | "port": 9000
8 | }
9 | ]
10 | }
11 |
--------------------------------------------------------------------------------
/conf/client.cnf:
--------------------------------------------------------------------------------
1 | [client]
2 | host = localhost
3 | user = root
4 | password =
5 | socket = /var/run/mysqld/mysqld.sock
6 | [mysql_upgrade]
7 | host = localhost
8 | user = root
9 | password =
10 | socket = /var/run/mysqld/mysqld.sock
11 |
--------------------------------------------------------------------------------
/.init.sh:
--------------------------------------------------------------------------------
1 | # docs: https://developer.wordpress.org/cli/commands/plugin/
2 |
3 | wp rewrite structure '/%year%/%monthnum%/%postname%/'
4 |
5 | wp plugin delete hello
6 | wp plugin delete akismet
7 | wp plugin activate ${REPO_NAME}
8 |
9 | # wp plugin install plugin_slug --activate
10 |
--------------------------------------------------------------------------------
/conf/apache.env.sh:
--------------------------------------------------------------------------------
1 | export APACHE_SERVER_NAME=$(gp url 8080 | sed -e s/https:\\/\\/// | sed -e s/\\///)
2 | export APACHE_RUN_USER="gitpod"
3 | export APACHE_RUN_GROUP="gitpod"
4 | export APACHE_RUN_DIR=/var/run/apache2
5 | export APACHE_PID_FILE="$APACHE_RUN_DIR/apache.pid"
6 | export APACHE_LOCK_DIR=/var/lock/apache2
7 | export APACHE_LOG_DIR=/var/log/apache2
8 |
--------------------------------------------------------------------------------
/main.php:
--------------------------------------------------------------------------------
1 |
Hello World from Gitpod Test Plugin
';
18 | } );
19 |
--------------------------------------------------------------------------------
/conf/mysql-bashrc-launch.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # this script is intended to be called from .bashrc
4 | # This is a workaround for not having something like supervisord
5 |
6 | if [ ! -e /var/run/mysqld/gitpod-init.lock ]
7 | then
8 | touch /var/run/mysqld/gitpod-init.lock
9 |
10 | # initialize database structures on disk, if needed
11 | [ ! -d /workspace/mysql ] && mysqld --initialize-insecure
12 |
13 | # launch database, if not running
14 | [ ! -e /var/run/mysqld/mysqld.pid ] && mysqld --daemonize
15 |
16 | rm /var/run/mysqld/gitpod-init.lock
17 | fi
18 |
--------------------------------------------------------------------------------
/.gitpod.yml:
--------------------------------------------------------------------------------
1 | image:
2 | file: .gitpod.dockerfile
3 |
4 | ports:
5 | - port: 8080
6 | onOpen: open-preview
7 | - port: 3306
8 | onOpen: ignore
9 | - port: 8025
10 | onOpen: ignore
11 | - port: 1025
12 | onOpen: ignore
13 | - port: 9000
14 | onOpen: ignore
15 |
16 | tasks:
17 | - init: gp await-port 3306 && wp-setup-plugin # or wp-setup-theme
18 | command: apache2ctl start # start Apache server
19 |
20 | # start MailHog (SMTP testing tool)
21 | - command: mailhog -api-bind-addr 127.0.0.1:8025 -ui-bind-addr 127.0.0.1:8025 -smtp-bind-addr 127.0.0.1:1025
22 |
--------------------------------------------------------------------------------
/conf/php.ini:
--------------------------------------------------------------------------------
1 | # custom settings
2 | error_reporting = E_ALL
3 | display_errors = On
4 | display_startup_errors = On
5 | max_execution_time = 300
6 | max_input_vars = 4000
7 | memory_limit = 128M
8 | post_max_size = 512M
9 | upload_max_filesize = 512M
10 |
11 | opcache.enable=1
12 | opcache.enable_cli=1
13 | opcache.memory_consumption=128
14 | opcache.interned_strings_buffer=8
15 | opcache.max_accelerated_files=4000
16 | opcache.revalidate_freq=60
17 | opcache.fast_shutdown=1
18 |
19 | sendmail_path = /usr/local/bin/mhsendmail
20 |
21 | xdebug.remote_enable = 1
22 | xdebug.remote_log="${GITPOD_REPO_ROOT}/xdebug.log"
23 | xdebug.remote_autostart = 1
24 | xdebug.remote_host='0.0.0.0'
25 |
--------------------------------------------------------------------------------
/conf/mysql.cnf:
--------------------------------------------------------------------------------
1 | [mysqld_safe]
2 | socket = /var/run/mysqld/mysqld.sock
3 | nice = 0
4 |
5 | [mysqld]
6 | user = gitpod
7 | pid-file = /var/run/mysqld/mysqld.pid
8 | socket = /var/run/mysqld/mysqld.sock
9 | port = 3306
10 | basedir = /usr
11 | datadir = /workspace/mysql
12 | tmpdir = /tmp
13 | lc-messages-dir = /usr/share/mysql
14 | skip-external-locking
15 | bind-address = 127.0.0.1
16 |
17 | key_buffer_size = 16M
18 | max_allowed_packet = 16M
19 | thread_stack = 192K
20 | thread_cache_size = 8
21 |
22 | myisam-recover-options = BACKUP
23 | query_cache_limit = 1M
24 | query_cache_size = 16M
25 |
26 | general_log_file = /var/log/mysql/mysql.log
27 | general_log = 1
28 | log_error = /var/log/mysql/error.log
29 |
30 | expire_logs_days = 10
31 | max_binlog_size = 100M
32 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Luiz Paulo "Bills"
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/conf/apache.conf:
--------------------------------------------------------------------------------
1 | # Apache httpd v2.4 minimal configuration
2 | # see https://wiki.apache.org/httpd/Minimal_Config for documentation
3 |
4 | ServerRoot ${GITPOD_REPO_ROOT}
5 |
6 | PidFile ${APACHE_PID_FILE}
7 | User ${APACHE_RUN_USER}
8 | Group ${APACHE_RUN_GROUP}
9 |
10 | # Modules as installed/activated via apt-get
11 | IncludeOptional /etc/apache2/mods-enabled/*.load
12 | IncludeOptional /etc/apache2/mods-enabled/*.conf
13 |
14 | # Configure hostname and port for server
15 | ServerName ${APACHE_SERVER_NAME}
16 | Listen *:8080
17 |
18 | # Configure Logging
19 | LogFormat "%h %l %u %t \"%r\" %>s %b" common
20 | CustomLog ${APACHE_LOG_DIR}/access.log common
21 | ErrorLog ${APACHE_LOG_DIR}/error.log
22 |
23 | # Never change this block
24 |
25 | AllowOverride None
26 | Require all denied
27 |
28 |
29 | # Direcrory and files to be served
30 | DirectoryIndex index.html index.php
31 | DocumentRoot "${GITPOD_REPO_ROOT}/${APACHE_DOCROOT}"
32 |
33 | Require all granted
34 | AllowOverride All
35 |
36 |
37 | # Include conf installed via apt-get
38 | IncludeOptional /etc/apache2/conf-enabled/*.conf
39 |
--------------------------------------------------------------------------------
/conf/wp-config.php:
--------------------------------------------------------------------------------
1 | > $HOME/.bashrc && \
15 | . $HOME/.bashrc && \
16 | bash -c ". .nvm/nvm.sh && nvm install --lts"
17 |
18 | ### MailHog ###
19 | USER root
20 | ARG DEBIAN_FRONTEND=noninteractive
21 | RUN go get github.com/mailhog/MailHog && \
22 | go get github.com/mailhog/mhsendmail && \
23 | cp $GOPATH/bin/MailHog /usr/local/bin/mailhog && \
24 | cp $GOPATH/bin/mhsendmail /usr/local/bin/mhsendmail && \
25 | ln $GOPATH/bin/mhsendmail /usr/sbin/sendmail && \
26 | ln $GOPATH/bin/mhsendmail /usr/bin/mail &&\
27 | ### Apache ###
28 | apt-get -y install apache2 && \
29 | chown -R gitpod:gitpod /var/run/apache2 /var/lock/apache2 /var/log/apache2 && \
30 | echo "include $HOME/gitpod-wordpress/conf/apache.conf" > /etc/apache2/apache2.conf && \
31 | echo ". $HOME/gitpod-wordpress/conf/apache.env.sh" > /etc/apache2/envvars && \
32 | ### PHP ###
33 | apt-get -qy purge php* && \
34 | add-apt-repository ppa:ondrej/php && \
35 | apt-get update && \
36 | apt-get -qy install \
37 | libapache2-mod-php \
38 | php${PHP_VERSION} \
39 | php${PHP_VERSION}-common \
40 | php${PHP_VERSION}-cli \
41 | php${PHP_VERSION}-mbstring \
42 | php${PHP_VERSION}-curl \
43 | php${PHP_VERSION}-gd \
44 | php${PHP_VERSION}-intl \
45 | php${PHP_VERSION}-mysql \
46 | php${PHP_VERSION}-xml \
47 | php${PHP_VERSION}-json \
48 | php${PHP_VERSION}-zip \
49 | php${PHP_VERSION}-soap \
50 | php${PHP_VERSION}-bcmath \
51 | php${PHP_VERSION}-opcache \
52 | php-xdebug && \
53 | apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* && \
54 | update-alternatives --set php /usr/bin/php${PHP_VERSION} && \
55 | cat /home/gitpod/gitpod-wordpress/conf/php.ini >> /etc/php/${PHP_VERSION}/apache2/php.ini && \
56 | ### Setup PHP in Apache ###
57 | a2dismod php* && \
58 | a2dismod mpm_* && \
59 | a2enmod mpm_prefork && \
60 | a2enmod php${PHP_VERSION} && \
61 | ### WP-CLI ###
62 | wget -q https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O $HOME/wp-cli.phar && \
63 | chmod +x $HOME/wp-cli.phar && \
64 | mv $HOME/wp-cli.phar /usr/local/bin/wp && \
65 | chown gitpod:gitpod /usr/local/bin/wp
66 |
67 | USER gitpod
68 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Gitpod for WordPress
2 |
3 | [Gitpod](https://www.gitpod.io) is a ready-to-code dev environment with a single click. It will allows you to develop plugin or theme directly from your browser.
4 |
5 | [](https://gitpod.io/#https://github.com/luizbills/gitpod-wordpress)
6 |
7 | ## Features
8 |
9 | - LAMP (Apache, MySQL, PHP)
10 | - [Composer](https://getcomposer.org/)
11 | - [Adminer](https://www.adminer.org/)
12 | - [NVM](https://github.com/nvm-sh/nvm)
13 | - [Node.js](https://nodejs.org/) (LTS)
14 | - [Xdebug](https://xdebug.org)
15 | - [WP-CLI](https://wp-cli.org/)
16 | - Git
17 | - SVN
18 | - [MailHog](https://github.com/mailhog/MailHog)
19 |
20 | ## Install
21 |
22 | Just copy the [`.gitpod.yml`](/.gitpod.yml) and [`.gitpod.dockerfile`](/.gitpod.dockerfile) to your project root directory and push to your remote repository.
23 |
24 | - If your project is a theme, change the `wp-setup-plugin` to `wp-setup-theme` in your `.gitpod.yml`.
25 | - By default, the webserver will use PHP `v7.3`. If you need a different version, change it on `ENV PHP_VERSION` in your `.gitpod.dockerfile` (line 4).
26 |
27 | Also, the `wp-setup-plugin` (or `wp-setup-theme`) will search for a `.init.sh` file in your project root directory and execute it (if exists). Then, you can use the `wp-cli` to install plugins, install themes, and [more](https://developer.wordpress.org/cli/commands/). Or create your own tasks.
28 |
29 | ```sh
30 | # .init.sh
31 | wp plugin install woocommerce --activate # install WooCommerce
32 | wp plugin activate ${REPO_NAME} # activate your plugin
33 | ```
34 |
35 | Project dependencies (in `composer.json` or `package.json`) are automatically installed.
36 |
37 | ## Usage
38 |
39 | Now you access `https://gitpod.io/#`.
40 |
41 | > Example: [https://gitpod.io/#https://github.com/luizbills/wp-tweaks/](https://gitpod.io/#https://github.com/luizbills/wp-tweaks/)
42 |
43 | Your admin credentials:
44 |
45 | ```
46 | username: admin
47 | password: password
48 | ```
49 |
50 | ### Utilities
51 |
52 | - You can use the following commands in terminal:
53 | - `browse-url `: open an endpoint of your WordPress installation.
54 | - `browse-home`: alias for `browse-url /` (your Homepage)
55 | - `browse-wpadmin`: alias for `browse-url /wp-admin` (WordPress Admin Painel)
56 | - `browse-dbadmin`: alias for `browse-url /database` (to manage your database with Adminer)
57 | - `browse-phpinfo`: alias for `browse-url /phpinfo` (a page with ``)
58 | - `browse-emails`: open the MailHog client
59 |
60 | - You can setup your PHP on `.htaccess` file (eg: `php_value max_execution_time 600`)
61 |
62 | ## Contributing
63 |
64 | To contribute, follow these steps:
65 |
66 | 1. Fork this repository.
67 | 1. Create a branch: `git checkout -b `.
68 | 1. Make your changes and commit them: `git commit -m ''`
69 | 1. Push to your fork: `git push origin `
70 | 1. Create the Pull Request.
71 |
72 | Alternatively see the GitHub documentation on [creating a pull request](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request).
73 |
74 | Just found a bug? Report it on GitHub [Issues](https://github.com/luizbills/gitpod-wordpress/issues).
75 |
76 | ## LICENSE
77 |
78 | MIT © 2019 Luiz Paulo "Bills"
79 |
80 | ---
81 |
82 | Made with ❤ in Brazil
83 |
--------------------------------------------------------------------------------
/conf/.bashrc.sh:
--------------------------------------------------------------------------------
1 |
2 | # WordPress Setup Script
3 | export REPO_NAME=$(basename $GITPOD_REPO_ROOT)
4 |
5 | function wp-init-database () {
6 | # user = wordpress
7 | # password = wordpress
8 | # database = wordpress
9 | mysql -e "CREATE DATABASE wordpress /*\!40100 DEFAULT CHARACTER SET utf8 */;"
10 | mysql -e "CREATE USER wordpress@localhost IDENTIFIED BY 'wordpress';"
11 | mysql -e "GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'localhost';"
12 | mysql -e "FLUSH PRIVILEGES;"
13 | }
14 |
15 | function wp-setup () {
16 | FLAG="$HOME/.wordpress-installed"
17 |
18 | # search the flag file
19 | if [ -f $FLAG ]; then
20 | echo 'WordPress already installed'
21 | return 1
22 | fi
23 |
24 | echo 'Please, wait ...'
25 |
26 | # this would cause mv below to match hidden files
27 | shopt -s dotglob
28 |
29 | # move the workspace temporarily
30 | mkdir $HOME/workspace
31 | mv ${GITPOD_REPO_ROOT}/* $HOME/workspace/
32 |
33 | # create a debugger launch.json
34 | mkdir -p ${GITPOD_REPO_ROOT}/.theia
35 | mv $HOME/gitpod-wordpress/conf/launch.json ${GITPOD_REPO_ROOT}/.theia/launch.json
36 |
37 | # create a database for this WordPress
38 | echo 'Creating MySQL user and database ...'
39 | wp-init-database 1> /dev/null
40 |
41 | # install WordPress
42 | rm -rf ${GITPOD_REPO_ROOT}/${APACHE_DOCROOT}
43 | mkdir -p ${GITPOD_REPO_ROOT}/${APACHE_DOCROOT}
44 | cd ${GITPOD_REPO_ROOT}/${APACHE_DOCROOT}/
45 |
46 | echo 'Downloading WordPress ...'
47 | wp core download --path="${GITPOD_REPO_ROOT}/${APACHE_DOCROOT}/"
48 |
49 | echo 'Installing WordPress ...'
50 | cp $HOME/gitpod-wordpress/conf/wp-config.php ${GITPOD_REPO_ROOT}/${APACHE_DOCROOT}/wp-config.php
51 | wp core install \
52 | --url="$(gp url 8080 | sed -e s/https:\\/\\/// | sed -e s/\\///)" \
53 | --title="WordPress" \
54 | --admin_user="admin" \
55 | --admin_password="password" \
56 | --admin_email="admin@gitpod.test" \
57 | --path="${GITPOD_REPO_ROOT}/${APACHE_DOCROOT}/"
58 |
59 | echo 'Downloading Adminer ...'
60 | mkdir ${GITPOD_REPO_ROOT}/${APACHE_DOCROOT}/database/
61 | wget -q https://www.adminer.org/latest.php -O ${GITPOD_REPO_ROOT}/${APACHE_DOCROOT}/database/index.php
62 |
63 | echo 'Creating phpinfo() page ...'
64 | mkdir ${GITPOD_REPO_ROOT}/${APACHE_DOCROOT}/phpinfo/
65 | echo "" > ${GITPOD_REPO_ROOT}/${APACHE_DOCROOT}/phpinfo/index.php
66 |
67 | # put the project files in the correct place
68 | echo 'Creating project files ...'
69 | PROJECT_PATH=${GITPOD_REPO_ROOT}/${APACHE_DOCROOT}/wp-content/$1/${REPO_NAME}
70 | mkdir -p $PROJECT_PATH
71 | mv $HOME/workspace/* ${PROJECT_PATH}
72 | cd $DESTINATION
73 |
74 | # install project dependencies
75 | if [ -f composer.json ]; then
76 | echo 'Installing Composer packages ...'
77 | composer update 2> /dev/null
78 | fi
79 |
80 | if [ -f package.json ]; then
81 | echo 'Installing NPM packages ...'
82 | npm i 2> /dev/null
83 | fi
84 |
85 | if [ -f ${PROJECT_PATH}/.init.sh ]; then
86 | echo '.init.sh detected ...'
87 | cp ${PROJECT_PATH}/.init.sh ${GITPOD_REPO_ROOT}/${APACHE_DOCROOT}/.init.sh
88 | echo 'Running your .init.sh ...'
89 | cd ${GITPOD_REPO_ROOT}/${APACHE_DOCROOT}/
90 | /bin/bash ${GITPOD_REPO_ROOT}/${APACHE_DOCROOT}/.init.sh
91 | rm -rf ${GITPOD_REPO_ROOT}/${APACHE_DOCROOT}/.init.sh
92 | fi
93 |
94 | # finish
95 | shopt -u dotglob
96 | touch $FLAG
97 |
98 | echo 'Done!'
99 | }
100 |
101 | function wp-setup-theme () {
102 | wp-setup "themes"
103 | }
104 |
105 | function wp-setup-plugin () {
106 | wp-setup "plugins"
107 | }
108 |
109 | export -f wp-setup-theme
110 | export -f wp-setup-plugin
111 |
112 | # Helpers
113 | function browse-url () {
114 | ENDPOINT=${1:-""}
115 | PORT=${2:-"8080"}
116 | URL=$(gp url $PORT | sed -e s/https:\\/\\/// | sed -e s/\\///)
117 | gp preview "${URL}${ENDPOINT}"
118 | }
119 |
120 | function browse-home () {
121 | browse-url "/"
122 | }
123 |
124 | function browse-wpadmin () {
125 | browse-url "/wp-admin"
126 | }
127 |
128 | function browse-dbadmin () {
129 | browse-url "/database"
130 | }
131 |
132 | function browse-phpinfo () {
133 | browse-url "/phpinfo"
134 | }
135 |
136 | function browse-emails () {
137 | browse-url "/" "8025"
138 | }
139 |
140 | export -f browse-url
141 | export -f browse-home
142 | export -f browse-wpadmin
143 | export -f browse-dbadmin
144 | export -f browse-phpinfo
145 | export -f browse-emails
146 |
147 | # load NVM
148 | export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
149 | [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
150 |
151 | # use Node.js LTS
152 | nvm use lts/* > /dev/null
153 | export NODE_VERSION=$(node -v | sed 's/v//g')
154 |
--------------------------------------------------------------------------------