Compare commits
9 Commits
055d993259
...
main
Author | SHA1 | Date | |
---|---|---|---|
d87f29923d | |||
c7a8d980b3 | |||
7c613510bf | |||
43fd49bf40 | |||
82d741d690 | |||
2ef8c257ed | |||
292b43815d | |||
9e13af4ddb | |||
2da7726458 |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/web/
|
17
.lando.yml
Normal file
17
.lando.yml
Normal file
@ -0,0 +1,17 @@
|
||||
name: sample-block-theme
|
||||
recipe: wordpress
|
||||
config:
|
||||
webroot: web
|
||||
services:
|
||||
appserver:
|
||||
overrides:
|
||||
volumes:
|
||||
- ./sample-wp-block-theme/:/app/web/wp-content/themes/sample-wp-block-theme
|
||||
build:
|
||||
- wp --path=/app/web/ core download
|
||||
- wp --path=/app/web/ config create --skip-check --force --dbuser=wordpress --dbname=wordpress --dbpass=wordpress --dbhost=database
|
||||
events:
|
||||
pre-rebuild:
|
||||
- 'find web -depth -regextype posix-extended -mindepth 1 ! -regex ".*sample-wp-block-theme.*" -delete || true'
|
||||
post-destroy:
|
||||
- 'find web -depth -regextype posix-extended -mindepth 1 ! -regex ".*sample-wp-block-theme.*" -delete || true'
|
@ -1,4 +1,5 @@
|
||||
{
|
||||
"core": null,
|
||||
"theme": [ "." ]
|
||||
}
|
||||
"themes": [ "./sample-wp-block-theme" ],
|
||||
"plugins": [ "wp-dummy-content-generator" ]
|
||||
}
|
||||
|
45
README.md
45
README.md
@ -14,13 +14,56 @@ Repo for practice task for Autonomic front-end recruitment.
|
||||
|
||||
## Running the site locally
|
||||
|
||||
You can launch an instance of WordPress pre-loaded with this theme using the `wp-env` tool.
|
||||
**Note** With all methods, you'll see a white screen when you visit the local
|
||||
instance, because this theme is blank! You can check things are working by
|
||||
visiting the local URL before the `theme activate` step, or just go straight to
|
||||
the dashboard at `/wp-admin` and start hacking.
|
||||
|
||||
### `wp-env`
|
||||
|
||||
**Note** The latest `wp-env` requires "Docker Compose V2"; if `docker compose`
|
||||
gives `'compose' is not a docker command.` then run `npm -g i
|
||||
@wordpress/env@8.13.0` instead of the first command.
|
||||
|
||||
You can launch an instance of WordPress pre-installed with this theme using the `wp-env` tool.
|
||||
|
||||
```sh
|
||||
$ npm -g i @wordpress/env
|
||||
$ cd /path/to/theme/Repo
|
||||
$ wp-env start
|
||||
$ wp-env run cli wp theme activate sample-wp-block-theme
|
||||
```
|
||||
|
||||
This will launch a WordPress local instance at http://localhost:8888. You can log into the dashboard at http://localhost:8888/wp-admin with `admin` as the username and `password` as the password.
|
||||
|
||||
**Note:** This method assumes you already have `docker` and `docker-compose` installed locally.
|
||||
|
||||
### Lando
|
||||
|
||||
Install Lando, then:
|
||||
|
||||
```sh
|
||||
$ lando start
|
||||
$ lando wp --path=/app/web/ core install \
|
||||
--title="Dev Env" \
|
||||
--admin_user=admin --admin_password=admin --admin_email=admin@example.com \
|
||||
--skip-email --url=https://sample-block-theme.lndo.site/
|
||||
$ lando wp --path=/app/web/ theme activate sample-wp-block-theme
|
||||
```
|
||||
|
||||
### docker-compose
|
||||
|
||||
Install Docker-compose, then:
|
||||
|
||||
```sh
|
||||
$ docker-compose up -d
|
||||
# wait a few seconds, run `docker-compose logs` to check start-up
|
||||
$ docker-compose exec --user=user wordpress wp core install \
|
||||
--title="Dev Env" \
|
||||
--admin_user=admin --admin_password=admin --admin_email=admin@example.com \
|
||||
--skip-email --url=http://sample-block-theme.localhost:8080
|
||||
$ docker-compose exec --user=user wordpress wp theme activate sample-wp-block-theme
|
||||
```
|
||||
|
||||
This should also work with `docker compose` (i.e. newwer Docker / Compose 2);
|
||||
just replace `docker-compose` with `docker compose` in the above.
|
||||
|
44
docker-compose.yml
Normal file
44
docker-compose.yml
Normal file
@ -0,0 +1,44 @@
|
||||
---
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
wordpress:
|
||||
image: "wordpress"
|
||||
ports:
|
||||
- "8080:80"
|
||||
dns: 4.2.2.4
|
||||
volumes:
|
||||
- "./entrypoint.sh:/usr/local/bin/entrypoint.sh:z"
|
||||
- "./sample-wp-block-theme/:/var/www/html/wp-content/themes/sample-wp-block-theme:z"
|
||||
entrypoint: ["/usr/local/bin/entrypoint.sh"]
|
||||
networks:
|
||||
- backend
|
||||
environment:
|
||||
- WORDPRESS_DB_HOST=db
|
||||
- WORDPRESS_DB_USER=wordpress
|
||||
- WORDPRESS_DB_PASSWORD=wordpress
|
||||
- WORDPRESS_DB_NAME=wordpress
|
||||
- WORDPRESS_TABLE_PREFIX=wp_
|
||||
- PAGER=more
|
||||
container_name: "samplewpblocktheme_wordpress"
|
||||
|
||||
db:
|
||||
image: "mariadb:10.6"
|
||||
ports:
|
||||
- 3306:3306
|
||||
volumes:
|
||||
- "mariadb:/var/lib/mysql"
|
||||
networks:
|
||||
- backend
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=wordpress
|
||||
- MYSQL_DATABASE=wordpress
|
||||
- MYSQL_USER=wordpress
|
||||
- MYSQL_PASSWORD=wordpress
|
||||
container_name: "samplewpblocktheme_db"
|
||||
|
||||
volumes:
|
||||
mariadb:
|
||||
|
||||
networks:
|
||||
backend:
|
50
entrypoint.sh
Executable file
50
entrypoint.sh
Executable file
@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -n "$PHP_EXTENSIONS" ]; then
|
||||
for extension in $PHP_EXTENSIONS; do
|
||||
if ! php -m | grep -q $extension; then
|
||||
docker-php-ext-install $PHP_EXTENSIONS
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if ! id -u "user" >/dev/null ; then
|
||||
useradd -u 1000 -m user
|
||||
mkdir /var/www/html/vendor
|
||||
chown -R user:user /var/www/html/vendor
|
||||
fi
|
||||
|
||||
if [ ! -x /usr/bin/unzip ]; then
|
||||
apt update && apt install unzip
|
||||
fi
|
||||
|
||||
if [ ! -x /usr/local/bin/wp ]; then
|
||||
curl -z /usr/local/bin/wp -o /usr/local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
|
||||
chmod +x /usr/local/bin/wp
|
||||
fi
|
||||
|
||||
if [ ! -x /usr/local/bin/composer ]; then
|
||||
mkdir -p /var/www/.composer
|
||||
chown user:user /var/www/.composer
|
||||
|
||||
curl https://getcomposer.org/installer -o /tmp/composer-setup.php
|
||||
php -r "if (hash_file('sha384', '/tmp/composer-setup.php') === 'e21205b207c3ff031906575712edab6f13eb0b361f2085f1f1237b7126d785e826a450292b6cfd1d64d92e6563bbde02') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
|
||||
php /tmp/composer-setup.php
|
||||
rm /tmp/composer-setup.php
|
||||
|
||||
mv /var/www/html/composer.phar /usr/local/bin/composer
|
||||
fi
|
||||
|
||||
export APACHE_RUN_USER=user
|
||||
export APACHE_RUN_GROUP=user
|
||||
|
||||
# Increase PHP memory limiit because it's A HOG
|
||||
echo 'memory_limit = 256M' >> /usr/local/etc/php/conf.d/docker-php-memlimit.ini;
|
||||
|
||||
if [ -n "$@" ]; then
|
||||
"$@"
|
||||
fi
|
||||
|
||||
# Upstream ENTRYPOINT
|
||||
# https://github.com/docker-library/wordpress/blob/master/php7.4/apache/Dockerfile#L120
|
||||
/usr/local/bin/docker-entrypoint.sh apache2-foreground
|
@ -4,5 +4,7 @@ add_action('init', 'custom_stylesheet');
|
||||
|
||||
function custom_stylesheet() {
|
||||
wp_register_style( 'custom-styles', get_template_directory_uri() . '/style.css' );
|
||||
wp_enqueue_style( 'custom-styles' );
|
||||
}
|
||||
wp_enqueue_style( 'custom-styles' );
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'custom_stylesheet' );
|
8
sample-wp-block-theme/theme.json
Normal file
8
sample-wp-block-theme/theme.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"version": 2,
|
||||
"$schema": "https://schemas.wp.org/trunk/theme.json",
|
||||
"settings": {
|
||||
"useRootPaddingAwareAlignments": true,
|
||||
"appearanceTools": true
|
||||
}
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
{
|
||||
"version": 2,
|
||||
"$schema": "https://schemas.wp.org/trunk/theme.json"
|
||||
}
|
Reference in New Issue
Block a user