How can I Integrate 'ddev' workflow in Gitpod?

I work with Drupal for most projects, which requires a similar environment to Laravel or Magento.

I love using ddev (https://ddev.readthedocs.io/) because it creates for me a docker setup, in a very simple way.

To start a Drupal project, all I need is run ddev config, answer 4 questions (all with the default answer), and ddev start. ddev start and everything works.
The first 13 lines in this ddev script would work for most Drupal projects, and I can still configure everything I want to change, if I want to change it.

Compared with the example of Magento2 in Gitpod:

Is there a way to start Gitpod, and then run ddev in the terminal of the workspace?
Is there a way to use docker-compose to bring multiple images into a project, instead of 1 docker file?

Hi @shaal! Sorry for the late reply / welcome to the Gitpod community! :tada:

While this isn’t possible in Gitpod today, docker & docker-compose support in Gitpod workspaces is currently being implemented, and should (hopefully) get released in just a few weeks.

You can configure Gitpod to automatically install ddev in your workspace (e.g. in a .gitpod.yml init task, or in a .gitpod.dockerfile).

However, since ddev itself seems to depend on Docker and/or docker-compose, you will probably need to wait for these to be supported in gitpod.io before you can fully benefit from ddev.

Please note that releasing this feature is currently our highest priority for Gitpod.

Thank you for your answer @jan

I am looking forward to docker and docker-composer functionality, if there’s any beta-testing for these features, please sign me up :slight_smile:

1 Like

@shaal Sure, thanks for the offer!

Also, we’ll share more details on this feature during a YouTube live stream tomorrow, in case you’re interested: https://youtu.be/l4I2TVAnBuw

@jan Thank you for telling me about it! I will definitely attend the Youtube live stream.

3 Likes

The beta feature is now available!
From: Is It possible to do run root commands from Docker after the Gitpod layer?

  • Go to https://gitpod.io/settings/
  • Check Enable Feature Preview
  • Reload a Gitpod workspace
  • (In Terminal) run sudo docker-up to start a Docker daemon.
  • :tada:
3 Likes

I finally got to test the preview feature of root access.
Here’s what I am trying to achieve:

  • Install ddev
  • run sudo docker-up
  • run ddev start

I want ddev installation to be part of a prebuild, to speed up development, and when a developer opens the workspace it should already be after ddev start command.

After setting this up, when I open the workspace, ddev is not installed.
How can I get it to work, that what was installed with brew will be available for anyone that uses the workspace?

Here’s the copy of gitpod.yml:

image:
  file: .gitpod.Dockerfile

# Use 'lock file' to delay running ddev until it is installed
# https://www.gitpod.io/blog/gitpodify/#running-init-scripts
tasks:
  - name: ddev_install
    init: |
      touch /tmp/.ddev-lock
      brew tap drud/ddev && brew install ddev
      rm /tmp/.ddev-lock
  - name: docker_up
    command: sudo docker-up
  - name: ddev_run
    init: sleep 1 && while [ -f /tmp/.ddev-lock ]; do sleep 1; done
    command: ddev start

github:
  prebuilds:
    # enable for the master/default branch (defaults to true)
    master: true
    # enable for all branches in this repo (defaults to false)
    branches: true
    # enable for pull requests coming from this repo (defaults to true)
    pullRequests: true
    # enable for pull requests coming from forks (defaults to false)
    pullRequestsFromForks: true
    # add a check to pull requests (defaults to true)
    addCheck: true
    # add a "Review in Gitpod" button as a comment to pull requests (defaults to false)
    addComment: true
    # add a "Review in Gitpod" button to the pull request's description (defaults to false)
    addBadge: true
    # add a label once the prebuild is ready to pull requests (defaults to false)
    addLabel: true

This is the repo:
https://github.com/shaal/ddevenv

Here’s a snapshot of the workspace:
https://gitpod.io/#snapshot/2eaa39c3-2725-4f76-bc95-adf343e50f6b

I realized I should move brew install command to dockerfile, instead of gitpod.yml.

I created a branch with this change:
https://github.com/shaal/ddevenv/tree/install-ddev-in-dockerfile

Now ddev get installed, and I can run it.

But now I am getting an error message that I have never seen before.

Failed to start ddevenv: ddev-ssh-agent failed to become ready; debug with 'docker logs ddev-ssh-agent'; error: container /ddev-ssh-agent unhealthy: OCI runtime exec failed: exec failed: container_linux.go:349: starting container process caused "process_linux.go:101: executing setns process caused \"exit status 1\"": unknown 

When I go to the terminal that is running sudo docker-up, there’s a repeating error displayed:

ERRO[0000] failed to disable IPv6 forwarding for container's interface all: open /proc/sys/net/ipv6/conf/all/disable_ipv6: read-only file system 
WARN[2021-01-05T04:49:52.526439001Z] Failed to disable IPv6 on all interfaces on network namespace "/var/run/docker/netns/a91f18dd1258": reexec to set IPv6 failed: exit status 4 
WARN[2021-01-05T04:49:52.787672778Z] OOM monitoring failed                         error="cgroups: memory cgroup not supported on this system"
ERRO[2021-01-05T04:49:53.857356149Z] stream copy error: reading from a closed fifo 
ERRO[2021-01-05T04:49:53.857452602Z] stream copy error: reading from a closed fifo 
WARN[2021-01-05T04:49:53.859689554Z] Health check for container dbeb96f45e970e27731c9469a9327fea2885163b1af4bd33cc8a28592dfc068f error: OCI runtime exec failed: exec failed: container_linux.go:349: starting container process caused "process_linux.go:101: executing setns process caused \"exit status 1\"": unknown  

This is the repo:
https://github.com/shaal/ddevenv/tree/init-instead-of-command

Here’s the workspace:

The issue here is executing setns process caused \"exit status 1 - A look around on the internet says you may need “user namespace support”, see https://github.com/opencontainers/runc/issues/1740#issuecomment-368311065

1 Like

Here’s that minimal setup, which is not related to DDEV, to replicate the error:
error: OCI runtime exec - when running a docker command with healthcheck · Issue #2845 · gitpod-io/gitpod (github.com)

This worked for me https://github.com/shaal/ddev-gitpod

Thank you @collierscott

The bug was fixed and now it’s working as expected.