Skip to content

Commit 1d59f1d

Browse files
committed
feat: add dotnet quickstart
1 parent 88454a3 commit 1d59f1d

File tree

5 files changed

+67
-1
lines changed

5 files changed

+67
-1
lines changed

.github/dependabot.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,8 @@ updates:
5858
schedule:
5959
interval: weekly
6060
open-pull-requests-limit: 10
61+
- package-ecosystem: docker
62+
directory: "./dockerfiles/dotnet"
63+
schedule:
64+
interval: weekly
65+
open-pull-requests-limit: 10

.github/labeler.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,9 @@ multi:
5252
github_actions:
5353
- changed-files:
5454
- any-glob-to-any-file: '/.github/workflows/*'
55+
56+
57+
# Add 'dotnet' label to any change to Dockerfile* files within the root dir
58+
dotnet:
59+
- changed-files:
60+
- any-glob-to-any-file: 'dockerfiles/dotnet/**'

.github/workflows/github-docker-registry-push.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,13 @@ jobs:
214214
platforms: linux/amd64, linux/aarch64
215215
push: true
216216
tags: ghcr.io/${{ env.REPO_NAME }}/jenkinsci-tutorials:cpp_${{ env.BRANCH }}
217+
218+
- name: Build and push the jenkins agent for dotnet tutorial
219+
# This step builds and pushes the Jenkins agent for the C++ tutorial
220+
if: contains(env.files, 'dockerfiles/dotnet/Dockerfile')
221+
uses: docker/build-push-action@v6
222+
with:
223+
context: ./dockerfiles/cpp
224+
platforms: linux/amd64, linux/aarch64
225+
push: true
226+
tags: ghcr.io/${{ env.REPO_NAME }}/jenkinsci-tutorials:cpp_${{ env.BRANCH }}

docker-compose.yaml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ services:
3535
- android
3636
- multi
3737
- golang
38+
- dotnet
3839
- default
3940
# This service depends on the sidekick_service (generating SSH keys and JCasc token) completing successfully.
4041
depends_on:
@@ -61,6 +62,7 @@ services:
6162
- android
6263
- golang
6364
- cpp
65+
- dotnet
6466
- default
6567
# The CASC_RELOAD_TOKEN environment variable is used by the Jenkins controller to restart the Configuration as Code (JCasc) plugin configuration.
6668
environment:
@@ -304,7 +306,28 @@ services:
304306
retries: 5
305307
volumes:
306308
- agent-ssh-dir:/home/jenkins/.ssh:ro # Mounts the agent-ssh-dir volume to the /home/jenkins/.ssh path inside the container as read-only
307-
309+
dotnet:
310+
image: ${IMAGE_PREFIX}/${GHCR_USERNAME}/quickstart-tutorials/jenkinsci-tutorials:dotnet_${BRANCH_SUFFIX}
311+
environment:
312+
- GITPOD_WORKSPACE_URL=${GITPOD_WORKSPACE_URL}
313+
container_name: desktop-jenkins_agent-1
314+
profiles:
315+
- dotnet
316+
depends_on:
317+
sidekick_service:
318+
condition: service_completed_successfully # Depends on the successful completion of the sidekick_service
319+
jenkins_controller:
320+
condition: service_started
321+
ports:
322+
- "5000:5000"
323+
healthcheck:
324+
test: ["CMD-SHELL", "[ -f /home/jenkins/.ssh/authorized_keys ] || exit 1"]
325+
# Checks if the authorized_keys file exists in the /home/jenkins/.ssh path
326+
interval: 5s
327+
timeout: 10s
328+
retries: 5
329+
volumes:
330+
- agent-ssh-dir:/home/jenkins/.ssh:ro # Mounts the agent-ssh-dir volume to the /home/jenkins/.ssh path inside the container as read-only
308331
volumes:
309332
jenkins_home: null
310333
empty_jenkins_home: null

dockerfiles/dotnet/Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM jenkins/ssh-agent:6.10.0 as ssh-agent
2+
3+
# ca-certificates because curl uses certificates from ca-certificates
4+
RUN apt-get update && apt-get install -y --no-install-recommends libc6 libgcc1 libgssapi-krb5-2 libicu70 libssl3 libstdc++6 zlib1g && apt-get clean && \
5+
rm -rf /var/lib/apt/lists/*
6+
7+
# Now time to install dotnet
8+
ARG DOTNET_VERSION=8.0
9+
10+
# Set SHELL flags for RUN commands to allow -e and pipefail
11+
# Rationale:https://github.com/hadolint/hadolint/wiki/DL4006
12+
SHELL ["/bin/bash", "-eo", "pipefail", "-c"]
13+
14+
RUN wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh && chmod +x ./dotnet-install.sh && \
15+
./dotnet-install.sh --channel ${DOTNET_VERSION}}
16+
17+
ENV DOTNET_ROOT=$HOME/.dotnet
18+
ENV PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools
19+
20+
RUN echo "PATH=${PATH}" >> /etc/environment && chown -R jenkins:jenkins "${JENKINS_AGENT_HOME}" && \
21+
dotnet --list-sdks
22+

0 commit comments

Comments
 (0)