I'm trying to get Pulumi running from a gitlab run...
# general
f
I'm trying to get Pulumi running from a gitlab runner (docker in docker executor) and it seems I'm running into a strange issue here:
#!/bin/bash
# exit if a command returns a non-zero exit code and also print the commands and their args as they are executed set -e -x # Download and install required tools. # pulumi curl -fsSL
<https://get.pulumi.com/> | bash
export PATH=$PATH:$HOME/.pulumi/bin # Login into pulumi. This will require the PULUMI_ACCESS_TOKEN environment variable ls -l ~/.pulumi/bin pulumi login # update the GitLab Runner's packages apt-get update -y apt-get install sudo -y # nodejs curl -sL
<https://deb.nodesource.com/setup_8.x> | sudo -E bash -
apt-get install -y nodejs # yarn npm i -g yarn exits at pulumi login with the following error: pulumi login ./setup.sh: line 12: /root/.pulumi/bin/pulumi: No such file or directory I did a ls -l before the call in order to check if all files are in that folder and if they are executable, that's the result: 38 === Installing Pulumi v1.8.1 === 39 + Downloading https://get.pulumi.com/releases/sdk/pulumi-v1.8.1-linux-x64.tar.gz... 40  % Total % Received % Xferd Average Speed Time Time Time Current 41  Dload Upload Total Spent Left Speed 42 100 52.1M 100 52.1M 0 0 13.7M 0 00003 00003 -- -- 13.7M 43 + Extracting to /root/.pulumi/bin 44 === Pulumi is now installed! 🍹 === 45 + Please add /root/.pulumi/bin to your $PATH 46 + Get started with Pulumi: https://www.pulumi.com/docs/quickstart 47 + export PATH=/usr/local/sbin/usr/local/bin/usr/sbin/usr/bin/sbin/bin/root/.pulumi/bin 48 + PATH=/usr/local/sbin/usr/local/bin/usr/sbin/usr/bin/sbin/bin/root/.pulumi/bin 49 + ls -l /root/.pulumi/bin 50 total 116648 51 -rwxr-xr-x 1 root root 46136504 Jan 3 11:28 pulumi 52 -rwxr-xr-x 1 root root 245 Jan 3 11:28 pulumi-analyzer-policy 53 -rwxr-xr-x 1 root root 17218844 Jan 3 11:28 pulumi-language-dotnet 54 -rwxr-xr-x 1 root root 21598301 Jan 3 11:28 pulumi-language-go 55 -rwxr-xr-x 1 root root 17349733 Jan 3 11:28 pulumi-language-nodejs 56 -rwxr-xr-x 1 root root 17114009 Jan 3 11:28 pulumi-language-python 57 -rw-r--r-- 1 root root 4734 Jan 3 11:28 pulumi-language-python-exec 58 -rwxr-xr-x 1 root root 238 Jan 3 11:28 pulumi-resource-pulumi-nodejs 59 -rwxr-xr-x 1 root root 41 Jan 3 11:28 pulumi-resource-pulumi-python what am I'm missing? gitlab runner configuration etc. I took from the documentation.
s
weird. what's your gitlab-ci file look like?
f
#
# This sample yaml configuration file contains two stages and three jobs. # This configuration uses GitLab's
only
,
when
, and
except
configuration # options to create a pipeline that will create the
pulumi-preview
job in the pipeline, # for all branches except the master. # Only for master branch merges, the main
pulumi
job is executed automatically. stages: - build - infrastructure-update # Each stage may require multiple jobs to complete that stage. # Consider a build stage, which may require building the UI, service, and a CLI. # All 3 individual build jobs can be attributed to the build stage. complex_build_job: stage: build script: - echo "pulumi rocks!" pulumi: stage: infrastructure-update before_script: - apk update - apk add bash - apk add curl - chmod +x ./*.sh - ./setup.sh script: - ./run-pulumi.sh # Create an artifact archive with just the pulumi log file, # which is created using console-redirection in run-pulumi.sh. artifacts: paths: - pulumi-log.txt # This is just a sample of how artifacts can be expired (removed) automatically in GitLab. # You may choose to not set this at all based on your organization's or team's preference. expire_in: 1 week # This job should only be created if the pipeline is created for the master branch. only: - master
basically the sample from the website with some packages added (bash and curl)
s
The reason for your error is because the
docker:stable
image that your job is running in doesn't have the correct interpreter to execute the binary file. If you run
apk add libc6-compat
before
pulumi login
, it should work. But as you can see from the
apt-get
commands in the provided
setup.sh
script, the example is assuming you are running the job in a debian/ubuntu image. I'd recommend setting that as your default job image. It looks like the page you are following was intentionally not written to be a complete example.
f
thank you, will try this!
Got it working with an Ubuntu image and some changes to my Setup script (like install curl)
But I wonder if I can‘t take the pulumi docker image or build my own image but that’s something to try later
s
you definitely can build your own image. that's how I'm doing it since my jobs require other dependencies as well. just a tip for building your own image, make sure you move the binary into a dir already part of
PATH
, e.g.
Copy code
FROM ubuntu:16.04
RUN curl -fsSL <https://get.pulumi.com> | sh && \
    mv $HOME/.pulumi/bin/* /usr/bin
and you can have a gitlab build step for the cicd image, e.g.
Copy code
variables:
  cicdImageVersion: 1.0.0 # this needs to be updated manually if there's a change to the cicd dockerfile

build_cicd_docker_image:
  stage: prepare
  image: docker:stable
  services:
    - docker:dind
  only:
    refs:
      - merge_requests
    changes:
      - cicd.Dockerfile
  script: |
    docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN <http://registry.gitlab.com|registry.gitlab.com>
    imageUri=<http://registry.gitlab.com/blahblah/cicd:$cicdImageVersion|registry.gitlab.com/blahblah/cicd:$cicdImageVersion>
    if ! DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect $imageUri; then
      docker build -t $imageUri -f cicd.Dockerfile .
      docker push $imageUri
    fi