Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add devcontainer/Codespace support #121

Open
wants to merge 51 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
9991b72
build: add vscode remote container support
dinhtungdu Jun 29, 2020
32fbb63
build: remove unused Dockerfile
dinhtungdu Jun 29, 2020
898c9ac
build: fix nvm issue
dinhtungdu Jun 29, 2020
5f973fe
change default node version
dinhtungdu Jun 29, 2020
ceff5a0
build: add forwardPorts
dinhtungdu Jun 30, 2020
d3ccf71
build: update mariadb driver
dinhtungdu Jun 30, 2020
bd02bb6
build: mount the plugin to nginx container
dinhtungdu Jun 30, 2020
f5ccaf5
feat: config free devcontainer setup, allow simple copy and paste to …
dinhtungdu Jul 16, 2020
85bfefa
feat: detect composer and npm
dinhtungdu Jul 16, 2020
e51ecad
test: set node version to 10
dinhtungdu Jul 16, 2020
ad3d6f1
update: latest and greatest definition
dinhtungdu Jul 16, 2020
f20afdc
Try adding port to SITE_HOST per suggestion from @dustinrue
helen Sep 2, 2021
87228c3
Hardcode values for now, some kind of error
helen Sep 2, 2021
065d65e
Oops quotes
helen Sep 2, 2021
271a87c
Try using CODESPACE_NAME in SITE_HOST
helen Sep 2, 2021
75731ed
Let's get setup.sh running
helen Sep 2, 2021
9b2047e
Debug some vars
helen Sep 3, 2021
c8e2c51
Wait to install WP until after installing dependencies
helen Sep 5, 2021
c0c9557
Turn on XDEBUG
helen Sep 7, 2021
3e4cf4c
try: switch to wordpress image
dinhtungdu Sep 11, 2021
c6b32c1
ci: switch to wordpress image
dinhtungdu Sep 11, 2021
08589e8
fix: debug installing wordpress
dinhtungdu Sep 11, 2021
11f5113
fix: install git
dinhtungdu Sep 11, 2021
885dca0
fix: commands order
dinhtungdu Sep 11, 2021
3805da8
build image when starting the devcontainer
dinhtungdu Oct 7, 2021
065421e
Merge branch 'develop' into try/codespace
dinhtungdu Oct 7, 2021
3352a8b
Merge branch 'develop' into try/codespace
jeffpaul Oct 7, 2021
53036fc
Merge branch 'develop' into try/codespace
jeffpaul Dec 9, 2021
d17fc68
Merge branch 'develop' into try/codespace
cadic Apr 22, 2022
a29c23a
Merge branch 'develop' into try/codespace
cadic Apr 25, 2022
fdc1aaa
update setup script and debug extension
dinhtungdu Jul 6, 2022
48ffe80
Merge branch 'develop' into try/codespace
dinhtungdu Jul 6, 2022
e8605c4
Merge branch 'develop' into try/codespace
github-actions[bot] Sep 18, 2023
971fea2
Merge branch 'develop' into try/codespace
github-actions[bot] Oct 9, 2023
67e9bf2
Merge branch 'develop' into try/codespace
github-actions[bot] Oct 17, 2023
b3d6c6c
Merge branch 'develop' into try/codespace
github-actions[bot] Oct 17, 2023
57f91f6
Merge branch 'develop' into try/codespace
github-actions[bot] Nov 3, 2023
7180c07
Merge branch 'develop' into try/codespace
github-actions[bot] Nov 21, 2023
0e0d001
Merge branch 'develop' into try/codespace
github-actions[bot] Dec 4, 2023
cda90af
Merge branch 'develop' into try/codespace
github-actions[bot] Dec 6, 2023
e2577f1
Merge branch 'develop' into try/codespace
github-actions[bot] Jan 2, 2024
c4756f2
Merge branch 'develop' into try/codespace
github-actions[bot] Jan 2, 2024
7968a24
Merge branch 'develop' into try/codespace
github-actions[bot] Jan 2, 2024
ef30d88
Merge branch 'develop' into try/codespace
github-actions[bot] Jan 11, 2024
a0d91e1
Merge branch 'develop' into try/codespace
github-actions[bot] Jan 11, 2024
0f2e45c
Merge branch 'develop' into try/codespace
github-actions[bot] Jan 16, 2024
6714cd2
Merge branch 'develop' into try/codespace
github-actions[bot] Jan 16, 2024
8546ea0
Merge branch 'develop' into try/codespace
github-actions[bot] Jan 18, 2024
038b548
Merge branch 'develop' into try/codespace
github-actions[bot] Feb 12, 2024
5efeddb
Merge branch 'develop' into try/codespace
github-actions[bot] Feb 26, 2024
a4db1e0
Merge branch 'develop' into try/codespace
github-actions[bot] Mar 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM wordpress

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Santiagosaiz4superprize

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Santiagosaiz4


# Allow devcontainer/Codespace use www-data as the remote user instead of root.
RUN usermod --shell /bin/bash www-data
RUN touch /var/www/.bashrc
RUN chown -R www-data: /var/www/

# Install git & zip
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y git && \
apt-get install -y sudo && \
apt-get install -y zip

# Install Xdebug
RUN pecl install "xdebug" || true \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&& docker-php-ext-enable xdebug
RUN echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN apachectl restart

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Install WP CLI
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \
chmod +x wp-cli.phar && \
mv wp-cli.phar /usr/local/bin/wp

# Install nvm and node
RUN su www-data -c 'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash'
RUN su www-data -c 'export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && nvm install --lts'

# Allow www-data user to use sudo without password
RUN adduser www-data sudo
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
11 changes: 11 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "${localWorkspaceFolderBasename}",
"dockerComposeFile": "docker-compose.yml",
"service": "wordpress",
"forwardPorts": [ 8080 ],
// Add the IDs of extensions you want installed when the container is created.
"extensions": [ "xdebug.php-debug" ],
"workspaceFolder": "/var/www/html/",
"postCreateCommand": "/var/www/html/wp-content/plugins/${localWorkspaceFolderBasename}/.devcontainer/setup.sh",
"remoteUser": "www-data"
}
32 changes: 32 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: '3.1'

services:

wordpress:
build: .
restart: always
ports:
- 8080:80
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: exampleuser
WORDPRESS_DB_PASSWORD: examplepass
WORDPRESS_DB_NAME: exampledb
volumes:
- wordpress:/var/www/html
- "../:/var/www/html/wp-content/plugins/simple-podcasting"

db:
image: mariadb
restart: always
environment:
MYSQL_DATABASE: exampledb
MYSQL_USER: exampleuser
MYSQL_PASSWORD: examplepass
MYSQL_RANDOM_ROOT_PASSWORD: '1'
volumes:
- db:/var/lib/mysql

volumes:
wordpress:
db:
46 changes: 46 additions & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#! /bin/bash
CURRENT_WORKING_DIR="$(pwd)"
PROJECT_DIR="$(dirname "$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" )"
SLUG="$(basename "$PROJECT_DIR")"
PROJECT_TYPE=plugin
if [ -f "$PROJECT_DIR/style.css" ]; then
PROJECT_TYPE=theme
fi

if [[ ! -z "$CODESPACE_NAME" ]]
then
SITE_HOST="https://${CODESPACE_NAME}-8080.githubpreview.dev"
else
SITE_HOST="http://localhost:8080"
fi

exec 3>&1 4>&2
trap 'exec 2>&4 1>&3' 0 1 2 3
exec 1>setup.log 2>&1

# Prepare a nice name from project name for the site title.
function getTitleFromSlug()
{
local _slug=${SLUG//-/ }
local __slug=${_slug//_/ }
local ___slug=( $__slug )
echo "${___slug[@]^}"
}

source ~/.bashrc

# Install dependencies
cd /var/www/html/wp-content/${PROJECT_TYPE}s/${SLUG}/
npm i && npm run build
composer i

# Install WordPress and activate the plugin/theme.
cd /var/www/html/
echo "Setting up WordPress at $SITE_HOST"
wp db reset --yes
wp core install --url="$SITE_HOST" --title="$(getTitleFromSlug) Development" --admin_user="admin" --admin_email="[email protected]" --admin_password="password" --skip-email

echo "Activate $SLUG"
wp $PROJECT_TYPE activate $SLUG

exit 0
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ Session.vim
Thumbs.db
Desktop.ini

.env
setup.log

# E2E testing
.wp-env.override.json
artifacts
Expand Down
Loading