Skip to content

Commit

Permalink
Merge pull request #838 from linuxserver/code-server-dotnet-multi
Browse files Browse the repository at this point in the history
dotnet: switch to multi-arch
  • Loading branch information
aptalca authored Feb 18, 2024
2 parents 17f7b26 + 992698e commit d416c18
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/BuildImage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ env:
ENDPOINT: "linuxserver/mods" #don't modify
BASEIMAGE: "code-server" #replace
MODNAME: "dotnet" #replace
MULTI_ARCH: "true" #set to true if needed

jobs:
set-vars:
Expand All @@ -19,6 +20,7 @@ jobs:
echo "ENDPOINT=${{ env.ENDPOINT }}" >> $GITHUB_OUTPUT
echo "BASEIMAGE=${{ env.BASEIMAGE }}" >> $GITHUB_OUTPUT
echo "MODNAME=${{ env.MODNAME }}" >> $GITHUB_OUTPUT
echo "MULTI_ARCH=${{ env.MULTI_ARCH }}" >> $GITHUB_OUTPUT
# **** If the mod needs to be versioned, set the versioning logic below. Otherwise leave as is. ****
DOTNET_JSON="$(curl --retry 5 -sX GET https://raw.githubusercontent.com/dotnet/core/master/release-notes/releases-index.json)"
MOD_VERSION="$(echo $DOTNET_JSON | jq -r '."releases-index"[] | select(."support-phase"=="active" or ."support-phase"=="maintenance") | ."latest-sdk"' | tr '\n' '_' | head -c -1)"
Expand All @@ -28,6 +30,7 @@ jobs:
ENDPOINT: ${{ steps.outputs.outputs.ENDPOINT }}
BASEIMAGE: ${{ steps.outputs.outputs.BASEIMAGE }}
MODNAME: ${{ steps.outputs.outputs.MODNAME }}
MULTI_ARCH: ${{ steps.outputs.outputs.MULTI_ARCH }}
MOD_VERSION: ${{ steps.outputs.outputs.MOD_VERSION }}

build:
Expand All @@ -43,4 +46,5 @@ jobs:
ENDPOINT: ${{ needs.set-vars.outputs.ENDPOINT }}
BASEIMAGE: ${{ needs.set-vars.outputs.BASEIMAGE }}
MODNAME: ${{ needs.set-vars.outputs.MODNAME }}
MULTI_ARCH: ${{ needs.set-vars.outputs.MULTI_ARCH }}
MOD_VERSION: ${{ needs.set-vars.outputs.MOD_VERSION }}
37 changes: 19 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
# syntax=docker/dockerfile:1

FROM ghcr.io/linuxserver/baseimage-alpine:3.18 as buildstage
FROM ghcr.io/linuxserver/baseimage-alpine:3.19 as buildstage

ARG MOD_VERSION

RUN \
DOTNET_JSON=$(curl -sX GET "https://raw.githubusercontent.com/dotnet/core/master/release-notes/releases-index.json") && \
if [ -z ${MOD_VERSION+x} ]; then \
DOTNET_JSON=$(curl -sX GET "https://raw.githubusercontent.com/dotnet/core/master/release-notes/releases-index.json") && \
if [ -z ${MOD_VERSION+x} ]; then \
MOD_VERSION=$(echo "$DOTNET_JSON" | jq -r '."releases-index"[] | select(."support-phase"=="active" or ."support-phase"=="maintenance") | ."latest-sdk"' | tr '\n' '_' | head -c -1); \
fi && \
DOTNET_VERSIONS="${MOD_VERSION//_/ }" && \
mkdir -p /root-layer/dotnet && \
echo "$DOTNET_VERSIONS" > /root-layer/dotnet/versions.txt && \
echo "versions are ${DOTNET_VERSIONS}" && \
for i in $DOTNET_VERSIONS; do \
echo "processing version ${i}" && \
fi && \
DOTNET_VERSIONS="${MOD_VERSION//_/ }" && \
mkdir -p /root-layer/dotnet && \
echo "$DOTNET_VERSIONS" > /root-layer/dotnet/versions.txt && \
echo "versions are ${DOTNET_VERSIONS}" && \
for i in $DOTNET_VERSIONS; do \
DOTNET_RELEASE_URL=$(echo "${DOTNET_JSON}" | jq -r ".\"releases-index\"[] | select(.\"latest-sdk\"==\"${i}\") | .\"releases.json\"") && \
DOTNET_RELEASE_JSON=$(curl -fSsLX GET "${DOTNET_RELEASE_URL}") && \
AMD64_URL=$(echo "${DOTNET_RELEASE_JSON}" | jq -r ".releases[] | select(.sdk.version==\"${i}\") | .sdk.files[] | select(.name | contains(\"linux-x64.tar.gz\")) | .url") && \
ARM64_URL=$(echo "${DOTNET_RELEASE_JSON}" | jq -r ".releases[] | select(.sdk.version==\"${i}\") | .sdk.files[] | select(.name | contains(\"linux-arm64.tar.gz\")) | .url") && \
if [ $(uname -m) = "x86_64" ]; then \
echo "**** Downloading x86_64 tarball for version ${i} ****" && \
TARBALL_URL=$(echo "${DOTNET_RELEASE_JSON}" | jq -r ".releases[] | select(.sdk.version==\"${i}\") | .sdk.files[] | select(.name | contains(\"linux-x64.tar.gz\")) | .url"); \
elif [ $(uname -m) = "aarch64" ]; then \
echo "**** Downloading aarch64 tarball for version ${i} ****" && \
TARBALL_URL=$(echo "${DOTNET_RELEASE_JSON}" | jq -r ".releases[] | select(.sdk.version==\"${i}\") | .sdk.files[] | select(.name | contains(\"linux-arm64.tar.gz\")) | .url"); \
fi && \
curl -fSL --retry 3 --retry-connrefused -o \
/root-layer/dotnet/dotnetsdk_"${i}"_x86_64.tar.gz -L \
"${AMD64_URL}" && \
curl -fSL --retry 3 --retry-connrefused -o \
/root-layer/dotnet/dotnetsdk_"${i}"_aarch64.tar.gz -L \
"${ARM64_URL}" || exit 1; \
done
/root-layer/dotnet/dotnetsdk_"${i}".tar.gz -L \
"${TARBALL_URL}" || exit 1; \
done

COPY root/ /root-layer/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if [ -d /dotnet ]; then
DOTNET_VERSIONS=$(cat /dotnet/versions.txt)
for i in $DOTNET_VERSIONS; do
mkdir -p "/dotnet_${i}"
tar xzf "/dotnet/dotnetsdk_${i}_${ARCH}.tar.gz" -C "/dotnet_${i}"
tar xzf "/dotnet/dotnetsdk_${i}.tar.gz" -C "/dotnet_${i}"
done
rm -rf /dotnet
# symlink latest dotnet binary
Expand Down

0 comments on commit d416c18

Please sign in to comment.