Skip to content

Commit

Permalink
Use an external base gitpod image (ddev#3331)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfay authored Oct 25, 2021
1 parent cb2b1e0 commit 8ddafd3
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 18 deletions.
61 changes: 55 additions & 6 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
14 changes: 2 additions & 12 deletions .gitpod.Dockerfile → .gitpod/images/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
###
45 changes: 45 additions & 0 deletions .gitpod/images/gitpod-setup-ddev.sh
Original file line number Diff line number Diff line change
@@ -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 <project-path>" && 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 <<CONFIGEND > ${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 <<COMPOSEEND >${PROJDIR}/docker-compose.host-docker-internal.yaml
#ddev-gitpod-generated
version: "3.6"
services:
web:
extra_hosts:
- "host.docker.internal:${hostip}"
COMPOSEEND
9 changes: 9 additions & 0 deletions .gitpod/images/push.sh
Original file line number Diff line number Diff line change
@@ -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 .

0 comments on commit 8ddafd3

Please sign in to comment.