[wp-trac] [WordPress Trac] #57896: Improve devcontainer + Codespaces support

WordPress Trac noreply at wordpress.org
Wed Aug 30 11:56:09 UTC 2023


#57896: Improve devcontainer + Codespaces support
------------------------------+-----------------------------
 Reporter:  SergeyBiryukov    |       Owner:  (none)
     Type:  enhancement       |      Status:  new
 Priority:  normal            |   Milestone:  Future Release
Component:  Build/Test Tools  |     Version:
 Severity:  normal            |  Resolution:
 Keywords:  has-patch         |     Focuses:
------------------------------+-----------------------------

Comment (by rmccue):

 Replying to [comment:4 mdawaffe]:
 > Agreed. I don't remember the details or what all I tried, but I think
 the issue was that the initial containers were created in one
 configuration with respect to the devcontainer container (as children? as
 siblings?) and the newly created CLI container was created with another.

 Yeah, the detail I'd missed is that when in dockerComposeFile mode,
 `service` indicates which container to run the terminal in - that's new
 behaviour since last time I tried Codespaces!

 tl;dr of the behaviour: Codespaces is running `docker-compose` on the root
 VM, then your terminal/etc run inside the specified service via an
 extended compose file. To access the cntainers, you hence have to mount
 the Docker socket into that service; docker-outside-of-docker handles
 that, thankfully, although I only realised that ''after'' I'd finished
 implementing the old school hacks.

 > As best I can tell, `docker-outside-of-docker` isn't working with core's
 docker-compose.yml because of `nginx:alpine`, which doesn't have `apt-get`
 (see
 [https://github.com/devcontainers/features/blob/038bed3d58a84885da8a008b80905da17d57a543/src
 /docker-outside-of-docker/install.sh#L70 docker-outside-of-docker's
 install.sh], [https://github.com/devcontainers/features/tree/main/src
 /docker-outside-of-docker#os-support OS Support]). Alpine uses
 [https://docs.alpinelinux.org/user-handbook/0.1a/Working/apk.html apk].
 Switching to `nginx:latest` fixes that problem, though others crop up.

 I actually did manage to get it to work in the end... -ish. Rather than
 using core's containers for the "main" (`service`) container, I'm using a
 container built off `mcr.microsoft.com/devcontainers/base` with an
 extended docker-compose, which means we don't need to modify the main file
 (but can override it if needed).

 My experience with Codespaces and in-container development is that it's
 very useful to have a devtool-only container available for working tools.
 (You can also use the `cli` container by setting the command to `sleep
 infinity`, but it's a bit more janky, and doesn't give us an easy way to
 add additional tools.)

 The problem I ended up with though is that MySQL is not accepting
 connections for root from 172.18.0.0/16; the config ''should'' be allowing
 `%` for the host so not sure what's going on there.

 I'll PR this up too in a bit (my Codespace is crashy right now).

 I'd recommend we commit either PR 5115 or something like it in the short
 term to fix the current experience while we look at using the other
 containers though.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57896#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list