我的CDKSTACK代码段如下所示,

问题描述 投票:0回答:1
入口点调用它就像

cdk.json
现在我的

app = cdk.App() mystack = CdkLambdaInfraStack( app, "CdkLambdaInfraStack" ) app.synth()

就像下面一样。
gitlab-ci.yml

现在,当我正在跑步时,它的工作正常,但是在
stages:
  - build

# Build and push the Docker image to the GitLab image registry
# using Docker-in-Docker.
dind-build:
  stage: build

  image:
    # An alpine-based image with the `docker` CLI installed.
    name: docker:19.03

  before_script:
    # Install the `docker` CLI.
    - apk update
    - apk add gcc libc-dev libffi-dev 
    - apk add --update --no-cache python3 python3-dev && ln -sf python3 /usr/bin/python
    - python3 -m ensurepip
    - pip3 install --no-cache --upgrade pip setuptools
    - pip install poetry
    - poetry install
    - source `poetry env info --path`/bin/activate

  services:
   - name: docker:dind
     alias: dockerdaemon

  variables:
    # Tell docker CLI how to talk to Docker daemon.
    DOCKER_HOST: tcp://dockerdaemon:2375/
    # Use the overlayfs driver for improved performance.
    DOCKER_DRIVER: overlay2
    # Disable TLS since we're running inside local network.
    DOCKER_TLS_CERTDIR: ""
    FF_NETWORK_PER_BUILD: "true"

  script:
    - apk add --update nodejs npm curl
    - npm install -g aws-cdk
    - python app.py
中同样的是给我错误

local

在我的一部分时,我在我的

gitlab runner

末尾添加了
RuntimeError: Bundling did not produce any output. Check that content is written to /asset-output.
,并正确地列出了我的所有列表。
    

我通过更改捆绑文件访问的方式来克服了类似问题。默认情况下,它将使用

bundlingfileaccess.bind_mount

,在普通的码头情况下工作正常,但在使用共享Docker套接字(Docker中的Docker)时不行。为了解决您可以使用
bundlingfileaccess.volume_copy

在说明中所述

这个速度较慢,但在更复杂的情况下使用远程或共享的Docker插座工作。
这是因为在使用共享套接字在Docker中使用Docker时试图安装音量将尝试安装主机的目录,而不是运行该作业的容器。使用
debugging
将创建卷和复制文件,而不是尝试安装座。您可以通过更改来尝试:
ls -la

docker gitlab-ci aws-cdk
1个回答
0
投票

@salvador,非常感谢!我花了将近2天的时间来解决这个问题。运行CDK Synth命令时,我在带有VSCODE和远程容器扩展的Docker容器中工作。我知道这与Docker(Dind)中的Docker有关,但从未找到一个好的解决方案。 你在我的情况下有正确的答案

© www.soinside.com 2019 - 2025. All rights reserved.