You can prepare a container for the build agent environment that suits your environment.
There are two policies for building agent configuration.
There are up to two build agents in the free tier, so for small project use you'll want one agent to have multiple build environments (unless you pay). Probably the same for personal use.
By minimizing the build agent, you can easily set up your build environment and keep your Dockerfile small. On the other hand, you have to manage the agent manually.
Unless you have a specific requirement, it's a good idea to start with the regular agent container (https://github.com/JetBrains/teamcity-docker-agent). It seems that the environment setup for .NET build and Docker deployment is also done. On the other hand, if you have a hard project use and want to make the container as small as possible, or if you don't want to put in extra things for complete management, [Minimum Agent Container](https://github.com/JetBrains/teamcity- docker-minimal-agent) may be used.
In any case, Java 8 is included as the execution environment of the agent itself. (It seems that you are using Amazon Coretto derived from OpenJDK)
This time, I decided to add the JDK starting from Minimum Agent Container.
The container used is the latest
of the linux
(Ubuntu) tag.
If you refer to Automatic detection of Java environment of agent, it will be automatically detected in the following directories. .. After that, it seems that you can set the search destination path in the configuration file.
Unix
The following directories are searched for Java subdirectories:
/usr/local/java /usr/local /usr/java /usr/lib/jvm /usr
Dockerfile sample when adding jdk11. Don't forget to add the JDK for Minimum Agent Container.
Dockerfile
FROM jetbrains/teamcity-minimal-agent:latest
LABEL maintainer=""
# JDK preparation start
# Amazon Coretto 11
ARG MD5SUM='08a0cea184824c5477a62ce6a6a0fb0b'
ARG JDK_URL='https://d3pxv6yz143wms.cloudfront.net/11.0.3.7.1/amazon-corretto-11.0.3.7.1-linux-x64.tar.gz'
RUN set -eux; \
curl -LfsSo /tmp/openjdk.tar.gz ${JDK_URL}; \
echo "${MD5SUM} */tmp/openjdk.tar.gz" | md5sum -c -; \
mkdir -p /usr/local/java/openjdk; \
cd /usr/local/java/openjdk; \
tar -xf /tmp/openjdk.tar.gz --strip-components=1; \
rm -rf /tmp/openjdk.tar.gz;
# JDK preparation end
##################################
It is easier to manage on the server if you name the agent using AGENT_NAME.
docker-compose.yml
version: '3'
services:
ci-agent-java11:
build: ./ci/ci-agent/
environment:
- SERVER_URL=ci:8111
- AGENT_NAME=Java11
ports:
- 9090:9090
 volumes:
- ./ci/agent-java11/conf:/data/teamcity_agent/conf
If the build step is the default, the JDK of the build agent JAVA_HOME
is used, so specify the set JDK.
If it is difficult to manage with the default
pool alone, divide the agents appropriately into pools and assign them to each project.
Ijo.
Recommended Posts