https://pulumi.com logo
#general
Title
# general
c

clever-glass-42863

04/06/2022, 9:33 PM
Greetings, we are trying to run a pulumi deploy for dotnet inside of a Gitlab Runner Ci/Cd job. The running container is instanced via the docker+machine executor, and as such, runs a base image mcr.microsoft.com/dotnet/sdk:6.0 since we're building an aspnet service. All the AWS resources are generated correctly, however it seems to hang when publishing the image to ECR. The repository is created, however the pulumi up command just hangs. We've tried adding --verbose, but no other additional information is supplied other than the continuous addition of . for updating.... log. Are there any steps we can take to further diagnose the exact root of the issue? We have confirmed that running thus locally, it all functions as we expect.
l

little-cartoon-10569

04/06/2022, 10:01 PM
Maximum verbosity is achieved by setting
-v=9
, and since you're running in CI, you'll want to add
--logtostderr
(otherwise the logs go to files which disappear with your build container..).
c

clever-glass-42863

04/06/2022, 10:06 PM
Got it. We'll try that. Is there a
pulumi/pulumi-dotnet
docker image that has .NET 6?
l

little-cartoon-10569

04/06/2022, 10:08 PM
Hmm, the docs don't link to the Dockerfiles.. that's an oversight. Onesec I'll check GitHub.
If you want anything other than 3.1, you'll have to build it yourself 😞
c

clever-glass-42863

04/06/2022, 10:13 PM
Got it. Thanks for the update @little-cartoon-10569
👍 1
l

little-cartoon-10569

04/06/2022, 10:14 PM
Though isn't 3.1 the latest? I'm a bit out of the dotnet world these last few years..
6 is Framework. Pulumi uses Core, not Framework.
c

clever-glass-42863

04/06/2022, 10:16 PM
The latest version of .NET Core is .NET 6. For more information, see the summary https://docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-6. They're trying to unify the sdks, which makes sense.
l

little-cartoon-10569

04/06/2022, 10:16 PM
Ah. The page I looked at doesn't explain that at all well...
c

clever-glass-42863

04/06/2022, 10:17 PM
Yeah, hopefully this confusion will be a thing of the past now 😅
I appreciate your help
👍 1
@little-cartoon-10569 when I run
docker info
via the pulumi/pulumi-dotnet container image (invoked from pulumi up), I get
docker: command not found
. What I'm trying to track down is an apparent hang when pushing or building the image for the app. How does Pulumi handle the docker images from within the running container?
l

little-cartoon-10569

04/06/2022, 11:14 PM
I think you're saying that your build script is running
docker
inside the GitLab-CI container?
docker
isn't installed by default iirc, you need to use the dind base image. Onesec, I'll get docs.
Assuming you're using a shared runner? Or have you installed the GitLabCI agent in your own image?
This page lists all the ways you can run docker from inside a container being used by GitLabCi. Note that only the dind option works with shared runners.
c

clever-glass-42863

04/07/2022, 2:06 PM
Yeah I had made some bad assumptions, which are now resolved. We are running our own instance of Gitlab with AWS autoscaling on the runners. I'll share the gitlab yml here as an example of how we worked around a few problems: 1. We're planning on generating a Dockerfile to change the default .NET version to 6, but for now we just install it as part of the job (for testing purposes). 2. We solved the docker communication issue by using docker:dind service to allow for communication to push the image.
Copy code
services:
  - name: docker:20-dind
    alias: docker
    command: ["--tls=false"]

deploy:
    image: 
      name: pulumi/pulumi-dotnet
    when: manual
    tags:
      - docker
    variables:
      # AWS_ACCESS_KEY_ID supplied via CiCd variables...
      # AWS_SECRET_ACCESS_KEY supplied via CiCd variables...
      AWS_REGION: us-west-1
      PULUMI_PROJECT_DIR: ./Product.Pulumi
      PULUMI_CONFIG_PASSPHRASE: $CI_COMMIT_REF_NAME
      DOCKER_DRIVER: overlay2
      DOCKER_HOST: <tcp://docker:2375> 
      DOCKER_TLS_CERTDIR: ""
    script:
      # Prepre docker cli...
      - apt-get update && apt-get install -y ca-certificates && apt-get install -y curl && apt-get install -y gnupg && apt-get install -y lsb-release
      - curl -fsSL <https://download.docker.com/linux/debian/gpg> | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
      - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] <https://download.docker.com/linux/debian> $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
      - apt-get update && apt-get install -y docker-ce-cli
      # Install dotnet 6, will eventually bake this in our own pulumi docker image...
      - apt-get install -y wget
      - wget <https://dot.net/v1/dotnet-install.sh>
      - bash dotnet-install.sh -c Current
      # Login to our S3 backend to store / restore state...
      - pulumi login <s3://our-product-backend-bucket/$CI_COMMIT_REF_NAME>
      # Deploy...
      - cd $PULUMI_PROJECT_DIR
      - pulumi stack select $CI_COMMIT_REF_NAME --create --verbose 9
      - pulumi up --stack $CI_COMMIT_REF_NAME --non-interactive --yes --skip-preview --verbose 9
Hopefully someone finds this useful if they run into a similar issue.
4 Views