lambci / docker-lambda

Docker images and test runners that replicate the live AWS Lambda environment
MIT License
5.83k stars 431 forks source link

Jenkins agent install on lambci/lambda:build-python3.7 #365

Closed jambstud closed 2 years ago

jambstud commented 2 years ago

Hello,

Would be possible to extend the image : lambci/lambda:build-python3.7 to contain the jenkins/inbound-agent?

This will be help when different lambda build libraries required to run from a container jenkins node .

jambstud commented 2 years ago

looks this did the trick to add the jenkins agent into the image;

FROM lambci/lambda:build-python3.7

ARG VERSION=4.9 ARG user=jenkins ARG group=jenkins ARG uid=1001 ARG gid=1001 ARG AGENT_WORKDIR=/home/${user}/agent

ec2-user id is 1000

ENV TERRAFORM_VERSION 1.1.3 ENV TERRAGRUNT_VERSION v0.35.16

USER root

create jenkins user/group/home

RUN groupadd ${group} RUN adduser -ms /bin/bash -u ${uid} -g ${group} ${user} RUN yum update -y && yum install -y openjdk11 curl bash git perl-Archive-Zip pytest moto==2.0.8 mock freezegun requests_sigv4 zip unzip ansible curl jq awscli

Jenkins node agent.jar

RUN curl --create-dirs -fsSLo /usr/share/jenkins/agent.jar https://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/${VERSION}/remoting-${VERSION}.jar \ && chmod 755 /usr/share/jenkins \ && chmod 644 /usr/share/jenkins/agent.jar \ && ln -sf /usr/share/jenkins/agent.jar /usr/share/jenkins/slave.jar \ && rm -rf /tmp/.apk /tmp/gcc /tmp/gcc-libs.tar /tmp/libz /tmp/libz.tar.xz /var/cache/apk/*

COPY jenkins-agent /usr/local/bin/jenkins-agent RUN chmod +x /usr/local/bin/jenkins-agent &&\ ln -s /usr/local/bin/jenkins-agent /usr/local/bin/jenkins-slave

WORKDIR /home/jenkins COPY jenkins_nodes.yaml .

Install terraform

RUN curl -o /tmp/terraform.zip -fsSL "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" \ && cd /usr/local/bin \ && unzip /tmp/terraform.zip \ && chmod +x terraform \ && rm /tmp/terraform.zip

Install terragrunt

RUN curl -o /usr/local/bin/terragrunt -fsSL "https://github.com/gruntwork-io/terragrunt/releases/download/${TERRAGRUNT_VERSION}/terragrunt_linux_amd64" \ && chmod +x /usr/local/bin/terragrunt

USER ${user} RUN mkdir /home/${user}/.jenkins && mkdir -p ${AGENT_WORKDIR}

ENTRYPOINT ["/usr/local/bin/jenkins-agent"]

jambstud commented 2 years ago

maybe there are ways