Closed raginjason closed 1 year ago
Hi @raginjason - at its core, this project is a wrapper around devcontainers/cli. While this project only has support for GitHub actions/Azure DevOps pipelines, the devcontainer
CLI can be installed in other environments and used to build and run dev containers. I'm not familiar with GitLab, but assuming that it offers a similar capability for building custom tasks then this project may be a useful reference if you are interested in building that out.
Hope that helps!
@stuartleeks I hear what you're saying and I'm following. While I'm not a GitLab CI expert, but I've spent a day trying to get it to build dev containers and come up short. Unfortunately with no examples or prior art to pull from, it's extremely difficult to get off the ground. Assuming I'm not alone, this will hurt adoption by anyone using GitLab CI. This may not be a feature request as much as a documentation request. Should I ever figure out how to do this, I'd be more than happy to contribute this documentation, but so far I've not been successful.
I probably should have mentioned my actual use case. Currently we use GitLab CI in a project which naturally installs various libraries/packages/modules. Moving to dev containers creates redundancy, because what there is a large overlap between what CI needs an what a dev container needs. This brought me to the idea of creating a dev container in a separate support project, and having the original project use it as both a dev container and in its GitLab CI pipeline. This would eliminate the redundancy between what GitLab CI installs and what our dev container installs because they would be the same container.
In a previous team, we started using dev containers in CI as a way to avoid having to keep tools/packages/versions installed in the CI environment in sync with the dev container that we were using for our local dev. That was before the devcontainers
CLI was created and had some pretty rough edges.
It sounds like there may be an opportunity to give more details on the CI scenario using the devcontainers
CLI - what sort of issues are you having, and what sort of info would you have found useful?
A example .gitlab-ci.yml
is really what would have been useful. I kept working on this and this will build a devcontainer
and push it to GitLab's own container registry:
image: docker:20.10.16
variables:
DOCKER_TLS_CERTDIR: "/certs"
services:
- docker:20.10.16-dind
before_script:
- docker info
- apk add --update nodejs=16.17.1-r0 npm=8.10.0-r0 python3=3.10.9-r0 make=4.3-r0 g++=11.2.1_git20220219-r2
- npm install -g @devcontainers/cli
build:
stage: build
script:
- docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
- devcontainer build --workspace-folder . --push true --image-name ${CI_REGISTRY_IMAGE}:latest
Any thoughts on where to include this documentation so that others may benefit from it?
Yeah, I can see how something like that would be useful.
I'm not sure whether this repo is a good place to put it as it's not something that would be verified by any tests so it would be unlikely that we'd catch any behaviour changes.
@Chuxel - any thoughts?
In my mind it seems like having a GitLab CI version of these docs https://github.com/devcontainers/ci/blob/main/docs/github-action.md would be appropriate
@raginjason For pure documentation, I wonder if a guide in containers.dev would make more sense and be more effective: https://containers.dev/guides
If you're interested, you could contribute one here: https://github.com/devcontainers/devcontainers.github.io/tree/gh-pages/_posts
We could also update references in places like this to mention the article: https://github.com/devcontainers/devcontainers.github.io/blob/gh-pages/_implementors/reference.md#-prebuilding-
@bamurtaugh - For VS Code users, we could also cross-reference any guides from here: https://code.visualstudio.com/docs/devcontainers/devcontainer-cli#_alternate-installation
To some extent that spot probably should point to the marketplace presence for the GitHub Action and Azure DevOps task rather than this repo as I look at it. This repo is more the source code than the docs site, so pointing here may actually be sending the wrong message as I think about it.
@Chuxel all that you mention here makes sense to me.
@raginjason we'd love any contributions you're able and willing to provide to the docs @Chuxel mentions! Please feel free to tag me as a reviewer in any of them, and I'm happy to help.
I should be able to contribute a guide. Let me see what I can come up with. Thanks!
There is now a Working with GitLab CI guide that covers much of what was discussed here
I see instructions on how to build devcontainers with GitHub and Azure DevOps, but nothing for GitLab CI. This may simply be a documentation issue, I don't know. I've attempted to get this working with GitLab CI, but so far have come up short, especially with various docker-in-docker (DinD) issues. Can you provide an example
.gitlab-ci.yml
or some instructions on how to get this working with GitLab CI?