Skip to content

Commit

Permalink
Remove HOME, restore jenkins user; reenable plugin caching; update co…
Browse files Browse the repository at this point in the history
…mments

* Simplify the deployment as much as possible
* HOME can be removed, but needs the jenkins user restored to have a
  valid HOME dir that's not /, which breaks npm.
  • Loading branch information
glin committed Jul 10, 2023
1 parent 696797a commit fbcdbb2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
13 changes: 3 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,11 @@ ecr-login:
push-serverless-custom-file:
aws s3 cp serverless-custom.yml s3://rstudio-devops/r-builds/serverless-custom.yml

# Temporarily patch serverless-custom.yml to not Dockerize pip and disable
# serverless-python-requirements caching. The caching does not work in Jenkins
# by default because the cache directory is resolved to a relative ".cache"
# directory, rather than an absolute directory, which breaks the plugin.
# The cache directory must either be an absolute path (optionally specified
# via cacheLocation: /path/to/cache), or caching must be disabled for the plugin
# to work. We disable caching completely to avoid all sorts of future issues.
# The cache directory is based on $HOME, which is set to "." when running
# Docker images in Jenkins for some reason.
# Temporarily patch serverless-custom.yml to not Dockerize pip for the
# serverless-python-requirements plugin.
fetch-serverless-custom-file:
aws s3 cp s3://rstudio-devops/r-builds/serverless-custom.yml .
sed -i 's|dockerizePip: true|dockerizePip: false\n useStaticCache: false\n useDownloadCache: false|' serverless-custom.yml
sed -i 's|dockerizePip: true|dockerizePip: false|' serverless-custom.yml

rebuild-all: deps fetch-serverless-custom-file
$(SLS_BINARY) invoke stepf -n rBuilds -d '{"force": true}'
Expand Down
7 changes: 0 additions & 7 deletions deploy.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ pipeline {
label 'docker'
}
}
environment {
// Set HOME to the workspace for the serverless-python-requirements plugin.
// The plugin uses HOME for its default cache location, which needs to be
// mounted in the separate Python build container. This needs to be an absolute
// path that also exists on the host since we're mounting the Docker socket.
HOME = "${env.WORKSPACE}"
}
options {
ansiColor('xterm')
}
Expand Down
9 changes: 9 additions & 0 deletions jenkins/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

FROM ubuntu:jammy

ARG JENKINS_UID=386
ARG JENKINS_GID=386

# Keep the Python version in line with the runtime in serverless.yml
ARG PYTHON_VERSION=3.8.15

Expand Down Expand Up @@ -32,3 +35,9 @@ RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
&& apt install -y nodejs

RUN npm install -g serverless

# Create the jenkins user with the same id:gid as the jenkins node
RUN groupadd -g $JENKINS_GID jenkins \
&& useradd -m -d /var/lib/jenkins -u $JENKINS_UID -g jenkins jenkins

USER jenkins

0 comments on commit fbcdbb2

Please sign in to comment.