diff --git a/.gitpod.yml b/.gitpod.yml index 250512f0bbd..504fb8f933a 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -1,19 +1,27 @@ -image: - file: .gitpod.Dockerfile +image: drud/ddev-gitpod-base:latest tasks: - - name: terminal + - name: ddev + - name: simpleproj init: | export DDEV_NONINTERACTIVE=true make mkdir -p /workspace/simpleproj && cd /workspace/simpleproj + ddev config global --omit-containers=ddev-router,ddev-ssh-agent,dba ddev config --project-type=drupal9 --docroot=web --create-docroot + ddev config global --router-bind-all-interfaces=true + gitpod-setup-ddev.sh /workspace/simpleproj + ddev start ddev composer create drupal/recommended-project -y && ddev composer require drush/drush - cp ~/bin/gitpod-setup-ddev.sh .ddev && .ddev/gitpod-setup-ddev.sh + ddev drush si demo_umami -y --account-pass=admin + mkdir -p .tarballs + ddev export-db --file=.tarballs/db.sql.gz command: | - cd /workspace/simpleproj && .ddev/gitpod-setup-ddev.sh + cd /workspace/simpleproj + ddev config global --omit-containers=ddev-router,ddev-ssh-agent,dba + ddev start -y + ddev import-db --src=.tarballs/db.sql.gz gp await-port 8080 && sleep 1 && gp preview $(gp url 8080) - vscode: extensions: - golang.go @@ -36,3 +44,44 @@ github: addBadge: true # add a label once the prebuild is ready to pull requests (defaults to false) addLabel: true + +ports: + # Used by projector + - port: 6942 + onOpen: ignore + visibility: private + # Direct-connect ddev-webserver port that is the main port + - port: 8080 + onOpen: ignore + visibility: private + # Currently un-notified and unsupported mailhog http port + - port: 8025 + onOpen: ignore + visibility: private + # Currently un-notified and unsupported mailhog https port + - port: 8026 + onOpen: ignore + visibility: private + # Currently un-notified and unsupported phpmyadmin http port + - port: 8036 + onOpen: ignore + visibility: private + # Currently un-notified and unsupported phpmyadmin https port + - port: 8037 + onOpen: ignore + visibility: private + # router http port that we're ignoring. + - port: 8888 + onOpen: ignore + visibility: private + # router https port that we're ignoring. + - port: 8889 + onOpen: ignore + visibility: private + # xdebug port + - port: 9000 + onOpen: ignore + visibility: private + # projector port + - port: 9999 + visibility: private diff --git a/.gitpod.Dockerfile b/.gitpod/images/Dockerfile similarity index 64% rename from .gitpod.Dockerfile rename to .gitpod/images/Dockerfile index 9c78708fcfb..7f307cf3977 100644 --- a/.gitpod.Dockerfile +++ b/.gitpod/images/Dockerfile @@ -10,21 +10,11 @@ RUN echo 'if [ -r "/home/linuxbrew/.linuxbrew/etc/profile.d/bash_completion.sh" RUN echo 'export PATH=~/bin:$PATH' >>~/.bashrc && mkdir -p ~/bin RUN ln -sf /workspace/ddev/.gotmp/bin/linux_amd64/ddev ~/bin/ddev -RUN curl -o ~/bin/gitpod-setup-ddev.sh --fail -lLs https://raw.githubusercontent.com/shaal/ddev-gitpod/main/.ddev/gitpod-setup-ddev.sh && chmod +x ~/bin/gitpod-setup-ddev.sh +COPY gitpod-setup-ddev.sh /usr/local/bin RUN mkcert -install -ENV BUILDX_BINARY_URL="https://github.com/docker/buildx/releases/download/v0.5.1/buildx-v0.5.1.linux-amd64" +ENV BUILDX_BINARY_URL="https://github.com/docker/buildx/releases/download/v0.6.3/buildx-v0.6.3.linux-amd64" RUN mkdir -p ~/.docker/cli-plugins && curl --output ~/.docker/cli-plugins/docker-buildx \ --silent --show-error --location --fail --retry 3 \ "$BUILDX_BINARY_URL" && chmod a+x ~/.docker/cli-plugins/docker-buildx - -# Install custom tools, runtimes, etc. -# For example "bastet", a command-line tetris clone: -# RUN brew install bastet -# -# More information: https://www.gitpod.io/docs/config-docker/ - -### -### Initiate a rebuild of Gitpod's image by updating this comment #1 -### diff --git a/.gitpod/images/gitpod-setup-ddev.sh b/.gitpod/images/gitpod-setup-ddev.sh new file mode 100755 index 00000000000..994e867577b --- /dev/null +++ b/.gitpod/images/gitpod-setup-ddev.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +# Set up ddev for use on gitpod + +set -eu -o pipefail + +if [ $# != 1 ]; then + echo "Usage: gitpod-setup-ddev.sh " && exit 1 +fi + +PROJDIR="$1/.ddev" +cd ${PROJDIR} + +# Generate a config.gitpod.yaml that adds the gitpod +# proxied ports so they're known to ddev. +shortgpurl="${GITPOD_WORKSPACE_URL#'https://'}" + +cat < ${PROJDIR}/config.gitpod.yaml +web_environment: +- DRUSH_OPTIONS_URI=$(gp url 8080) + +bind_all_interfaces: true +host_webserver_port: 8080 +# Will ignore the direct-bind https port, which will land on 2222 +host_https_port: 2222 +# Allows local db clients to run +host_db_port: 3306 +# Assign MailHog port +host_mailhog_port: "8025" +# Assign phpMyAdmin port +host_phpmyadmin_port: 8036 +CONFIGEND + +# We need host.docker.internal inside the container, +# So add it via docker-compose.host-docker-internal.yaml +hostip=$(awk "\$2 == \"$HOSTNAME\" { print \$1; }" /etc/hosts) + +cat <${PROJDIR}/docker-compose.host-docker-internal.yaml +#ddev-gitpod-generated +version: "3.6" +services: + web: + extra_hosts: + - "host.docker.internal:${hostip}" +COMPOSEEND diff --git a/.gitpod/images/push.sh b/.gitpod/images/push.sh new file mode 100755 index 00000000000..7d6d5539c74 --- /dev/null +++ b/.gitpod/images/push.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -eu -o pipefail + +DOCKER_REPO=drud/ddev-gitpod-base:latest + +echo "Pushing ${DOCKER_REPO}" +set -x +# Build only current architecture and load into docker +docker buildx build -t ${DOCKER_REPO} --push --platform=linux/amd64 .