diff --git a/containers/jenkins-alpine/Dockerfile b/containers/jenkins-alpine/Dockerfile index 4a7669b..843a4af 100644 --- a/containers/jenkins-alpine/Dockerfile +++ b/containers/jenkins-alpine/Dockerfile @@ -95,6 +95,7 @@ RUN git clone --depth=1 https://github.com/tfutils/tfenv.git /opt/.tfenv && \ RUN git clone https://github.com/iamhsa/pkenv.git /opt/.pkenv && \ PACKER_LATEST_URL=$(curl -sL https://releases.hashicorp.com/packer/index.json | jq -r '.versions[].builds[].url' | egrep -v 'rc|beta|alpha' | egrep 'linux.*amd64' | tail -1) && \ PACKER_LATEST_VERSION=$(echo "$PACKER_LATEST_URL" | awk -F '/' '{print $6}' | sed 's/packer_//' | sed 's/_linux_amd64.zip//') && \ + cd /opt/.pkenv && \ pkenv install ${PACKER_LATEST_VERSION} && \ pkenv use ${PACKER_LATEST_VERSION} diff --git a/containers/jenkins-alpine/packer.pkr.hcl b/containers/jenkins-alpine/packer.pkr.hcl index 3e1b8f5..ad82048 100644 --- a/containers/jenkins-alpine/packer.pkr.hcl +++ b/containers/jenkins-alpine/packer.pkr.hcl @@ -200,9 +200,11 @@ build { environment_vars = ["PATH=${local.path_var}", "PYENV_ROOT=/opt/.pyenv", "USER=root"] execute_command = "sudo -Hu root sh -c '{{ .Vars }} {{ .Path }}'" inline = [ + "mkdir -p /opt/tfsec", "curl -sSL $(curl -sSL https://api.github.com/repos/tfsec/tfsec/releases/latest | jq -r '.assets[] | select(.name | contains(\"tfsec-linux-amd64\")) | .browser_download_url') -o /tmp/tfsec > /dev/null 2>&1", "chmod +x /tmp/tfsec", - "mv /tmp/tfsec /usr/local/bin" + "mv /tmp/tfsec /opt/tfsec/tfsec", + "ln -fs /opt/tfsec/tfsec /usr/bin/tfsec" ] } @@ -232,6 +234,7 @@ build { execute_command = "sudo -Hu ${var.normal_user} sh -c '{{ .Vars }} {{ .Path }}'" inline = [ "git clone https://github.com/iamhsa/pkenv.git /opt/.pkenv", + "cd /opt/.pkenv", "pkenv install latest", "pkenv use latest" ]