Skip to content

Commit fbcdbb2

Browse files
committedJul 10, 2023
Remove HOME, restore jenkins user; reenable plugin caching; update comments
* 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.
1 parent 696797a commit fbcdbb2

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed
 

‎Makefile

+3-10
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,11 @@ ecr-login:
3030
push-serverless-custom-file:
3131
aws s3 cp serverless-custom.yml s3://rstudio-devops/r-builds/serverless-custom.yml
3232

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

4639
rebuild-all: deps fetch-serverless-custom-file
4740
$(SLS_BINARY) invoke stepf -n rBuilds -d '{"force": true}'

‎deploy.Jenkinsfile

-7
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@ pipeline {
55
label 'docker'
66
}
77
}
8-
environment {
9-
// Set HOME to the workspace for the serverless-python-requirements plugin.
10-
// The plugin uses HOME for its default cache location, which needs to be
11-
// mounted in the separate Python build container. This needs to be an absolute
12-
// path that also exists on the host since we're mounting the Docker socket.
13-
HOME = "${env.WORKSPACE}"
14-
}
158
options {
169
ansiColor('xterm')
1710
}

‎jenkins/Dockerfile

+9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
FROM ubuntu:jammy
77

8+
ARG JENKINS_UID=386
9+
ARG JENKINS_GID=386
10+
811
# Keep the Python version in line with the runtime in serverless.yml
912
ARG PYTHON_VERSION=3.8.15
1013

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

3437
RUN npm install -g serverless
38+
39+
# Create the jenkins user with the same id:gid as the jenkins node
40+
RUN groupadd -g $JENKINS_GID jenkins \
41+
&& useradd -m -d /var/lib/jenkins -u $JENKINS_UID -g jenkins jenkins
42+
43+
USER jenkins

0 commit comments

Comments
 (0)
Please sign in to comment.