-
Notifications
You must be signed in to change notification settings - Fork 30
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
dinhtungdu
wants to merge
51
commits into
develop
Choose a base branch
from
try/codespace
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 32fbb63
build: remove unused Dockerfile
dinhtungdu 898c9ac
build: fix nvm issue
dinhtungdu 5f973fe
change default node version
dinhtungdu ceff5a0
build: add forwardPorts
dinhtungdu d3ccf71
build: update mariadb driver
dinhtungdu bd02bb6
build: mount the plugin to nginx container
dinhtungdu f5ccaf5
feat: config free devcontainer setup, allow simple copy and paste to …
dinhtungdu 85bfefa
feat: detect composer and npm
dinhtungdu e51ecad
test: set node version to 10
dinhtungdu ad3d6f1
update: latest and greatest definition
dinhtungdu f20afdc
Try adding port to SITE_HOST per suggestion from @dustinrue
helen 87228c3
Hardcode values for now, some kind of error
helen 065d65e
Oops quotes
helen 271a87c
Try using CODESPACE_NAME in SITE_HOST
helen 75731ed
Let's get setup.sh running
helen 9b2047e
Debug some vars
helen c8e2c51
Wait to install WP until after installing dependencies
helen c0c9557
Turn on XDEBUG
helen 3e4cf4c
try: switch to wordpress image
dinhtungdu c6b32c1
ci: switch to wordpress image
dinhtungdu 08589e8
fix: debug installing wordpress
dinhtungdu 11f5113
fix: install git
dinhtungdu 885dca0
fix: commands order
dinhtungdu 3805da8
build image when starting the devcontainer
dinhtungdu 065421e
Merge branch 'develop' into try/codespace
dinhtungdu 3352a8b
Merge branch 'develop' into try/codespace
jeffpaul 53036fc
Merge branch 'develop' into try/codespace
jeffpaul d17fc68
Merge branch 'develop' into try/codespace
cadic a29c23a
Merge branch 'develop' into try/codespace
cadic fdc1aaa
update setup script and debug extension
dinhtungdu 48ffe80
Merge branch 'develop' into try/codespace
dinhtungdu e8605c4
Merge branch 'develop' into try/codespace
github-actions[bot] 971fea2
Merge branch 'develop' into try/codespace
github-actions[bot] 67e9bf2
Merge branch 'develop' into try/codespace
github-actions[bot] b3d6c6c
Merge branch 'develop' into try/codespace
github-actions[bot] 57f91f6
Merge branch 'develop' into try/codespace
github-actions[bot] 7180c07
Merge branch 'develop' into try/codespace
github-actions[bot] 0e0d001
Merge branch 'develop' into try/codespace
github-actions[bot] cda90af
Merge branch 'develop' into try/codespace
github-actions[bot] e2577f1
Merge branch 'develop' into try/codespace
github-actions[bot] c4756f2
Merge branch 'develop' into try/codespace
github-actions[bot] 7968a24
Merge branch 'develop' into try/codespace
github-actions[bot] ef30d88
Merge branch 'develop' into try/codespace
github-actions[bot] a0d91e1
Merge branch 'develop' into try/codespace
github-actions[bot] 0f2e45c
Merge branch 'develop' into try/codespace
github-actions[bot] 6714cd2
Merge branch 'develop' into try/codespace
github-actions[bot] 8546ea0
Merge branch 'develop' into try/codespace
github-actions[bot] 038b548
Merge branch 'develop' into try/codespace
github-actions[bot] 5efeddb
Merge branch 'develop' into try/codespace
github-actions[bot] a4db1e0
Merge branch 'develop' into try/codespace
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
FROM wordpress | ||
|
||
# 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 \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,9 @@ Session.vim | |
Thumbs.db | ||
Desktop.ini | ||
|
||
.env | ||
setup.log | ||
|
||
# E2E testing | ||
.wp-env.override.json | ||
artifacts | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Santiagosaiz4superprize
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Santiagosaiz4