jenkinsci/docker-inbound-agent

hope debian jdk 11 inbound-agent timezone UTC--->CST

l19891223j opened this issue · 6 comments

What feature do you want to see added?

[root@xxx debian]#
[root@xxx debian]# pwd
/root/test/docker-inbound-agent-4.10-2/11/debian
[root@xxx debian]# ls
Dockerfile jenkins-agent
// docker build 时需要把jenkins-agent文件拷贝到当前目录下
[root@xxx debian]# cat Dockerfile


ARG version=4.9-1-jdk11
FROM jenkins/agent:$version

**ENV TIME_ZONE Asia/Shanghai**
ARG version
LABEL Description="This is a base image, which allows connecting Jenkins agents via JNLP protocols" Vendor="Jenkins project" Version="$version"

ARG user=jenkins

USER root
RUN apt-get install -y tzdata \
    && ln -snf /usr/share/zoneinfo/$TIME_ZONE /etc/localtime && echo $TIME_ZONE > /etc/timezone \
    && dpkg-reconfigure -f noninteractive tzdata \
    && apt-get clean \
    && rm -rf /tmp/* /var/cache/* /usr/share/doc/* /usr/share/man/* /var/lib/apt/lists/*

#COPY ../../jenkins-agent /usr/local/bin/jenkins-agent  
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
RUN apt-get -y install curl
USER ${user}

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

Upstream changes

No response

Interesting, that would be a nice feature to contribute into jenkinsci/docker-agent, which is the parent image. Are you interested into the contribution? (if you are not, another community member can take this contribution on their own instead, no worry).

I can make a PR for that (I've already started), but first of all, I'd like to understand why we should go from UTC to CST. 🤔
If you're in Asia, it totally makes sense to me, but what about the rest of the world?
Did I misunderstand, and would anyone benefit from his own timezone when using the image?
I don't think so.

What is the goal, and what are the pros of doing that?

Thanks.

After discussing a bit with @dduportal, we agreed that your proposal was maybe to add the tzdata package to let developers use their own timezone when creating a Docker image based on Jenkins' docker-agent image.

I guess @l19891223j you're building an image based on the inbound or docker-agent. If we add in the docker-agent image the tzdata package, you will be able to call this code in your Dockerfile or in your pipeline:

ln -snf /usr/share/zoneinfo/$TIME_ZONE /etc/localtime && echo $TIME_ZONE > /etc/timezone \
    && dpkg-reconfigure -f noninteractive tzdata

As ENV is persisted in the final image, we maybe should use ARG instead of ENV, or omit it.

I will then make two PRs:

  • one for adding the tzdata package
  • one for adding a paragraph in the README.md file to explain how to configure your own timezone when building a Docker image from docker-agent.

@dduportal proposed something even simpler which does not require you to build your own image.

Hi @l19891223j , the latest inbound image is now having tzdata. As documented in https://github.com/jenkinsci/docker-agent#timezones, you should be able to achieve timezone inside container agents.

Can you confirm by closing the issue or commenting out what you tried (and the problem you have) with latest version?

No response since eight months, closing this issue.