diff --git a/Dockerfile b/Dockerfile index 3d0e75b..b4ed77b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,10 @@ FROM williamyeh/ansible:ubuntu16.04 +ARG user=jenkins +ARG group=jenkins +ARG uid=1000 +ARG gid=1000 + RUN apt-get update -y && \ apt-get install -y git unzip @@ -11,6 +16,10 @@ ARG TERRAFORM_VERSION=0.11.1 ADD https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip /tmp/terraform_${TERRAFORM_VERSION}_linux_amd64.zip RUN unzip /tmp/terraform_${TERRAFORM_VERSION}_linux_amd64.zip -d /usr/local/bin +# https://github.com/jenkinsci/docker/blob/ca17603a0ff907728201f6285a4182020b277b87/Dockerfile#L18-L19 +RUN groupadd -g ${gid} ${group} && \ + useradd -u ${uid} -g ${gid} -m -s /bin/bash ${user} +USER ${user} # required for Packer # https://groups.google.com/d/msg/packer-tool/92wq5kYOvto/kkzoASaMAQAJ -ENV USER root +ENV USER ${user} diff --git a/Jenkinsfile b/Jenkinsfile index 5db3619..3cf4530 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,7 +14,7 @@ pipeline { image '18fgsa/devsecops-builder' alwaysPull true // https://support.cloudbees.com/hc/en-us/articles/218583777-How-to-set-user-in-docker-image- - args '-u root' + args '-u jenkins:jenkins' } } environment {