https://pulumi.com logo
Title
a

agreeable-ram-97887

03/25/2021, 5:12 PM
Has anyone used
pulumi up
/
pulumi preview
in a gitlab CICD script with docker resources? If so would you mind sharing how you've configured your pipeline? Or at least giving some hint about the "right" way to do it. When I try this myself, I unfortunately keep getting the error
FileNotFoundError: [Errno 2] No such file or directory: 'docker': 'docker'
, and I'm not sure what to make of that 🤔
b

billowy-army-68599

03/25/2021, 5:14 PM
can you share what you have?
a

agreeable-ram-97887

03/25/2021, 5:35 PM
after cleaning it up a little bit, this is basically what I'm working with:
image: python:3.7.9-buster
before_script:
  - apt-get update -y
  - apt-get install sudo -y
  - python3 -m venv infra/venv
  - infra/venv/bin/python -m pip install --upgrade pip setuptools wheel
  - infra/venv/bin/python -m pip install -r infra/requirements.txt
  - bash ./pulumiSetup/setup.sh

stages:
  - preview
  - deploy

pulumi-preview:
  stage: preview
  services:
    - docker:dind
  script:
    - bash ./pulumiSetup/pulumi-preview.sh

pulumi-deploy:
  stage: deploy
  services:
    - docker:dind
  script:
    - bash ./pulumiSetup/pulumi-up.sh
  only:
    - master
the scripts
pulumiSetup/setup.sh
is like this:
#!/bin/bash

# exit if a command returns a non-zero exit code
# print the commands and their args as they are executed
set -e -x

# Download and install required tools
# update the GitLab Runner and install other packages
apt-get update -y
apt-get install sudo python3-pip python3-venv unzip wget curl -y

curl -fsSL <https://get.pulumi.com/> | bash
export PATH=$PATH:$HOME/.pulumi/bin
export PULUMI_ACCESS_TOKEN=$PULUMI_ACCESS_TOKEN

# Login into pulumi. This will require the PULUMI_ACCESS_TOKEN environment variable
# pulumi config set --secret pulumi-access-token $PULUMI_ACCESS_TOKEN
pulumi login

curl "<https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip>" -o "awscliv2.zip"
unzip -qq awscliv2.zip
sudo ./aws/install
and the script 
pulumiSetup/pulumi-preview.sh
 is like this:
#!/bin/bash

# exit if a command returns a non-zero exit code
# print the commands and their args as they are executed
set -e -x

# Add the pulumi CLI to the PATH
export PATH=$PATH:$HOME/.pulumi/bin

# AWS creds here - variables with $ to be set on gitlab var env
aws configure set default.region '$AWS_DEFAULT_REGION'
aws configure set aws_access_key_id '$AWS_ACCESS_KEY_ID'
aws configure set aws_secret_access_key '$AWS_SECRET_ACCESS_KEY'

echo $AWS_ACCESS_KEY_ID
echo $AWS_SECRET_ACCESS_KEY

pulumi stack select accure1/dev --cwd "/builds/accure1/code/el/corvus/infra/"

# preview configuration before deployment
pulumi preview --cwd "/builds/accure1/code/el/corvus/infra/"
b

billowy-army-68599

03/25/2021, 5:41 PM
are you provisioning docker containers, I can't see where you're referencing docker anywhere so no idea where that file not found is coming from
w

white-secretary-18260

03/25/2021, 5:42 PM
If your pulumi script is building docker container, you will need to make sure your build containers have docker installed.
docker in docker,
yes.
in our build container we install it in our
Dockerfile
with:
# SETUP DOCKER
RUN curl -fsSL <https://get.docker.com> -o get-docker.sh
RUN sudo sh get-docker.sh
RUN sudo service docker start
depending on the base image your build container uses you may have to install
sudo
RUN apt-get install sudo -y
a

agreeable-ram-97887

03/25/2021, 6:37 PM
thanks @white-secretary-18260 for that suggestion (in hindsight it was pretty obvious 🤦), it seems to have gotten me past the previous error. But now the pipelines hangs in the
pulumi preview
call 🤔 . Any ideas? Btw, the new
pulumiSetup/setup.sh
script that im using is (note the additional install docker lines):
#!/bin/bash

# exit if a command returns a non-zero exit code
# print the commands and their args as they are executed
set -e -x

# Download and install required tools
# update the GitLab Runner and install other packages
apt-get update -y
apt-get install sudo python3-pip python3-venv unzip wget curl -y

# SETUP DOCKER
curl -fsSL <https://get.docker.com> -o get-docker.sh
sudo sh get-docker.sh
sudo service docker start

# INSTALL PULUMI
curl -fsSL <https://get.pulumi.com/> | bash
export PATH=$PATH:$HOME/.pulumi/bin
export PULUMI_ACCESS_TOKEN=$PULUMI_ACCESS_TOKEN

# Login into pulumi. This will require the PULUMI_ACCESS_TOKEN environment variable
# pulumi config set --secret pulumi-access-token $PULUMI_ACCESS_TOKEN
pulumi login

curl "<https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip>" -o "awscliv2.zip"
unzip -qq awscliv2.zip
sudo ./aws/install
w

white-secretary-18260

03/25/2021, 6:49 PM
I’d throw
--verbose 999
on there and see what it brings.
a

agreeable-ram-97887

03/25/2021, 7:27 PM
apparently it wasn't hanging, but just took over 30 minutes to do the
pulumi preview
. I'm running it again now with the increased verbosity, so hopefully will have some more info soon. But anyway I guess I'll need to implement some sort of caching of the image getting built
👍 1