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

Early experiment with a node.js back-end #48

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 8 additions & 20 deletions .github/workflows/linux-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,26 @@ if [ ! -z "${DOCKERHUB_PULL_USERNAME:-}" ]; then
fi

sudo apt-get update -qq >/dev/null
sudo apt-get install -qq zip jq expect nfs-kernel-server build-essential curl git libnss3-tools libcurl4-gnutls-dev postgresql-client >/dev/null
sudo apt-get install -y -qq build-essential expect libnss3-tools libcurl4-gnutls-dev postgresql-client >/dev/null

curl -sSL --fail -o /tmp/ngrok.zip https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip && sudo unzip -o -d /usr/local/bin /tmp/ngrok.zip

export PATH=/home/linuxbrew/.linuxbrew/bin:$PATH
echo "export PATH=/home/linuxbrew/.linuxbrew/bin:$PATH" >>~/.bashrc
curl -sSL https://ngrok-agent.s3.amazonaws.com/ngrok.asc \
| sudo tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null \
&& echo "deb https://ngrok-agent.s3.amazonaws.com buster main" \
| sudo tee /etc/apt/sources.list.d/ngrok.list \
&& sudo apt-get update -qq >/dev/null \
&& sudo apt-get install -y -qq ngrok

# Without this .curlrc CircleCI linux image doesn't respect mkcert certs
echo "capath=/etc/ssl/certs/" >>~/.curlrc

source ~/.bashrc

for item in bats-core ddev/ddev/ddev docker-compose golangci-lint kaos/shell/bats-assert kaos/shell/bats-file mkcert; do
for item in bats-core ddev/ddev/ddev docker-compose ghr golangci-lint kaos/shell/bats-assert kaos/shell/bats-file; do
brew install $item >/dev/null || brew upgrade $item >/dev/null
done

mkcert -install

primary_ip=$(ip route get 1 | awk '{gsub("^.*src ",""); print $1; exit}')

sudo bash -c "cat <<EOF >/etc/exports
${HOME} ${primary_ip}/255.255.255.255(rw,sync,no_subtree_check)
/tmp ${primary_ip}/255.255.255.255(rw,sync,no_subtree_check)
EOF"

sudo service nfs-kernel-server restart

# Install ghr
GHR_RELEASE="v0.14.0"
curl -fsL -o /tmp/ghr.tar.gz https://github.com/tcnksm/ghr/releases/download/${GHR_RELEASE}/ghr_${GHR_RELEASE}_linux_amd64.tar.gz
sudo tar -C /usr/local/bin --strip-components=1 -xzf /tmp/ghr.tar.gz ghr_${GHR_RELEASE}_linux_amd64/ghr

# Show info to simplify debugging
docker info
docker version
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ permissions:
jobs:
build:
name: Build DDEV executables
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
env:
AmplitudeAPIKey: ${{ secrets.AMPLITUDE_API_KEY_DEV }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push-tagged-dbimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ permissions:
jobs:
push-tagged-dbimage:
name: "push tagged dbimage"
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
matrix:
dbtype: [mariadb_5.5, mariadb_10.0, mariadb_10.1, mariadb_10.2, mariadb_10.3, mariadb_10.4, mariadb_10.5, mariadb_10.6, mariadb_10.7, mariadb_10.8, mariadb_10.11, mariadb_11.4, mysql_5.5, mysql_5.6, mysql_5.7, mysql_8.0, mysql_8.4]
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/quickstart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Quickstart test
defaults:
run:
shell: bash

on:
push:
branches:
- master
pull_request:
paths:
- "docs/content/users/quickstart.md"
workflow_dispatch:
inputs:
debug_enabled:
description: 'Enable debug mode'
type: boolean
required: false
default: false

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

permissions:
actions: write

jobs:
build:
name: Docs Quickstart test
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master

- name: Install Docker and deps (Linux)
run: ./.github/workflows/linux-setup.sh

- name: Setup tmate session
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true

- name: Run quickstart test
run: |
make quickstart-test

2 changes: 1 addition & 1 deletion .github/workflows/selfhosted-upgrades.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fi
# Upgrade various items on various operating systems
case $os in
darwin)
for item in mkcert mkdocs golang golangci-lint ddev; do
for item in mkdocs golang golangci-lint ddev; do
brew upgrade $item || brew install $item || true
done
;;
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:

fail-fast: false

runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

env:
CGO_ENABLED: 0
Expand Down Expand Up @@ -109,7 +109,14 @@ jobs:
uses: Homebrew/actions/setup-homebrew@master

- name: Remove unnecessary items on disk
run: sudo rm -rf /usr/local/lib/android && df -h .
run: |
sudo rm -rf /opt/hostedtoolcache/CodeQL
sudo rm -rf /usr/local/{aws*,julia*}
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf /usr/local/bin/minikube,bin/terraform,bin/oc
sudo rm -rf /usr/local/share/chromium /usr/local/share/powershell /usr/local/share/vcpkg
df -h .

- name: Install Docker and deps (Linux)
run: ./.github/workflows/linux-setup.sh
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,11 @@ golangci-lint:
echo "Skipping golangci-lint as not installed"; \
fi

quickstart-test: build
@echo "quickstart-test:"
@echo DDEV_BINARY_FULLPATH=$(DDEV_BINARY_FULLPATH)
export PATH="$(DDEV_PATH):$$PATH" DDEV_NO_INSTRUMENTATION=true CGO_ENABLED=$(CGO_ENABLED) DDEV_BINARY_FULLPATH=$(DDEV_BINARY_FULLPATH); bats docs/tests

version:
@echo VERSION:$(VERSION)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[program:nodejs]
command = bash -c "cd /var/www/html && ./node_modules/http-server/bin/http-server -p 3000"
priority=5
stdout_logfile=/var/tmp/logpipe
stdout_logfile_maxbytes=0
redirect_stderr=true
autorestart=true
startretries=3
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[include]
files = /etc/supervisor/nodejs.conf /etc/supervisor/conf.d/*.conf

[program:nginx]
command=/usr/sbin/nginx
priority=10
stdout_logfile=/var/tmp/logpipe
stdout_logfile_maxbytes=0
redirect_stderr=true
autorestart=true
startretries=3
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ done
phpstatus="false"
htmlaccess="false"
mailpit="false"
nodestatus="false"

if ls /var/www/html >/dev/null; then
htmlaccess="true"
Expand Down Expand Up @@ -58,7 +59,13 @@ if [ "${DDEV_WEBSERVER_TYPE#*-}" = "fpm" ]; then
fi
fi

if [ "${phpstatus}" = "true" ] && [ "${mailpit}" = "true" ]; then
if [ "${DDEV_WEBSERVER_TYPE#*-}" = "nodejs" ]; then
gunicornstatus="true"
phpstatus="true"
nodestatus="true"
fi

if [ "${phpstatus}" = "true" ] && [ "${htmlaccess}" = "true" ] && [ "${mailpit}" = "true" ]; then
touch /tmp/healthy
exit 0
fi
Expand Down
2 changes: 2 additions & 0 deletions docs/content/developers/buildkite-testmachine-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ We are using [Buildkite](https://buildkite.com/ddev) for Windows and macOS testi
PATH=$PATH:/usr/local/bin:/opt/homebrew/bin
```

30. In macOS Settings visit "full disk access" and grant access to `buildkite-agent`, `docker`, `iterm`, `orbstack`. This may prevent startup modal dialogs that prevent `buildkite-agent` or `docker` from continuing properly.

## Additional Colima macOS setup

1. `brew install colima`
Expand Down
14 changes: 10 additions & 4 deletions docs/content/users/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,24 @@ To get started with [Backdrop](https://backdropcms.org), clone the project repos

```bash
# Clone an existing repository (or navigate to a local project directory):
git clone https://github.com/example/example-site my-backdrop-site
# Set PROJECT_GIT_URL to your project's git URL.
PROJECT_GIT_URL=https://github.com/ddev/test-backdrop.git
git clone ${PROJECT_GIT_URL} my-backdrop-site
cd my-backdrop-site

# Set up the DDEV environment:
ddev config --project-type=backdrop

# Boot the project and install Composer packages (if required):
# Start the project
ddev start
ddev composer install

# Import a database backup and open the site in your browser:
# Import a database backup:
ddev import-db --file=/path/to/db.sql.gz

# Import files backup
ddev import-files --source=/path/to/files.tar.gz

# open the site in your browser
ddev launch
```

Expand Down
75 changes: 75 additions & 0 deletions docs/tests/backdrop.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env bats

setup() {
PROJNAME=my-backdrop-site
load 'common-setup'
_common_setup
}

# executed after each test
teardown() {
_common_teardown
}

@test "backdrop new-project quickstart with $(ddev --version)" {
# mkdir my-backdrop-site && cd my-backdrop-site
run mkdir -p my-backdrop-site && cd my-backdrop-site
assert_success
# curl -LJO https://github.com/backdrop/backdrop/releases/latest/download/backdrop.zip
run curl -LJO https://github.com/backdrop/backdrop/releases/latest/download/backdrop.zip
assert_success
# unzip ./backdrop.zip && rm -f backdrop.zip && mv -f ./backdrop/{.,}* . ; rm -rf backdrop
run unzip -o ./backdrop.zip && rm -f backdrop.zip && mv -f ./backdrop/{.,}* . ; rm -rf backdrop
assert_success
# ddev config --project-type=backdrop
run ddev config --project-type=backdrop
assert_success
# ddev start
run ddev start
assert_success
# ddev launch
run bash -c "DDEV_DEBUG=true ddev launch"
assert_output "FULLURL https://${PROJNAME}.ddev.site"
assert_success
# validate running project
run curl -sfI https://${PROJNAME}.ddev.site
assert_success
assert_output --partial "location: https://${PROJNAME}.ddev.site/core/install.php"
assert_output --partial "HTTP/2 302"
}

@test "backdrop existing project with $(ddev --version)" {
# PROJECT_GIT_URL=https://github.com/ddev/test-backdrop.git
PROJECT_GIT_URL=https://github.com/ddev/test-backdrop.git
# git clone ${PROJECT_GIT_URL} my-backdrop-site
run git clone ${PROJECT_GIT_URL} ${PROJNAME}
assert_success
# cd my-backdrop-site
cd ${PROJNAME} || exit 2
assert_success
# ddev config --project-type=backdrop
run ddev config --project-type=backdrop
assert_success
# ddev start
run ddev start
assert_success
run curl -fLO https://github.com/ddev/test-backdrop/releases/download/1.29.2/db.sql.gz
assert_success
# ddev import-db --file=/path/to/db.sql.gz
run ddev import-db --file=db.sql.gz
assert_success
run curl -fLO https://github.com/ddev/test-backdrop/releases/download/1.29.2/files.tgz
assert_success
# ddev import-files --source=/path/to/files.tar.gz
run ddev import-files --source=files.tgz
# ddev launch
run bash -c "DDEV_DEBUG=true ddev launch"
assert_output "FULLURL https://${PROJNAME}.ddev.site"
assert_success
run curl -sfI https://${PROJNAME}.ddev.site
assert_success
assert_output --partial "HTTP/2 200"
run curl -sf https://${PROJNAME}.ddev.site
assert_success
assert_output --partial "Welcome to My Backdrop Site!"
}
18 changes: 18 additions & 0 deletions docs/tests/common-setup.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

_common_setup() {
TEST_BREW_PREFIX="$(brew --prefix 2>/dev/null || true)"
export BATS_LIB_PATH="${BATS_LIB_PATH}:${TEST_BREW_PREFIX}/lib:/usr/lib/bats"
bats_load_library bats-support
bats_load_library bats-assert
mkdir -p ~/tmp
tmpdir=$(mktemp -d ~/tmp/${PROJNAME}.XXXXXX)
export DDEV_NO_INSTRUMENTATION=true
mkdir -p ${tmpdir} && cd ${tmpdir} || exit 1
ddev delete -Oy ${PROJNAME:-notset}
}

_common_teardown() {
ddev delete -Oy ${PROJNAME}
rm -rf ${tmpdir}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ require (
go.opentelemetry.io/otel/sdk v1.22.0 // indirect
go.opentelemetry.io/otel/trace v1.32.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/protobuf v1.35.2 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE=
golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down
5 changes: 5 additions & 0 deletions pkg/ddevapp/apptypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ func init() {
importFilesAction: magentoImportFilesAction,
},

// TODO: Fill it in.
nodeps.AppTypeNodeJS: {
configOverrideAction: nodejsConfigOverrideAction,
},

nodeps.AppTypePHP: {
postStartAction: nil,
},
Expand Down
Loading
Loading