Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(documentation) Adds a small paragraph describing how to use another timezone #338

Merged
merged 12 commits into from
Nov 28, 2022

Conversation

gounthar
Copy link
Contributor

@gounthar gounthar commented Nov 25, 2022

By default, the image is using Etc/UTC. A user wants to use another timezone (c.f. #291.

I explain briefly how to use another one while creating a new image derived from jenkins/agent.

This is a follow-up to jenkinsci/docker-inbound-agent#337 where I added the tzdata package.
This PR and the jenkinsci/docker-inbound-agent#337 will replace my first attempt (see jenkinsci/docker-inbound-agent#334).

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

…her timezone

By default, the image is using `Etc/UTC`.
@gounthar gounthar changed the title feat(documentation) Adds a small paragraph describing how to use anot… feat(documentation) Adds a small paragraph describing how to use another timezone Nov 25, 2022
@dduportal
Copy link
Contributor

Not blocking, but maybe suggesting mounting the host /etc/localtime along with setting the TZ environment variable (as per moby/moby#12084 (comment)) could also be useful, to cover users who do not want to build a custom image.

For instance, from the jenkinsci/docker-inbound-agent#337 (with tzdata installed)

$ docker build -t test ./11/bullseye && docker run --rm -ti --entrypoint=date -v /etc/localtime:/etc/localtime:ro test && docker run --rm -ti --env TZ=Asia/Shanghai --entrypoint=date test 
[+] Building 2.6s (16/16) FINISHED                                                                                                                                                                                                        
 => [internal] load build definition from Dockerfile                                                                                                                                                                                 0.0s
 => => transferring dockerfile: 32B                                                                                                                                                                                                  0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                    0.0s
 => => transferring context: 2B                                                                                                                                                                                                      0.0s
 => [internal] load metadata for docker.io/library/debian:bullseye-20221114                                                                                                                                                          1.8s
 => [internal] load metadata for docker.io/library/eclipse-temurin:11.0.17_8-jdk-focal                                                                                                                                               1.9s
 => [stage-1 1/8] FROM docker.io/library/debian:bullseye-20221114@sha256:3066ef83131c678999ce82e8473e8d017345a30f5573ad3e44f62e5c9c46442b                                                                                            0.0s
 => [jre-build 1/2] FROM docker.io/library/eclipse-temurin:11.0.17_8-jdk-focal@sha256:d84b470fe0b8de379461a8e179792c389e29611b6a4f182c02c23b98c2527f7e                                                                               0.0s
 => https://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/3077.vd69cf116da_6f/remoting-3077.vd69cf116da_6f.jar                                                                                                             0.5s
 => CACHED [stage-1 2/8] RUN groupadd -g "1000" "jenkins"   && useradd -l -c "Jenkins user" -d /home/jenkins -u "1000" -g "1000" -m "jenkins"                                                                                        0.0s
 => CACHED [stage-1 3/8] RUN apt-get update   && apt-get --yes --no-install-recommends install     ca-certificates     curl     fontconfig     git     git-lfs     less     netbase     openssh-client     patch     tzdata   && ap  0.0s
 => CACHED [stage-1 4/8] ADD --chown=jenkins:jenkins https://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/3077.vd69cf116da_6f/remoting-3077.vd69cf116da_6f.jar /usr/share/jenkins/agent.jar                               0.0s
 => CACHED [stage-1 5/8] RUN chmod 0644 /usr/share/jenkins/agent.jar   && ln -sf /usr/share/jenkins/agent.jar /usr/share/jenkins/slave.jar                                                                                           0.0s
 => CACHED [jre-build 2/2] RUN jlink   --add-modules ALL-MODULE-PATH   --strip-debug   --no-man-pages   --no-header-files   --compress=2   --output /javaruntime                                                                     0.0s
 => CACHED [stage-1 6/8] COPY --from=jre-build /javaruntime /opt/java/openjdk                                                                                                                                                        0.0s
 => CACHED [stage-1 7/8] RUN mkdir /home/jenkins/.jenkins && mkdir -p "/home/jenkins/agent"                                                                                                                                          0.0s
 => CACHED [stage-1 8/8] WORKDIR /home/jenkins                                                                                                                                                                                       0.0s
 => exporting to image                                                                                                                                                                                                               0.0s
 => => exporting layers                                                                                                                                                                                                              0.0s
 => => writing image sha256:4ad90e28bb559cd34687da879b313bdb9c62c8af61b74834b655b962379d39e2                                                                                                                                         0.0s
 => => naming to docker.io/library/test                                                                                                                                                                                              0.0s
Fri Nov 25 15:52:10 UTC 2022
Fri Nov 25 23:52:11 CST 2022

and

 docker build -t test:alpine ./11/alpine && docker run --rm -ti --entrypoint=date -v /etc/localtime:/etc/localtime:ro test:alpine && docker run --rm -ti --env TZ=Asia/Shanghai --entrypoint=date test:alpine
[+] Building 1.0s (12/12) FINISHED                                                                                                                                                                                                        
 => [internal] load build definition from Dockerfile                                                                                                                                                                                 0.0s
 => => transferring dockerfile: 32B                                                                                                                                                                                                  0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                    0.0s
 => => transferring context: 2B                                                                                                                                                                                                      0.0s
 => [internal] load metadata for docker.io/library/eclipse-temurin:11.0.17_8-jdk-alpine                                                                                                                                              0.7s
 => [1/7] FROM docker.io/library/eclipse-temurin:11.0.17_8-jdk-alpine@sha256:dad17670f7d3e0072d2e3e04978dab261bd131bbd6117da57cc9d7c45b5029fa                                                                                        0.0s
 => https://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/3077.vd69cf116da_6f/remoting-3077.vd69cf116da_6f.jar                                                                                                             0.1s
 => CACHED [2/7] RUN addgroup -g "1000" "jenkins"   && adduser -h /home/"jenkins" -u "1000" -G "jenkins" -D "jenkins"                                                                                                                0.0s
 => CACHED [3/7] RUN apk add --no-cache      bash      curl      git      git-lfs      musl-locales      openssh-client      openssl      procps      tzdata     && rm -rf /tmp/*.apk /tmp/gcc /tmp/gcc-libs.tar* /tmp/libz /tmp/li  0.0s
 => CACHED [4/7] ADD --chown=jenkins:jenkins https://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/3077.vd69cf116da_6f/remoting-3077.vd69cf116da_6f.jar /usr/share/jenkins/agent.jar                                       0.0s
 => CACHED [5/7] RUN chmod 0644 /usr/share/jenkins/agent.jar   && ln -sf /usr/share/jenkins/agent.jar /usr/share/jenkins/slave.jar                                                                                                   0.0s
 => CACHED [6/7] RUN mkdir /home/"jenkins"/.jenkins && mkdir -p "/home/jenkins/agent"                                                                                                                                                0.0s
 => CACHED [7/7] WORKDIR /home/jenkins                                                                                                                                                                                               0.0s
 => exporting to image                                                                                                                                                                                                               0.0s
 => => exporting layers                                                                                                                                                                                                              0.0s
 => => writing image sha256:936f518194bb2fd614cf7c887d5f8bfe43de569d8acf50a7e1c91140b4596c51                                                                                                                                         0.0s
 => => naming to docker.io/library/test:alpine                                                                                                                                                                                       0.0s
Fri Nov 25 15:54:05 UTC 2022
Fri Nov 25 23:54:06 CST 2022

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@gounthar gounthar marked this pull request as ready for review November 28, 2022 16:43
@gounthar gounthar requested a review from a team as a code owner November 28, 2022 16:43
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Copy link
Contributor

@dduportal dduportal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 nitpicks suggestion feel free to accept or refuse them.

Otherwise it's nice, thanks!

gounthar and others added 2 commits November 28, 2022 18:44
Co-authored-by: Damien Duportal <damien.duportal@gmail.com>
Co-authored-by: Damien Duportal <damien.duportal@gmail.com>
@gounthar
Copy link
Contributor Author

Thanks a lot for the review, I always forget about those long flags. 😊

@dduportal dduportal merged commit 3e93de2 into jenkinsci:master Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants