https://pulumi.com logo
Title
w

wooden-student-58350

11/18/2021, 12:41 PM
Hi all. I’m using Pulumi Crosswalk for AWS to build & push a Docker image to ECR. This works fine locally, but fails in GitLab CI (presumably because the
pulumi-nodejs
image I’m using doesn’t contain the docker binary). What’s the best practice for dealing with this setup? I’d like to use the
pulumi-nodejs
image if possible, so should I manually install docker in the CI script? Or is it better to use the
docker
image and install Pulumi?
Some more details:
// index.ts

const repository = new awsx.ecr.Repository(...)
repository.buildAndPushImage({
  context: sourcePath,
  extraOptions: ["--platform=linux/amd64"],
})
In the CI pipeline:
error: Error: ' docker build --platform=linux/amd64 ../app -t d2f5d933-container' failed with exit code 1

  at /builds/.../node_modules/@pulumi/docker.ts:592:15
  at Generator.next (<anonymous>)
  at fulfilled (/builds/.../node_modules/@pulumi/docker/docker.js:18:58)
  at processTicksAndRejections (node:internal/process/task_queues:96:5)

error: spawn docker ENOENT
# .gitlab-ci.yml

deploy:
 stage: deploy
 rules:
  - if: '$CI_OPEN_MERGE_REQUESTS == null'
 image: pulumi/pulumi-nodejs:3.17.1
 services:
  - docker:20.10.8-dind
 variables:
  GIT_SUBMODULE_STRATEGY: recursive
  DOCKER_TLS_CERTDIR: "/certs"
 before_script:
  - echo "Running deployment for production"
 script:
  - npm ci --prefix infra
  - pulumi up --yes --stack $CI_COMMIT_BRANCH
The GitLab Runner is using the docker executor on a container using the
docker:20.10.8
image, running in privileged mode (following advice in GitLab docs for building Docker images inside Docker).