Skip to content

Commit 3259217

Browse files
committed
code-server-dotnet: initial release
1 parent 69f8a2e commit 3259217

7 files changed

Lines changed: 117 additions & 73 deletions

File tree

.travis.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,39 @@ language: shell
44

55
branches:
66
only:
7-
- <baseimagename>-<modname> #replace variables, omit brackets
7+
- code-server-dotnet
88

99
services:
1010
- docker
1111

1212
env:
1313
global:
14-
- DOCKERHUB="linuxserver/mods" #don't modify
15-
- BASEIMAGE="baseimagename" #replace
16-
- MODNAME="modname" #replace
14+
- DOCKERHUB="linuxserver/mods"
15+
- BASEIMAGE="code-server"
16+
- MODNAME="dotnet"
1717

1818
jobs:
1919
include:
2020
- stage: PR-BuildImage
2121
if: (type IN (pull_request))
2222
script:
2323
# Build image
24-
- docker build --no-cache -t ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT} .
24+
- DOTNET_JSON="$(curl --retry 5 -sX GET https://raw.githubusercontent.com/dotnet/core/master/release-notes/releases-index.json)"
25+
- DOTNET_VERSIONS="$(echo $DOTNET_JSON | jq -r '."releases-index"[] | select(."support-phase"=="lts") | ."latest-sdk"' | tr '\n' ' ' | head -c -1)"
26+
- docker build --no-cache --build-arg DOTNET_VERSIONS="${DOTNET_VERSIONS}" -t ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT} .
2527
- stage: BuildImage
2628
if: (NOT (type IN (pull_request)))
2729
script:
2830
# Build image
29-
- docker build --no-cache -t ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT} .
31+
- DOTNET_JSON="$(curl --retry 5 -sX GET https://raw.githubusercontent.com/dotnet/core/master/release-notes/releases-index.json)"
32+
- DOTNET_VERSIONS="$(echo $DOTNET_JSON | jq -r '."releases-index"[] | select(."support-phase"=="lts") | ."latest-sdk"' | tr '\n' ' ' | head -c -1)"
33+
- DOTNET_TAG="$(echo $DOTNET_VERSIONS | tr ' ' '_')"
34+
- docker build --no-cache --build-arg DOTNET_VERSIONS="${DOTNET_VERSIONS}" -t ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT} .
3035
- docker tag ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT} ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}
36+
- docker tag ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT} ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${DOTNET_TAG}
3137
# Login to DockerHub
3238
- echo $DOCKERPASS | docker login -u $DOCKERUSER --password-stdin
3339
# Push all of the tags
3440
- docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT}
35-
- docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}
41+
- docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}
42+
- docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${DOTNET_TAG}

Dockerfile

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,42 @@
1+
FROM lsiobase/alpine:3.12 as buildstage
2+
3+
ARG DOTNET_VERSIONS
4+
5+
RUN \
6+
apk add --no-cache \
7+
curl \
8+
jq && \
9+
DOTNET_JSON=$(curl -sX GET "https://raw.githubusercontent.com/dotnet/core/master/release-notes/releases-index.json") && \
10+
if [ -z ${DOTNET_VERSIONS+x} ]; then \
11+
DOTNET_VERSIONS=$(echo "$DOTNET_JSON" | jq -r '."releases-index"[] | select(."support-phase"=="lts") | ."latest-sdk"' | tr '\n' ' ' | head -c -1); \
12+
fi && \
13+
mkdir -p /root-layer/dotnet && \
14+
echo "$DOTNET_VERSIONS" > /root-layer/dotnet/versions.txt && \
15+
echo "versions are ${DOTNET_VERSIONS}" && \
16+
for i in $DOTNET_VERSIONS; do \
17+
echo "processing version ${i}" && \
18+
DOTNET_RELEASE_URL=$(echo "${DOTNET_JSON}" | jq -r ".\"releases-index\"[] | select(.\"latest-sdk\"==\"${i}\") | .\"releases.json\"") && \
19+
DOTNET_RELEASE_JSON=$(curl -sX GET "${DOTNET_RELEASE_URL}") && \
20+
AMD64_URL=$(echo "${DOTNET_RELEASE_JSON}" | jq -r ".releases[] | select(.sdk.version==\"${i}\") | .sdk.files[] | select(.name | contains(\"linux-x64\")) | .url") && \
21+
ARM32_URL=$(echo "${DOTNET_RELEASE_JSON}" | jq -r ".releases[] | select(.sdk.version==\"${i}\") | .sdk.files[] | select(.name | contains(\"linux-arm.\")) | .url") && \
22+
ARM64_URL=$(echo "${DOTNET_RELEASE_JSON}" | jq -r ".releases[] | select(.sdk.version==\"${i}\") | .sdk.files[] | select(.name | contains(\"linux-arm64\")) | .url") && \
23+
curl -fS --retry 3 --retry-connrefused -o \
24+
/root-layer/dotnet/dotnetsdk_"${i}"_x86_64.tar.gz -L \
25+
"${AMD64_URL}" && \
26+
curl -fS --retry 3 --retry-connrefused -o \
27+
/root-layer/dotnet/dotnetsdk_"${i}"_armv7l.tar.gz -L \
28+
"${ARM32_URL}" && \
29+
curl -fS --retry 3 --retry-connrefused -o \
30+
/root-layer/dotnet/dotnetsdk_"${i}"_aarch64.tar.gz -L \
31+
"${ARM64_URL}"; \
32+
done
33+
34+
COPY root/ /root-layer/
35+
36+
# runtime stage
137
FROM scratch
238

3-
LABEL maintainer="username"
39+
LABEL maintainer="aptalca"
440

5-
# copy local files
6-
COPY root/ /
41+
# Add files from buildstage
42+
COPY --from=buildstage /root-layer/ /

Dockerfile.complex

Lines changed: 0 additions & 21 deletions
This file was deleted.

README.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
# Rsync - Docker mod for openssh-server
1+
# .NET Core SDK - Docker mod for code server
22

3-
This mod adds rsync to openssh-server, to be installed/updated during container start.
3+
This mod adds .NET CORE SDK to code server.
44

5-
In openssh-server docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:openssh-server-rsync`
5+
In code server docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:code-server-dotnet`
66

7-
If adding multiple mods, enter them in an array separated by `|`, such as `DOCKER_MODS=linuxserver/mods:openssh-server-rsync|linuxserver/mods:openssh-server-mod2`
7+
If adding multiple mods, enter them in an array separated by `|`, such as `DOCKER_MODS=linuxserver/mods:code-server-dotnet|linuxserver/mods:code-server-mod2`
88

9-
# Mod creation instructions
9+
All current [lts releases](https://dotnet.microsoft.com/download/dotnet-core) will be made available inside the container (3.1.403 and 2.1.811 as of 2020/10/14).
1010

11-
* Fork the repo, create a new branch based on the branch `template`.
12-
* Edit the `Dockerfile` for the mod. `Dockerfile.complex` is only an example and included for reference; it should be deleted when done.
13-
* Inspect the `root` folder contents. Edit, add and remove as necessary.
14-
* Edit this readme with pertinent info, delete these instructions.
15-
* Finally edit the `travis.yml`. Customize the build branch, and the vars for `BASEIMAGE` and `MODNAME`.
16-
* Ask the team to create a new branch named `<baseimagename>-<modname>`. Baseimage should be the name of the image the mod will be applied to. The new branch will be based on the `template` branch.
17-
* Submit PR against the branch created by the team.
11+
The binaries are accessible at `/dotnet_<sdkversion>/dotnet` for each respective version.
12+
13+
The latest version binary is symlinked from `/usr/local/bin/dotnet` so it can be called via `dotnet` from anywhere.

root/etc/cont-init.d/98-dotnet

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/with-contenv bash
2+
3+
# Determine if setup is needed
4+
if [ -d /dotnet ]; then
5+
# remove existing install if updating
6+
if ls -d /dotnet_* >/dev/null 2>&1; then
7+
echo "deleting" $(ls -d /dotnet_*)
8+
rm -rf /dotnet_*
9+
fi
10+
DOTNET_VERSIONS=$(cat /dotnet/versions.txt)
11+
ARCH=$(uname -m)
12+
for i in $DOTNET_VERSIONS; do
13+
mkdir -p "/dotnet_${i}"
14+
tar xzf "/dotnet/dotnetsdk_${i}_${ARCH}.tar.gz" -C "/dotnet_${i}"
15+
done
16+
rm -rf /dotnet
17+
# symlink latest dotnet binary
18+
DOTNET_LATEST=$(echo "$DOTNET_VERSIONS" | awk '{print $1}')
19+
rm -rf /usr/local/bin/dotnet
20+
ln -s /dotnet_${DOTNET_LATEST}/dotnet /usr/local/bin/dotnet
21+
echo "
22+
****************************************************
23+
****************************************************
24+
**
25+
**
26+
DOTNET SDK versions installed:
27+
$(echo $DOTNET_VERSIONS | sed 's| |\n |g')
28+
**
29+
**
30+
Binary locations are:"
31+
for i in $DOTNET_VERSIONS; do
32+
echo " /dotnet_${i}/dotnet"
33+
done
34+
echo " **
35+
**
36+
Version $DOTNET_LATEST is symlinked from /usr/local/bin/dotnet and can be called from anywhere via \"dotnet\"
37+
**
38+
**
39+
****************************************************
40+
****************************************************"
41+
# symlink other dotnet installs for access through latest binary
42+
for i in {2..5}; do
43+
DOTNET_OTHER_SDK_VERSION="$(echo $DOTNET_VERSIONS | awk -v var=${i} '{print $var}')"
44+
if [ -n "$DOTNET_OTHER_SDK_VERSION" ]; then
45+
DOTNET_OTHER_RUNTIME_VERSION="$(ls /dotnet_${DOTNET_OTHER_SDK_VERSION}/shared/Microsoft.NETCore.App)"
46+
echo "**** Symlinking sdk version ${DOTNET_OTHER_SDK_VERSION} and runtime version ${DOTNET_OTHER_RUNTIME_VERSION} ****"
47+
ln -s "/dotnet_${DOTNET_OTHER_SDK_VERSION}/shared/Microsoft.NETCore.App/${DOTNET_OTHER_RUNTIME_VERSION}" "/dotnet_${DOTNET_LATEST}/shared/Microsoft.NETCore.App/${DOTNET_OTHER_RUNTIME_VERSION}"
48+
ln -s "/dotnet_${DOTNET_OTHER_SDK_VERSION}/shared/Microsoft.AspNetCore.App/${DOTNET_OTHER_RUNTIME_VERSION}" "/dotnet_${DOTNET_LATEST}/shared/Microsoft.AspNetCore.App/${DOTNET_OTHER_RUNTIME_VERSION}"
49+
ln -s "/dotnet_${DOTNET_OTHER_SDK_VERSION}/sdk/${DOTNET_OTHER_SDK_VERSION}" "/dotnet_${DOTNET_LATEST}/sdk/${DOTNET_OTHER_SDK_VERSION}"
50+
else
51+
break
52+
fi
53+
done
54+
else
55+
echo "**** Existing dotnet install is up to date, skipping ****"
56+
fi

root/etc/cont-init.d/98-vpn-config

Lines changed: 0 additions & 27 deletions
This file was deleted.

root/etc/services.d/sshvpn/run

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)