ci icon indicating copy to clipboard operation
ci copied to clipboard

`undefined` in docker-compose.devcontainer.build-*.yml

Open hankei6km opened this issue 2 years ago • 1 comments

I am trying with the following repository.

  • devcontainer.json use docker compose
  • A workflow is run with GitHub Actions

https://github.com/hankei6km/test-devcontainers-cli-compose

cli

Using @devcontainers/cli directly from within the workflow will succeed.

https://github.com/hankei6km/test-devcontainers-cli-compose/runs/6874333436?check_suite_focus=true

ci

Using devcontainers/[email protected] will result in an error.

https://github.com/hankei6km/test-devcontainers-cli-compose/runs/6874333439?check_suite_focus=true

  [2196 ms] yaml.scanner.ScannerError: while scanning a simple key
    in "/tmp/docker-compose/docker-compose.devcontainer.build-1655184778637.yml", line 3, column 1
  could not find expected ':'
    in "/tmp/docker-compose/docker-compose.devcontainer.build-1655184778637.yml", line 4, column 17

undefined was included when docker-compose.devcontainer.build-1655184778637.yml was displayed

services:
  node:
undefined
      cache_from:
        - ghcr.io/hankei6km/h6-dev-containers:node

files

Below are the contents of the related files.

.devcontainer/devcontainer.json

{
  "name": "node",
  "dockerComposeFile": "docker-compose.yml",
  "service": "node",
  "remoteUser": "vscode",
  "workspaceFolder": "/home/vscode/workspace",
  "extensions": ["esbenp.prettier-vscode"],
  "settings": {
    "[typescript]": {
      "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[json]": {
      "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[javascript]": {
      "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[jsonc]": {
      "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[html]": {
      "editor.defaultFormatter": "esbenp.prettier-vscode"
    }
  }
}

.devcontainer/docker-compose.yml

version: '3.8'

services:
  node:
    # image: 'ghcr.io/hankei6km/h6-dev-containers:node'
    build:
      context: .
      dockerfile: Dockerfile
    hostname: node
    user: vscode
    volumes:
      - ../:/home/vscode/workspace
    tty: true
  httpbin:
    image: 'kennethreitz/httpbin:latest'
    hostname: httpbin

.devcontainer/Dockerfile

FROM ghcr.io/hankei6km/h6-dev-containers:node

.github/workflows/test_chk.yaml

name: test_chk
on:
  push:
    branches:
      - '**'
    tags:
      - '!v*'
  workflow_dispatch:

jobs:
  jest:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Build and run dev container task
        uses: devcontainers/[email protected]
        continue-on-error: true
        with:
          imageName: ghcr.io/hankei6km/h6-dev-containers
          imageTag: node
          push: never
          runCmd: |
            npm install
            npm run test

      - name: Print failed files
        run: cat /tmp/docker-compose/docker-compose.devcontainer.build-*.yml

hankei6km avatar Jun 14 '22 05:06 hankei6km

I've just started seeing this after doing some changes that resulted in the container getting updated. Is there a resolution or workaround?

simeon-walker avatar Sep 05 '22 17:09 simeon-walker

devcontainers/ci latest version also works with Dev Containers using docker-compose.

https://github.com/hankei6km/test-devcontainers-cli-compose/actions/runs/3984321073/jobs/6830415764

Run devcontainers/[email protected]
Starting...
Warning: The `save-state` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
Installing @devcontainers/cli...
** Installing @devcontainers/cli
/usr/bin/bash -c npm install -g @devcontainers/cli@latest

added 3 packages, and audited 4 packages in 6s

found 0 vulnerabilities
Adding --cache-from ghcr.io/hankei6km/h6-dev-containers:node to build args
🏗️ build container
🏃 start container
🚀 Run command in container

hankei6km avatar Jan 23 '23 08:01 hankei6km