From f19acfde53dc3d20d31da3a39d96542da89a84e3 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Sun, 1 Nov 2020 15:33:37 -0600 Subject: [PATCH 1/4] Switch to GHA, add GHCR --- .github/workflows/BuildImage.yml | 62 ++++++++++++++++++++++++++++++++ .travis.yml | 42 ---------------------- 2 files changed, 62 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/BuildImage.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/BuildImage.yml b/.github/workflows/BuildImage.yml new file mode 100644 index 0000000..b28662e --- /dev/null +++ b/.github/workflows/BuildImage.yml @@ -0,0 +1,62 @@ +name: Build Image + +on: [push, pull_request, workflow_dispatch] + +env: + ENDPOINT: "linuxserver/mods" #don't modify + BASEIMAGE: "code-server" #replace + MODNAME: "dotnet" #replace + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2.3.3 + + - name: Build image + run: | + docker build --no-cache -t ${{ github.sha }} . + + - name: Tag image + if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) }} + run: | + docker tag ${{ github.sha }} ${ENDPOINT}:${BASEIMAGE}-${MODNAME} + docker tag ${{ github.sha }} ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ github.sha }} + docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME} + docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ github.sha }} + + - name: Credential check + if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) }} + run: | + echo "CR_USER=${{ secrets.CR_USER }}" >> $GITHUB_ENV + echo "CR_PAT=${{ secrets.CR_PAT }}" >> $GITHUB_ENV + echo "DOCKERUSER=${{ secrets.DOCKERUSER }}" >> $GITHUB_ENV + echo "DOCKERPASS=${{ secrets.DOCKERPASS }}" >> $GITHUB_ENV + if [[ "${{ secrets.CR_USER }}" == "" && "${{ secrets.CR_PAT }}" == "" && "${{ secrets.DOCKERUSER }}" == "" && "${{ secrets.DOCKERPASS }}" == "" ]]; then + echo "::error::Push credential secrets missing." + echo "::error::You must set either CR_USER & CR_PAT or DOCKERUSER & DOCKERPASS as secrets in your repo settings." + echo "::error::See https://github.com/linuxserver/docker-mods/blob/master/README.md for more information/instructions." + exit 1 + fi + + - name: Login to GitHub Container Registry + if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) && env.CR_USER && env.CR_PAT }} + run: | + echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u ${{ secrets.CR_USER }} --password-stdin + + - name: Push tags to GitHub Container Registry + if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) && env.CR_USER && env.CR_PAT }} + run: | + docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ github.sha }} + docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME} + + - name: Login to DockerHub + if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) && env.DOCKERUSER && env.DOCKERPASS }} + run: | + echo ${{ secrets.DOCKERPASS }} | docker login -u ${{ secrets.DOCKERUSER }} --password-stdin + + - name: Push tags to DockerHub + if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) && env.DOCKERUSER && env.DOCKERPASS }} + run: | + docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ github.sha }} + docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 44e4732..0000000 --- a/.travis.yml +++ /dev/null @@ -1,42 +0,0 @@ -os: linux - -language: shell - -branches: - only: - - code-server-dotnet - -services: - - docker - -env: - global: - - DOCKERHUB="linuxserver/mods" - - BASEIMAGE="code-server" - - MODNAME="dotnet" - -jobs: - include: - - stage: PR-BuildImage - if: (type IN (pull_request)) - script: - # Build image - - DOTNET_JSON="$(curl --retry 5 -sX GET https://raw.githubusercontent.com/dotnet/core/master/release-notes/releases-index.json)" - - DOTNET_VERSIONS="$(echo $DOTNET_JSON | jq -r '."releases-index"[] | select(."support-phase"=="lts") | ."latest-sdk"' | tr '\n' ' ' | head -c -1)" - - docker build --no-cache --build-arg DOTNET_VERSIONS="${DOTNET_VERSIONS}" -t ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT} . - - stage: BuildImage - if: (NOT (type IN (pull_request))) - script: - # Build image - - DOTNET_JSON="$(curl --retry 5 -sX GET https://raw.githubusercontent.com/dotnet/core/master/release-notes/releases-index.json)" - - DOTNET_VERSIONS="$(echo $DOTNET_JSON | jq -r '."releases-index"[] | select(."support-phase"=="lts") | ."latest-sdk"' | tr '\n' ' ' | head -c -1)" - - DOTNET_TAG="$(echo $DOTNET_VERSIONS | tr ' ' '_')" - - docker build --no-cache --build-arg DOTNET_VERSIONS="${DOTNET_VERSIONS}" -t ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT} . - - docker tag ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT} ${DOCKERHUB}:${BASEIMAGE}-${MODNAME} - - docker tag ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT} ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${DOTNET_TAG} - # Login to DockerHub - - echo $DOCKERPASS | docker login -u $DOCKERUSER --password-stdin - # Push all of the tags - - docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT} - - docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME} - - docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${DOTNET_TAG} \ No newline at end of file From 536943cdc67bcf725a3d58535aef6f94c05eb702 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Mon, 2 Nov 2020 12:57:23 -0600 Subject: [PATCH 2/4] Update BuildImage.yml --- .github/workflows/BuildImage.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/BuildImage.yml b/.github/workflows/BuildImage.yml index b28662e..ca58270 100644 --- a/.github/workflows/BuildImage.yml +++ b/.github/workflows/BuildImage.yml @@ -15,14 +15,24 @@ jobs: - name: Build image run: | - docker build --no-cache -t ${{ github.sha }} . + # Set version + DOTNET_JSON="$(curl --retry 5 -sX GET https://raw.githubusercontent.com/dotnet/core/master/release-notes/releases-index.json)" + DOTNET_VERSIONS="$(echo $DOTNET_JSON | jq -r '."releases-index"[] | select(."support-phase"=="lts") | ."latest-sdk"' | tr '\n' ' ' | head -c -1)" + DOTNET_TAG="$(echo $DOTNET_VERSIONS | tr ' ' '_')" + echo "DOTNET_TAG=${{ secrets.DOTNET_TAG }}" >> $GITHUB_ENV + # Build image + docker build --no-cache --build-arg DOTNET_VERSIONS="${DOTNET_VERSIONS}" -t ${{ github.sha }} . - name: Tag image if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) }} run: | docker tag ${{ github.sha }} ${ENDPOINT}:${BASEIMAGE}-${MODNAME} + docker tag ${{ github.sha }} ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.DOTNET_TAG }} + docker tag ${{ github.sha }} ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.DOTNET_TAG }}-${{ github.sha }} docker tag ${{ github.sha }} ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ github.sha }} docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME} + docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.DOTNET_TAG }} + docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.DOTNET_TAG }}-${{ github.sha }} docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ github.sha }} - name: Credential check @@ -47,6 +57,8 @@ jobs: - name: Push tags to GitHub Container Registry if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) && env.CR_USER && env.CR_PAT }} run: | + docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.DOTNET_TAG }} + docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.DOTNET_TAG }}-${{ github.sha }} docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ github.sha }} docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME} @@ -58,5 +70,7 @@ jobs: - name: Push tags to DockerHub if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) && env.DOCKERUSER && env.DOCKERPASS }} run: | + docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.DOTNET_TAG }} + docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.DOTNET_TAG }}-${{ github.sha }} docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ github.sha }} docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME} From 7a1c3aecdf35e441d54b41ab1df5baca3752d99b Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Mon, 2 Nov 2020 13:01:22 -0600 Subject: [PATCH 3/4] Update BuildImage.yml --- .github/workflows/BuildImage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/BuildImage.yml b/.github/workflows/BuildImage.yml index ca58270..6f1d6aa 100644 --- a/.github/workflows/BuildImage.yml +++ b/.github/workflows/BuildImage.yml @@ -19,7 +19,7 @@ jobs: DOTNET_JSON="$(curl --retry 5 -sX GET https://raw.githubusercontent.com/dotnet/core/master/release-notes/releases-index.json)" DOTNET_VERSIONS="$(echo $DOTNET_JSON | jq -r '."releases-index"[] | select(."support-phase"=="lts") | ."latest-sdk"' | tr '\n' ' ' | head -c -1)" DOTNET_TAG="$(echo $DOTNET_VERSIONS | tr ' ' '_')" - echo "DOTNET_TAG=${{ secrets.DOTNET_TAG }}" >> $GITHUB_ENV + echo "DOTNET_TAG=${DOTNET_TAG}" >> $GITHUB_ENV # Build image docker build --no-cache --build-arg DOTNET_VERSIONS="${DOTNET_VERSIONS}" -t ${{ github.sha }} . From 5459cb08eac66fda90683e0c2130236ada78c038 Mon Sep 17 00:00:00 2001 From: aptalca Date: Mon, 2 Nov 2020 16:43:23 -0500 Subject: [PATCH 4/4] switch to ghcr for baseimage --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5a74641..496a000 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM lsiobase/alpine:3.12 as buildstage +FROM ghcr.io/linuxserver/baseimage-alpine:3.12 as buildstage ARG DOTNET_VERSIONS @@ -39,4 +39,4 @@ FROM scratch LABEL maintainer="aptalca" # Add files from buildstage -COPY --from=buildstage /root-layer/ / \ No newline at end of file +COPY --from=buildstage /root-layer/ /