From ca2c0ce48ee3a046b0b132d015aed836badf9ed6 Mon Sep 17 00:00:00 2001 From: aptalca Date: Sun, 2 Feb 2020 15:54:30 -0500 Subject: [PATCH 01/23] create template branch --- .dockerignore | 6 ++ .gitattributes | 17 +++++ .gitignore | 43 +++++++++++++ .travis.yml | 25 +++++--- README.md | 166 ++++--------------------------------------------- blacklist.txt | 2 - 6 files changed, 95 insertions(+), 164 deletions(-) create mode 100644 .dockerignore create mode 100644 .gitattributes create mode 100644 .gitignore delete mode 100644 blacklist.txt diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..cdb1a82f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.git +.gitignore +.github +.gitattributes +READMETEMPLATE.md +README.md diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..bdb0cabc --- /dev/null +++ b/.gitattributes @@ -0,0 +1,17 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Custom for Visual Studio +*.cs diff=csharp + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..96374c4e --- /dev/null +++ b/.gitignore @@ -0,0 +1,43 @@ +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# ========================= +# Operating System Files +# ========================= + +# OSX +# ========================= + +.DS_Store +.AppleDouble +.LSOverride + +# Thumbnails +._* + +# Files that might appear on external disk +.Spotlight-V100 +.Trashes + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk diff --git a/.travis.yml b/.travis.yml index 388a81b2..e6e5b1fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,24 +1,35 @@ -sudo: true +os: linux -language: bash +language: shell + +branches: + only: + - - #replace variables, omit brackets services: - docker env: global: - - DOCKERHUB="user/endpoint" + - DOCKERHUB="linuxserver/mods" #don't modify + - BASEIMAGE="baseimagename" #replace + - MODNAME="modname" #replace jobs: include: + - stage: PR-BuildImage + if: (type IN (pull_request)) + script: + # Build image + - docker build --no-cache -t ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT} . - stage: BuildImage if: (NOT (type IN (pull_request))) script: # Build image - - docker build --no-cache -t ${DOCKERHUB}:${TRAVIS_COMMIT} . - - docker tag ${DOCKERHUB}:${TRAVIS_COMMIT} ${DOCKERHUB}:latest + - docker build --no-cache -t ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT} . + - docker tag ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT} ${DOCKERHUB}:${BASEIMAGE}-${MODNAME} # Login to DockerHub - echo $DOCKERPASS | docker login -u $DOCKERUSER --password-stdin # Push all of the tags - - docker push ${DOCKERHUB}:${TRAVIS_COMMIT} - - docker push ${DOCKERHUB}:latest + - docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT} + - docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME} \ No newline at end of file diff --git a/README.md b/README.md index 413c5005..867a00c1 100644 --- a/README.md +++ b/README.md @@ -1,159 +1,15 @@ -# Intro +# Docker mod for openssh-server -The purpose of the repository is to provide examples and guidance in creating and storing a user consumable modification layer for the Library of Linuxserver.io Dockerhub Containers. -At it's core a Docker Mod is a tarball of files stored on Dockerhub that is downloaded and extracted on container boot before any init logic is run. -This allows: +This mod adds rsync to openssh-server, to be installed/updated during container start. -* Developers and community users to modify base containers to suit their needs without the need to maintain a fork of the main docker repository -* Mods to be shared with the Linuxserver.io userbase as individual independent projects with their own support channels and development ideologies -* Zero cost hosting and build pipelines for these modifications leveraging Github and Dockerhub -* Full custom configuration management layers for hooking containers into each other using environment variables contained in a compose file +In openssh-server docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:openssh-server-rsync` -It is important to note to end users of this system that there are not only extreme security implications to consuming files from souces outside of our control, but by leveraging community Mods you essentially lose direct support from the core LinuxServer team. Our first and foremost troubleshooting step will be to remove the `DOCKER_MODS` environment variable when running into issues and replace the container with a clean LSIO one. +# Mod creation instructions -Again, when pulling in logic from external sources practice caution and trust the sources/community you get them from. - -## Using a Docker Mod - -Before consuming a Docker Mod ensure that the source code for it is publicly posted along with it's build pipeline pushing to Dockerhub. - -Consumption of a Docker Mod is intended to be as user friendly as possible and can be achieved with the following environment variables being passed to the container: - -* DOCKER_MODS- This can be a single endpoint `user/endpoint:tag` or an array of endpoints separated by `|` `user/endpoint:tag|user2/endpoint2:tag` -* RUN_BANNED_MODS- If this is set to any value you will bypass our centralized filter of banned Dockerhub users and run Mods regardless of a ban - -Full example: - -``` -docker create \ - --name=nzbget \ - -e DOCKER_MODS=taisun/nzbget-mod:latest \ - -e PUID=1000 \ - -e PGID=1000 \ - -e TZ=Europe/London \ - -p 6789:6789 \ - -v :/config \ - -v :/downloads \ - --restart unless-stopped \ - linuxserver/nzbget -``` - -This will spinup an nzbget container and apply the custom logic found in the following repository: - -https://github.com/Taisun-Docker/Linuxserver-Mod-Demo - -This basic demo installs Pip and a couple dependencies for plugins some users leverage with nzbget. - -## Creating and maintaining a Docker Mod - -We will always recommend to our users consuming Mods that they leverage ones from active community members or projects so transparency is key here. We understand that image layers can be pushed on the back end behind these pipelines, but every little bit helps. -In this repository we will be going over two basic methods of making a Mod along with an example of the Travis-CI.org build logic to get this into a Dockerhub endpoint. Though we are not officially endorsing Travis-CI here it is one of the most popular Open Source free build pipelines and only requires a Github account to get started. If you prefer others feel free to use them as long as build jobs are transparent. - -One of the core ideas to remember when creating a Mod is that it can only contain a single image layer, the examples below will show you how to add files standardly and how to run complex logic to assemble the files in a build layer to copy them over into this single layer. - -### Docker Mod Simple - just add scripts - -In this repository you will find the `Dockerfile` containing: - -``` -FROM scratch - -# copy local files -COPY root/ / -``` - -For most users this will suffice and anything in the root/ folder of the repository will be added to the end users Docker container / path. - -The most common paths to leverage for Linuxserver images will be: - -* root/etc/cont-init.d/<25-script-name> - Contains init logic scripts that run before the services in the container start these should exit 0 and are ordered by filename -* root/etc/services.d//run - Contains scripts that run in the foreground for persistent services IE NGINX -* root/defaults - Contains base config files that are copied/modified on first spinup - -The example files in this repo contain a script to install sshutil and a service file to run the installed utility. - -### Docker Mod Complex - Sky is the limit - -In this repository you will find the `Dockerfile.complex` containing: - -``` -## Buildstage ## -FROM lsiobase/alpine:3.9 as buildstage - -RUN \ - echo "**** install packages ****" && \ - apk add --no-cache \ - curl && \ - echo "**** grab rclone ****" && \ - mkdir -p /root-layer && \ - curl -o \ - /root-layer/rclone.deb -L \ - "https://downloads.rclone.org/v1.47.0/rclone-v1.47.0-linux-amd64.deb" - -# copy local files -COPY root/ /root-layer/ - -## Single layer deployed image ## -FROM scratch - -# Add files from buildstage -COPY --from=buildstage /root-layer/ / -``` - -Here we are leveraging a multi stage DockerFile to run custom logic and pull down an Rclone deb from the Internet to include in our image layer for distribution. Any amount of logic can be run in this build stage or even multiple build stages as long as the files in the end are combined into a single folder for the COPY command in the final output. - -## Full loop - getting a Mod to Dockerhub - -First and foremost to publish a Mod you will need the following accounts: -* Github- https://github.com/join -* DockerHub- https://hub.docker.com/signup - -We reccomend using this repositroy as a template for your first Mod, so in this section we assume the code is finished and we will only concentrate on plugging into Travis/Dockerhub. - -The only code change you need to make to the build logic file `.travis.yml` will be to modify the DOCKERHUB endpoint to your own image: -``` -env: - global: - - DOCKERHUB="user/endpoint" -``` - -User is your Dockerhub user and endpoint is your own custom name. You do not need to create this endpoint beforehand, the build logic will push it and create it on first run. - -Head over to https://travis-ci.org/ and click on signup: - -![signup](https://s3-us-west-2.amazonaws.com/linuxserver-docs/images/signup.png) - -This will use Github to auth you in. Once in the dashboard click on "Add new Repository": - -![addnew](https://s3-us-west-2.amazonaws.com/linuxserver-docs/images/addnew.png) - -Click on settings for the repo you want to add: - -![settings](https://s3-us-west-2.amazonaws.com/linuxserver-docs/images/settings.png) - -Under the "Environment Variables" section add DOCKERUSER and DOCKERPASS as shown below, these will be your live Dockerhub credentials: - -![env](https://s3-us-west-2.amazonaws.com/linuxserver-docs/images/env.png) - -Once these are set click on the "Current" tab and "Activate repository": - -![activate](https://s3-us-west-2.amazonaws.com/linuxserver-docs/images/activate.png) - -Travis will trigger a build off of your repo and will push to Dockerhub on success. This Dockerhub endpoint is the Mod variable you can use to customize your container now. - - -## Appendix - -### Inspecting mods - -To inspect the file contents of external Mods dive is a great CLI tool: - -https://github.com/wagoodman/dive - -Basic usage: - -``` -docker run --rm -it \ - -v /var/run/docker.sock:/var/run/docker.sock \ - wagoodman/dive:latest -``` +* Ask the team to create a new branch named `-`. Baseimage should be the name of the image the mod will be applied to. The new branch will be based on the `template` branch. +* Fork the repo, checkout the template branch. +* Edit the `Dockerfile` for the mod. `Dockerfile.complex` is only an example and included for reference; it should be deleted when done. +* Inspect the `root` folder contents. Edit, add and remove as necessary. +* Edit this readme with pertinent info, delete thse instructions. +* Finally edit the `travis.yml`. Customize the build branch,and the vars for `BASEIMAGE` and `MODNAME` +* Submit PR against the branch created by the team \ No newline at end of file diff --git a/blacklist.txt b/blacklist.txt deleted file mode 100644 index 9cce7e51..00000000 --- a/blacklist.txt +++ /dev/null @@ -1,2 +0,0 @@ -evilbitcoinminer -rootkitinc From 5be8b23ea105ad27c9cf986c4945ddef99ece6dd Mon Sep 17 00:00:00 2001 From: aptalca Date: Wed, 1 Apr 2020 17:35:56 -0400 Subject: [PATCH 02/23] readme and template updates --- README.md | 12 +++++++----- .../etc/cont-init.d/{99-vpn-config => 98-vpn-config} | 0 2 files changed, 7 insertions(+), 5 deletions(-) rename root/etc/cont-init.d/{99-vpn-config => 98-vpn-config} (100%) diff --git a/README.md b/README.md index 867a00c1..2418e530 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,17 @@ -# Docker mod for openssh-server +# Rsync - Docker mod for openssh-server This mod adds rsync to openssh-server, to be installed/updated during container start. In openssh-server docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:openssh-server-rsync` +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` + # Mod creation instructions * Ask the team to create a new branch named `-`. Baseimage should be the name of the image the mod will be applied to. The new branch will be based on the `template` branch. -* Fork the repo, checkout the template branch. +* Fork the repo, checkout the newly created branch. * Edit the `Dockerfile` for the mod. `Dockerfile.complex` is only an example and included for reference; it should be deleted when done. * Inspect the `root` folder contents. Edit, add and remove as necessary. -* Edit this readme with pertinent info, delete thse instructions. -* Finally edit the `travis.yml`. Customize the build branch,and the vars for `BASEIMAGE` and `MODNAME` -* Submit PR against the branch created by the team \ No newline at end of file +* Edit this readme with pertinent info, delete these instructions. +* Finally edit the `travis.yml`. Customize the build branch, and the vars for `BASEIMAGE` and `MODNAME`. +* Submit PR against the branch created by the team. \ No newline at end of file diff --git a/root/etc/cont-init.d/99-vpn-config b/root/etc/cont-init.d/98-vpn-config similarity index 100% rename from root/etc/cont-init.d/99-vpn-config rename to root/etc/cont-init.d/98-vpn-config From 30f904f9520dc03d1814de532c2bd64d6754be45 Mon Sep 17 00:00:00 2001 From: aptalca Date: Thu, 7 May 2020 16:57:38 -0400 Subject: [PATCH 03/23] code-server: golang initial release --- .travis.yml | 31 ++++++++++++++++++++++-------- Dockerfile | 27 ++++++++++++++++++++++++-- Dockerfile.complex | 21 -------------------- README.md | 28 +++++++++++++++------------ root/etc/cont-init.d/98-golang | 10 ++++++++++ root/etc/cont-init.d/98-vpn-config | 27 -------------------------- root/etc/services.d/sshvpn/run | 3 --- 7 files changed, 74 insertions(+), 73 deletions(-) delete mode 100644 Dockerfile.complex create mode 100644 root/etc/cont-init.d/98-golang delete mode 100644 root/etc/cont-init.d/98-vpn-config delete mode 100644 root/etc/services.d/sshvpn/run diff --git a/.travis.yml b/.travis.yml index e6e5b1fb..4b521df0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,16 +4,16 @@ language: shell branches: only: - - - #replace variables, omit brackets + - code-server-golang services: - docker env: global: - - DOCKERHUB="linuxserver/mods" #don't modify - - BASEIMAGE="baseimagename" #replace - - MODNAME="modname" #replace + - DOCKERHUB="linuxserver/mods" + - BASEIMAGE="code-server" + - MODNAME="golang" jobs: include: @@ -25,11 +25,26 @@ jobs: - stage: BuildImage if: (NOT (type IN (pull_request))) script: + # Set version + - GO_WEBSITE=$(curl -sX GET https://golang.org/dl/) + - GO_VERSION=${GO_VERSION:-$(echo "$GO_WEBSITE" | grep -o '.*linux-amd64.*' | grep -oP '(?<=go).*(?=.linux)')} + - if [ $(echo "$GO_VERSION" | tr -d -c '.' | awk '{ print length; }') = "1" ]; then GO_TAG="${GO_VERSION}.0"; else GO_TAG="${GO_VERSION}"; fi + - GO_TAG_MINOR=$(echo "$GO_TAG" | awk 'BEGIN{FS=OFS="."} NF--') + - GO_TAG_MAJOR=$(echo "$GO_TAG_MINOR" | awk 'BEGIN{FS=OFS="."} NF--') + - echo "GO_TAG is $GO_TAG GO_TAG_MINOR is $GO_TAG_MINOR GO_TAG_MAJOR is $GO_TAG_MAJOR" + - if [ "$GO_VERSION" == $(echo "$GO_WEBSITE" | grep -o '.*linux-amd64.*' | grep -oP '(?<=go).*(?=.linux)') ]; then LATEST="true"; fi + - if [ "$GO_VERSION" == $(echo "$GO_WEBSITE" | grep -o 'download" href=".*linux-amd64.tar.gz">' | grep -oP '(?<=go/go).*(?=.linux)' | grep -m 1 ^${GO_TAG_MINOR}) ]; then LATEST_MINOR="true"; fi + - if [ "$GO_VERSION" == $(echo "$GO_WEBSITE" | grep -o 'download" href=".*linux-amd64.tar.gz">' | grep -oP '(?<=go/go).*(?=.linux)' | grep -m 1 ^${GO_TAG_MAJOR}) ]; then LATEST_MAJOR="true"; fi + - echo "LATEST is ${LATEST:-not true}, LATEST_MINOR is ${LATEST_MINOR:-not true}, LATEST_MAJOR is ${LATEST_MAJOR:-not true}" # Build image - - docker build --no-cache -t ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT} . - - docker tag ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT} ${DOCKERHUB}:${BASEIMAGE}-${MODNAME} + - docker build --no-cache --build-arg GO_VERSION=${GO_VERSION} -t ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${GO_TAG} . + - if [ "$LATEST_MAJOR" == "true" ]; then docker tag ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${GO_TAG} ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${GO_TAG_MAJOR}; fi + - if [ "$LATEST_MINOR" == "true" ]; then docker tag ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${GO_TAG} ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${GO_TAG_MINOR}; fi + - if [ "$LATEST" == "true" ]; then docker tag ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${GO_TAG} ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}; fi # 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} \ No newline at end of file + - docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${GO_TAG} + - if [ "$LATEST_MAJOR" == "true" ]; then docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${GO_TAG_MAJOR}; fi + - if [ "$LATEST_MINOR" == "true" ]; then docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${GO_TAG_MINOR}; fi + - if [ "$LATEST" == "true" ]; then docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}; fi diff --git a/Dockerfile b/Dockerfile index 2f24b209..aef9d090 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,27 @@ +FROM lsiobase/alpine:3.11 as buildstage + +ARG GO_VERSION + +RUN \ + apk add --no-cache \ + curl \ + grep && \ + if [ -z ${GO_VERSION+x} ]; then \ + GO_VERSION=$(curl -sX GET https://golang.org/dl/ | grep -o '.*linux-amd64.*' | grep -oP '(?<=go).*(?=.linux)'); \ + fi && \ + mkdir -p /root-layer/usr/local && \ + curl -o \ + /tmp/golang.tar.gz -L \ + https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz && \ + tar xzf /tmp/golang.tar.gz -C \ + /root-layer/usr/local + +COPY root/ /root-layer/ + +# runtime stage FROM scratch -# copy local files -COPY root/ / +LABEL maintainer="n-i-x" + +# Add files from buildstage +COPY --from=buildstage /root-layer/ / diff --git a/Dockerfile.complex b/Dockerfile.complex deleted file mode 100644 index 4463d838..00000000 --- a/Dockerfile.complex +++ /dev/null @@ -1,21 +0,0 @@ -## Buildstage ## -FROM lsiobase/alpine:3.9 as buildstage - -RUN \ - echo "**** install packages ****" && \ - apk add --no-cache \ - curl && \ - echo "**** grab rclone ****" && \ - mkdir -p /root-layer && \ - curl -o \ - /root-layer/rclone.deb -L \ - "https://downloads.rclone.org/v1.47.0/rclone-v1.47.0-linux-amd64.deb" - -# copy local files -COPY root/ /root-layer/ - -## Single layer deployed image ## -FROM scratch - -# Add files from buildstage -COPY --from=buildstage /root-layer/ / diff --git a/README.md b/README.md index 2418e530..6074ff4a 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,21 @@ -# Rsync - Docker mod for openssh-server +# Golang - Docker mod for code-server -This mod adds rsync to openssh-server, to be installed/updated during container start. +This mod adds golang/go to code-server. -In openssh-server docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:openssh-server-rsync` +In code-server docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:code-server-golang` -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` +If adding multiple mods, enter them in an array separated by `|`, such as `DOCKER_MODS=linuxserver/mods:code-server-golang|linuxserver/mods:code-server-mod2` -# Mod creation instructions +## Available Image Tags +- `code-server-golang` : installs the latest stable version +- `code-server-golang-X` : installs the latest major `X` version +- `code-server-golang-X.X` : installs the latest minor `X.X` version +- `code-server-golang-X.X.X` : installs the specific `X.X.X` version -* Ask the team to create a new branch named `-`. Baseimage should be the name of the image the mod will be applied to. The new branch will be based on the `template` branch. -* Fork the repo, checkout the newly created branch. -* Edit the `Dockerfile` for the mod. `Dockerfile.complex` is only an example and included for reference; it should be deleted when done. -* Inspect the `root` folder contents. Edit, add and remove as necessary. -* Edit this readme with pertinent info, delete these instructions. -* Finally edit the `travis.yml`. Customize the build branch, and the vars for `BASEIMAGE` and `MODNAME`. -* Submit PR against the branch created by the team. \ No newline at end of file +### Examples +- `linuxserver/mods:code-server-golang-1.13` will install the latest `1.13` release, which is `1.13.10` as of 2020/05/07 +- `linuxserver/mods:code-server-golang-1` will install the latest `1` release, which is `1.14.2` as of 2020/05/07 +- `linuxserver/mods:code-server-golang` will install the latest stable release, which is `1.14.2` as of 2020/05/07 +- `linuxserver/mods:code-server-golang-1.14.2` will install the specific `1.14.2` release + +Visit https://hub.docker.com/r/linuxserver/mods/tags?page=1&name=code-server-golang to see all available tags \ No newline at end of file diff --git a/root/etc/cont-init.d/98-golang b/root/etc/cont-init.d/98-golang new file mode 100644 index 00000000..d5e07511 --- /dev/null +++ b/root/etc/cont-init.d/98-golang @@ -0,0 +1,10 @@ +#!/usr/bin/with-contenv bash + +echo "ensuring golang is in PATH" +if grep -q '^PATH=' /etc/services.d/code-server/run; then + if ! grep -q '^PATH=.*/usr/local/go/bin.*' /etc/services.d/code-server/run; then + sed -i '/PATH/ s/$/:\/usr\/local\/go\/bin/' /etc/services.d/code-server/run + fi +else + sed -i '/^#!\/usr\/bin/a \\n# Added by codeserver-golang\nexport PATH=$PATH:/usr/local/go/bin' /etc/services.d/code-server/run +fi diff --git a/root/etc/cont-init.d/98-vpn-config b/root/etc/cont-init.d/98-vpn-config deleted file mode 100644 index a5f91276..00000000 --- a/root/etc/cont-init.d/98-vpn-config +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/with-contenv bash - -# Determine if setup is needed -if [ ! -f /usr/local/lib/python***/dist-packages/sshuttle ] && \ -[ -f /usr/bin/apt ]; then - ## Ubuntu - apt-get update - apt-get install --no-install-recommends -y \ - iptables \ - openssh-client \ - python3 \ - python3-pip - pip3 install sshuttle -fi -if [ ! -f /usr/lib/python***/site-packages/sshuttle ] && \ -[ -f /sbin/apk ]; then - # Alpine - apk add --no-cache \ - iptables \ - openssh \ - py3-pip \ - python3 - pip3 install sshuttle -fi - -chown -R root:root /root -chmod -R 600 /root/.ssh diff --git a/root/etc/services.d/sshvpn/run b/root/etc/services.d/sshvpn/run deleted file mode 100644 index 7d49e796..00000000 --- a/root/etc/services.d/sshvpn/run +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/with-contenv bash - -sshuttle --dns --remote root@${HOST}:${PORT} 0/0 -x 172.17.0.0/16 From a12d90ea8439aa57e50134a16b1a6b4954312332 Mon Sep 17 00:00:00 2001 From: aptalca Date: Mon, 18 May 2020 17:05:13 -0400 Subject: [PATCH 04/23] code-server-golang: multi arch --- Dockerfile | 12 ++++++++---- root/etc/cont-init.d/98-golang | 9 +++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index aef9d090..f88202b7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,12 +9,16 @@ RUN \ if [ -z ${GO_VERSION+x} ]; then \ GO_VERSION=$(curl -sX GET https://golang.org/dl/ | grep -o '.*linux-amd64.*' | grep -oP '(?<=go).*(?=.linux)'); \ fi && \ - mkdir -p /root-layer/usr/local && \ + mkdir -p /root-layer/golang && \ curl -o \ - /tmp/golang.tar.gz -L \ + /root-layer/golang/golang_x86_64.tar.gz -L \ https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz && \ - tar xzf /tmp/golang.tar.gz -C \ - /root-layer/usr/local + curl -o \ + /root-layer/golang/golang_armv7l.tar.gz -L \ + https://dl.google.com/go/go${GO_VERSION}.linux-armv6l.tar.gz && \ + curl -o \ + /root-layer/golang/golang_aarch64.tar.gz -L \ + https://dl.google.com/go/go${GO_VERSION}.linux-arm64.tar.gz COPY root/ /root-layer/ diff --git a/root/etc/cont-init.d/98-golang b/root/etc/cont-init.d/98-golang index d5e07511..41e1668e 100644 --- a/root/etc/cont-init.d/98-golang +++ b/root/etc/cont-init.d/98-golang @@ -8,3 +8,12 @@ if grep -q '^PATH=' /etc/services.d/code-server/run; then else sed -i '/^#!\/usr\/bin/a \\n# Added by codeserver-golang\nexport PATH=$PATH:/usr/local/go/bin' /etc/services.d/code-server/run fi + +ARCH=$(uname -m) +if [ -f "/golang/golang_${ARCH}.tar.gz" ]; then + echo "Installing golang" + tar xzf "/golang/golang_${ARCH}.tar.gz" -C /usr/local + rm -rf /golang +else + echo "Golang already installed, skipping" +fi From e4aebe3b5708d0107baeacb126ff54e3e7644bba Mon Sep 17 00:00:00 2001 From: n-i-x <440158+n-i-x@users.noreply.github.com> Date: Tue, 19 May 2020 23:31:49 -0400 Subject: [PATCH 05/23] Update 98-golang --- root/etc/cont-init.d/98-golang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/root/etc/cont-init.d/98-golang b/root/etc/cont-init.d/98-golang index d5e07511..e060939d 100644 --- a/root/etc/cont-init.d/98-golang +++ b/root/etc/cont-init.d/98-golang @@ -1,8 +1,8 @@ #!/usr/bin/with-contenv bash echo "ensuring golang is in PATH" -if grep -q '^PATH=' /etc/services.d/code-server/run; then - if ! grep -q '^PATH=.*/usr/local/go/bin.*' /etc/services.d/code-server/run; then +if grep -q -E '^(export )?PATH=' /etc/services.d/code-server/run; then + if ! grep -q -E '^(export )?PATH=.*/usr/local/go/bin.*' /etc/services.d/code-server/run; then sed -i '/PATH/ s/$/:\/usr\/local\/go\/bin/' /etc/services.d/code-server/run fi else From 13f13fefbb922d4df63de51b22dddd19c73ab75a Mon Sep 17 00:00:00 2001 From: n-i-x <440158+n-i-x@users.noreply.github.com> Date: Fri, 29 May 2020 11:05:27 -0400 Subject: [PATCH 06/23] Add /config/go/bin to PATH for user binaries --- root/etc/cont-init.d/98-golang | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/root/etc/cont-init.d/98-golang b/root/etc/cont-init.d/98-golang index e060939d..e38b87e7 100644 --- a/root/etc/cont-init.d/98-golang +++ b/root/etc/cont-init.d/98-golang @@ -4,7 +4,10 @@ echo "ensuring golang is in PATH" if grep -q -E '^(export )?PATH=' /etc/services.d/code-server/run; then if ! grep -q -E '^(export )?PATH=.*/usr/local/go/bin.*' /etc/services.d/code-server/run; then sed -i '/PATH/ s/$/:\/usr\/local\/go\/bin/' /etc/services.d/code-server/run + elif ! grep -q -E '^(export )?PATH=.*/config/go/bin:.*' /etc/services.d/code-server/run; then + sed -i 's/PATH=/PATH=\/config\/go\/bin:/g' /etc/services.d/code-server/run + fi fi else - sed -i '/^#!\/usr\/bin/a \\n# Added by codeserver-golang\nexport PATH=$PATH:/usr/local/go/bin' /etc/services.d/code-server/run + sed -i '/^#!\/usr\/bin/a \\n# Added by codeserver-golang\nexport PATH=/config/go/bin:$PATH:/usr/local/go/bin' /etc/services.d/code-server/run fi From c97eac0b61dc934fc429aff62b819bda62fb6a9f Mon Sep 17 00:00:00 2001 From: n-i-x <440158+n-i-x@users.noreply.github.com> Date: Fri, 29 May 2020 12:16:13 -0400 Subject: [PATCH 07/23] remove redundant fi --- root/etc/cont-init.d/98-golang | 1 - 1 file changed, 1 deletion(-) diff --git a/root/etc/cont-init.d/98-golang b/root/etc/cont-init.d/98-golang index e38b87e7..63314201 100644 --- a/root/etc/cont-init.d/98-golang +++ b/root/etc/cont-init.d/98-golang @@ -7,7 +7,6 @@ if grep -q -E '^(export )?PATH=' /etc/services.d/code-server/run; then elif ! grep -q -E '^(export )?PATH=.*/config/go/bin:.*' /etc/services.d/code-server/run; then sed -i 's/PATH=/PATH=\/config\/go\/bin:/g' /etc/services.d/code-server/run fi - fi else sed -i '/^#!\/usr\/bin/a \\n# Added by codeserver-golang\nexport PATH=/config/go/bin:$PATH:/usr/local/go/bin' /etc/services.d/code-server/run fi From 6d1525f1d2e744b02d248bdfe8386488e493a366 Mon Sep 17 00:00:00 2001 From: n-i-x <440158+n-i-x@users.noreply.github.com> Date: Fri, 29 May 2020 12:19:20 -0400 Subject: [PATCH 08/23] Fix logic.. this is embarrasing --- root/etc/cont-init.d/98-golang | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/root/etc/cont-init.d/98-golang b/root/etc/cont-init.d/98-golang index 63314201..8d246334 100644 --- a/root/etc/cont-init.d/98-golang +++ b/root/etc/cont-init.d/98-golang @@ -4,7 +4,8 @@ echo "ensuring golang is in PATH" if grep -q -E '^(export )?PATH=' /etc/services.d/code-server/run; then if ! grep -q -E '^(export )?PATH=.*/usr/local/go/bin.*' /etc/services.d/code-server/run; then sed -i '/PATH/ s/$/:\/usr\/local\/go\/bin/' /etc/services.d/code-server/run - elif ! grep -q -E '^(export )?PATH=.*/config/go/bin:.*' /etc/services.d/code-server/run; then + fi + if ! grep -q -E '^(export )?PATH=.*/config/go/bin:.*' /etc/services.d/code-server/run; then sed -i 's/PATH=/PATH=\/config\/go\/bin:/g' /etc/services.d/code-server/run fi else From d874a8de810c8e3bc7bae187b45de57aa6a9da92 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Sun, 1 Nov 2020 15:33:48 -0600 Subject: [PATCH 09/23] Switch to GHA, add GHCR --- .github/workflows/BuildImage.yml | 62 ++++++++++++++++++++++++++++++++ .travis.yml | 50 -------------------------- 2 files changed, 62 insertions(+), 50 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 00000000..1ab0e74e --- /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: "golang" #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 4b521df0..00000000 --- a/.travis.yml +++ /dev/null @@ -1,50 +0,0 @@ -os: linux - -language: shell - -branches: - only: - - code-server-golang - -services: - - docker - -env: - global: - - DOCKERHUB="linuxserver/mods" - - BASEIMAGE="code-server" - - MODNAME="golang" - -jobs: - include: - - stage: PR-BuildImage - if: (type IN (pull_request)) - script: - # Build image - - docker build --no-cache -t ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT} . - - stage: BuildImage - if: (NOT (type IN (pull_request))) - script: - # Set version - - GO_WEBSITE=$(curl -sX GET https://golang.org/dl/) - - GO_VERSION=${GO_VERSION:-$(echo "$GO_WEBSITE" | grep -o '.*linux-amd64.*' | grep -oP '(?<=go).*(?=.linux)')} - - if [ $(echo "$GO_VERSION" | tr -d -c '.' | awk '{ print length; }') = "1" ]; then GO_TAG="${GO_VERSION}.0"; else GO_TAG="${GO_VERSION}"; fi - - GO_TAG_MINOR=$(echo "$GO_TAG" | awk 'BEGIN{FS=OFS="."} NF--') - - GO_TAG_MAJOR=$(echo "$GO_TAG_MINOR" | awk 'BEGIN{FS=OFS="."} NF--') - - echo "GO_TAG is $GO_TAG GO_TAG_MINOR is $GO_TAG_MINOR GO_TAG_MAJOR is $GO_TAG_MAJOR" - - if [ "$GO_VERSION" == $(echo "$GO_WEBSITE" | grep -o '.*linux-amd64.*' | grep -oP '(?<=go).*(?=.linux)') ]; then LATEST="true"; fi - - if [ "$GO_VERSION" == $(echo "$GO_WEBSITE" | grep -o 'download" href=".*linux-amd64.tar.gz">' | grep -oP '(?<=go/go).*(?=.linux)' | grep -m 1 ^${GO_TAG_MINOR}) ]; then LATEST_MINOR="true"; fi - - if [ "$GO_VERSION" == $(echo "$GO_WEBSITE" | grep -o 'download" href=".*linux-amd64.tar.gz">' | grep -oP '(?<=go/go).*(?=.linux)' | grep -m 1 ^${GO_TAG_MAJOR}) ]; then LATEST_MAJOR="true"; fi - - echo "LATEST is ${LATEST:-not true}, LATEST_MINOR is ${LATEST_MINOR:-not true}, LATEST_MAJOR is ${LATEST_MAJOR:-not true}" - # Build image - - docker build --no-cache --build-arg GO_VERSION=${GO_VERSION} -t ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${GO_TAG} . - - if [ "$LATEST_MAJOR" == "true" ]; then docker tag ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${GO_TAG} ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${GO_TAG_MAJOR}; fi - - if [ "$LATEST_MINOR" == "true" ]; then docker tag ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${GO_TAG} ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${GO_TAG_MINOR}; fi - - if [ "$LATEST" == "true" ]; then docker tag ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${GO_TAG} ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}; fi - # Login to DockerHub - - echo $DOCKERPASS | docker login -u $DOCKERUSER --password-stdin - # Push all of the tags - - docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${GO_TAG} - - if [ "$LATEST_MAJOR" == "true" ]; then docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${GO_TAG_MAJOR}; fi - - if [ "$LATEST_MINOR" == "true" ]; then docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${GO_TAG_MINOR}; fi - - if [ "$LATEST" == "true" ]; then docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}; fi From 5799728ca54f1153d918faf381cf6fea47c65589 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Mon, 2 Nov 2020 13:32:52 -0600 Subject: [PATCH 10/23] Update BuildImage.yml --- .github/workflows/BuildImage.yml | 64 +++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 5 deletions(-) diff --git a/.github/workflows/BuildImage.yml b/.github/workflows/BuildImage.yml index 1ab0e74e..a37858cc 100644 --- a/.github/workflows/BuildImage.yml +++ b/.github/workflows/BuildImage.yml @@ -15,14 +15,44 @@ jobs: - name: Build image run: | - docker build --no-cache -t ${{ github.sha }} . + # Set version + GO_WEBSITE=$(curl -sX GET https://golang.org/dl/) + GO_VERSION=${GO_VERSION:-$(echo "$GO_WEBSITE" | grep -o '.*linux-amd64.*' | grep -oP '(?<=go).*(?=.linux)')} + if [ $(echo "$GO_VERSION" | tr -d -c '.' | awk '{ print length; }') = "1" ]; then GO_TAG="${GO_VERSION}.0"; else GO_TAG="${GO_VERSION}"; fi + echo "GO_TAG=${GO_TAG}" >> $GITHUB_ENV + GO_TAG_MINOR=$(echo "$GO_TAG" | awk 'BEGIN{FS=OFS="."} NF--') + echo "GO_TAG_MINOR=${GO_TAG_MINOR}" >> $GITHUB_ENV + GO_TAG_MAJOR=$(echo "$GO_TAG_MINOR" | awk 'BEGIN{FS=OFS="."} NF--') + echo "GO_TAG_MAJOR=${GO_TAG_MAJOR}" >> $GITHUB_ENV + echo "GO_TAG is $GO_TAG GO_TAG_MINOR is $GO_TAG_MINOR GO_TAG_MAJOR is $GO_TAG_MAJOR" + if [ "$GO_VERSION" == $(echo "$GO_WEBSITE" | grep -o '.*linux-amd64.*' | grep -oP '(?<=go).*(?=.linux)') ]; then LATEST="true"; fi + echo "LATEST=${LATEST}" >> $GITHUB_ENV + if [ "$GO_VERSION" == $(echo "$GO_WEBSITE" | grep -o 'download" href=".*linux-amd64.tar.gz">' | grep -oP '(?<=go/go).*(?=.linux)' | grep -m 1 ^${GO_TAG_MINOR}) ]; then LATEST_MINOR="true"; fi + echo "LATEST_MINOR=${LATEST_MINOR}" >> $GITHUB_ENV + if [ "$GO_VERSION" == $(echo "$GO_WEBSITE" | grep -o 'download" href=".*linux-amd64.tar.gz">' | grep -oP '(?<=go/go).*(?=.linux)' | grep -m 1 ^${GO_TAG_MAJOR}) ]; then LATEST_MAJOR="true"; fi + echo "LATEST_MAJOR=${LATEST_MAJOR}" >> $GITHUB_ENV + echo "LATEST is ${LATEST:-not true}, LATEST_MINOR is ${LATEST_MINOR:-not true}, LATEST_MAJOR is ${LATEST_MAJOR:-not true}" + # Build image + docker build --no-cache --build-arg GO_VERSION=${GO_VERSION} -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.GO_TAG }} + docker tag ${{ github.sha }} ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.GO_TAG }}-${{ github.sha }} + docker tag ${{ github.sha }} ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.GO_TAG_MAJOR }} + docker tag ${{ github.sha }} ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.GO_TAG_MAJOR }}-${{ github.sha }} + docker tag ${{ github.sha }} ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.GO_TAG_MINOR }} + docker tag ${{ github.sha }} ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.GO_TAG_MINOR }}-${{ 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.GO_TAG }} + docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.GO_TAG }}-${{ github.sha }} + docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.GO_TAG_MAJOR }} + docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.GO_TAG_MAJOR }}-${{ github.sha }} + docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.GO_TAG_MINOR }} + docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.GO_TAG_MINOR }}-${{ github.sha }} docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ github.sha }} - name: Credential check @@ -47,8 +77,20 @@ 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}-${{ github.sha }} - docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME} + docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.GO_TAG }}-${{ github.sha }} + docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.GO_TAG }} + if [ "${{ env.LATEST_MAJOR }}" == "true" ]; then + docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.GO_TAG_MAJOR }}-${{ github.sha }} + docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.GO_TAG_MAJOR }} + fi + if [ "${{ env.LATEST_MINOR }}" == "true" ]; then + docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.GO_TAG_MINOR }}-${{ github.sha }} + docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.GO_TAG_MINOR }} + fi + if [ "${{ env.LATEST }}" == "true" ]; then + docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ github.sha }} + docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME} + fi - name: Login to DockerHub if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) && env.DOCKERUSER && env.DOCKERPASS }} @@ -58,5 +100,17 @@ 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}-${{ github.sha }} - docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME} + docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.GO_TAG }}-${{ github.sha }} + docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.GO_TAG }} + if [ "${{ env.LATEST_MAJOR }}" == "true" ]; then + docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.GO_TAG_MAJOR }}-${{ github.sha }} + docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.GO_TAG_MAJOR }} + fi + if [ "${{ env.LATEST_MINOR }}" == "true" ]; then + docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.GO_TAG_MINOR }}-${{ github.sha }} + docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.GO_TAG_MINOR }} + fi + if [ "${{ env.LATEST }}" == "true" ]; then + docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ github.sha }} + docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME} + fi From 779dac6e8b6806cb5a071134159aeb2f01cdb970 Mon Sep 17 00:00:00 2001 From: aptalca Date: Mon, 2 Nov 2020 16:58:13 -0500 Subject: [PATCH 11/23] switch baseimage to ghcr --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f88202b7..8694a3c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM lsiobase/alpine:3.11 as buildstage +FROM ghcr.io/linuxserver/baseimage-alpine:3.12 as buildstage ARG GO_VERSION From 2ebfef50844612ac8b0b2cf178574b02f5994b42 Mon Sep 17 00:00:00 2001 From: aptalca Date: Mon, 2 Nov 2020 17:26:35 -0500 Subject: [PATCH 12/23] update regex --- .github/workflows/BuildImage.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/BuildImage.yml b/.github/workflows/BuildImage.yml index a37858cc..723f70f5 100644 --- a/.github/workflows/BuildImage.yml +++ b/.github/workflows/BuildImage.yml @@ -27,9 +27,9 @@ jobs: echo "GO_TAG is $GO_TAG GO_TAG_MINOR is $GO_TAG_MINOR GO_TAG_MAJOR is $GO_TAG_MAJOR" if [ "$GO_VERSION" == $(echo "$GO_WEBSITE" | grep -o '.*linux-amd64.*' | grep -oP '(?<=go).*(?=.linux)') ]; then LATEST="true"; fi echo "LATEST=${LATEST}" >> $GITHUB_ENV - if [ "$GO_VERSION" == $(echo "$GO_WEBSITE" | grep -o 'download" href=".*linux-amd64.tar.gz">' | grep -oP '(?<=go/go).*(?=.linux)' | grep -m 1 ^${GO_TAG_MINOR}) ]; then LATEST_MINOR="true"; fi + if [ "$GO_VERSION" == $(echo "$GO_WEBSITE" | grep -o 'download" href=".*linux-amd64.tar.gz">' | grep -oP '(?<=\/go)[1-9].*(?=.linux)' | grep -m 1 ^${GO_TAG_MINOR}) ]; then LATEST_MINOR="true"; fi echo "LATEST_MINOR=${LATEST_MINOR}" >> $GITHUB_ENV - if [ "$GO_VERSION" == $(echo "$GO_WEBSITE" | grep -o 'download" href=".*linux-amd64.tar.gz">' | grep -oP '(?<=go/go).*(?=.linux)' | grep -m 1 ^${GO_TAG_MAJOR}) ]; then LATEST_MAJOR="true"; fi + if [ "$GO_VERSION" == $(echo "$GO_WEBSITE" | grep -o 'download" href=".*linux-amd64.tar.gz">' | grep -oP '(?<=\/go)[1-9].*(?=.linux)' | grep -m 1 ^${GO_TAG_MAJOR}) ]; then LATEST_MAJOR="true"; fi echo "LATEST_MAJOR=${LATEST_MAJOR}" >> $GITHUB_ENV echo "LATEST is ${LATEST:-not true}, LATEST_MINOR is ${LATEST_MINOR:-not true}, LATEST_MAJOR is ${LATEST_MAJOR:-not true}" # Build image From 7038ede1fa598910da8ed4b7ef5671bb8175269c Mon Sep 17 00:00:00 2001 From: aptalca Date: Fri, 6 Nov 2020 23:36:45 -0500 Subject: [PATCH 13/23] add workflow input for trigger --- .github/workflows/BuildImage.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/BuildImage.yml b/.github/workflows/BuildImage.yml index 723f70f5..16c9df30 100644 --- a/.github/workflows/BuildImage.yml +++ b/.github/workflows/BuildImage.yml @@ -1,6 +1,11 @@ name: Build Image -on: [push, pull_request, workflow_dispatch] +on: + push: + pull_request: + workflow_dispatch: + inputs: + GO_VERSION: env: ENDPOINT: "linuxserver/mods" #don't modify @@ -17,6 +22,7 @@ jobs: run: | # Set version GO_WEBSITE=$(curl -sX GET https://golang.org/dl/) + GO_VERSION=${{ github.event.inputs.GO_VERSION }} GO_VERSION=${GO_VERSION:-$(echo "$GO_WEBSITE" | grep -o '.*linux-amd64.*' | grep -oP '(?<=go).*(?=.linux)')} if [ $(echo "$GO_VERSION" | tr -d -c '.' | awk '{ print length; }') = "1" ]; then GO_TAG="${GO_VERSION}.0"; else GO_TAG="${GO_VERSION}"; fi echo "GO_TAG=${GO_TAG}" >> $GITHUB_ENV From d95b81523f573456b2653fff6945de6f53ec2033 Mon Sep 17 00:00:00 2001 From: caiych Date: Tue, 16 Mar 2021 21:52:35 +0800 Subject: [PATCH 14/23] Install gcc at the end of code-server-golang init script --- root/etc/cont-init.d/98-golang | 3 +++ 1 file changed, 3 insertions(+) diff --git a/root/etc/cont-init.d/98-golang b/root/etc/cont-init.d/98-golang index 7a0dab26..ae6c1a3f 100644 --- a/root/etc/cont-init.d/98-golang +++ b/root/etc/cont-init.d/98-golang @@ -17,6 +17,9 @@ if [ -f "/golang/golang_${ARCH}.tar.gz" ]; then echo "Installing golang" tar xzf "/golang/golang_${ARCH}.tar.gz" -C /usr/local rm -rf /golang + + echo "Installing gcc, to make CGO work" + apt-get update && apt-get install -y gcc else echo "Golang already installed, skipping" fi From f90b13c8c2a9a26bc1526700fafc4b82390350e0 Mon Sep 17 00:00:00 2001 From: aptalca Date: Wed, 16 Jun 2021 17:22:43 -0400 Subject: [PATCH 15/23] standardize apt-get --- root/etc/cont-init.d/95-apt-get | 3 +++ root/etc/cont-init.d/98-golang | 26 +++++++++++++------------- 2 files changed, 16 insertions(+), 13 deletions(-) create mode 100644 root/etc/cont-init.d/95-apt-get diff --git a/root/etc/cont-init.d/95-apt-get b/root/etc/cont-init.d/95-apt-get new file mode 100644 index 00000000..3a725eac --- /dev/null +++ b/root/etc/cont-init.d/95-apt-get @@ -0,0 +1,3 @@ +#!/usr/bin/with-contenv bash + +apt-get update \ No newline at end of file diff --git a/root/etc/cont-init.d/98-golang b/root/etc/cont-init.d/98-golang index ae6c1a3f..374b3245 100644 --- a/root/etc/cont-init.d/98-golang +++ b/root/etc/cont-init.d/98-golang @@ -2,24 +2,24 @@ echo "ensuring golang is in PATH" if grep -q -E '^(export )?PATH=' /etc/services.d/code-server/run; then - if ! grep -q -E '^(export )?PATH=.*/usr/local/go/bin.*' /etc/services.d/code-server/run; then - sed -i '/PATH/ s/$/:\/usr\/local\/go\/bin/' /etc/services.d/code-server/run - fi - if ! grep -q -E '^(export )?PATH=.*/config/go/bin:.*' /etc/services.d/code-server/run; then - sed -i 's/PATH=/PATH=\/config\/go\/bin:/g' /etc/services.d/code-server/run - fi + if ! grep -q -E '^(export )?PATH=.*/usr/local/go/bin.*' /etc/services.d/code-server/run; then + sed -i '/PATH/ s/$/:\/usr\/local\/go\/bin/' /etc/services.d/code-server/run + fi + if ! grep -q -E '^(export )?PATH=.*/config/go/bin:.*' /etc/services.d/code-server/run; then + sed -i 's/PATH=/PATH=\/config\/go\/bin:/g' /etc/services.d/code-server/run + fi else - sed -i '/^#!\/usr\/bin/a \\n# Added by codeserver-golang\nexport PATH=/config/go/bin:$PATH:/usr/local/go/bin' /etc/services.d/code-server/run + sed -i '/^#!\/usr\/bin/a \\n# Added by codeserver-golang\nexport PATH=/config/go/bin:$PATH:/usr/local/go/bin' /etc/services.d/code-server/run fi ARCH=$(uname -m) if [ -f "/golang/golang_${ARCH}.tar.gz" ]; then - echo "Installing golang" - tar xzf "/golang/golang_${ARCH}.tar.gz" -C /usr/local - rm -rf /golang + echo "Installing golang" + tar xzf "/golang/golang_${ARCH}.tar.gz" -C /usr/local + rm -rf /golang - echo "Installing gcc, to make CGO work" - apt-get update && apt-get install -y gcc + echo "Installing gcc, to make CGO work" + apt-get install -y gcc else - echo "Golang already installed, skipping" + echo "Golang already installed, skipping" fi From 3c3d4183fac380fbb809d2b7dfb6c090af46cead Mon Sep 17 00:00:00 2001 From: aptalca Date: Thu, 17 Feb 2022 09:52:55 -0500 Subject: [PATCH 16/23] update url --- .github/workflows/BuildImage.yml | 2 +- Dockerfile | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/BuildImage.yml b/.github/workflows/BuildImage.yml index 16c9df30..756f55ec 100644 --- a/.github/workflows/BuildImage.yml +++ b/.github/workflows/BuildImage.yml @@ -21,7 +21,7 @@ jobs: - name: Build image run: | # Set version - GO_WEBSITE=$(curl -sX GET https://golang.org/dl/) + GO_WEBSITE=$(curl -sLX GET https://go.dev/dl/) GO_VERSION=${{ github.event.inputs.GO_VERSION }} GO_VERSION=${GO_VERSION:-$(echo "$GO_WEBSITE" | grep -o '.*linux-amd64.*' | grep -oP '(?<=go).*(?=.linux)')} if [ $(echo "$GO_VERSION" | tr -d -c '.' | awk '{ print length; }') = "1" ]; then GO_TAG="${GO_VERSION}.0"; else GO_TAG="${GO_VERSION}"; fi diff --git a/Dockerfile b/Dockerfile index 8694a3c1..ca636a5f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/linuxserver/baseimage-alpine:3.12 as buildstage +FROM ghcr.io/linuxserver/baseimage-alpine:3.15 as buildstage ARG GO_VERSION @@ -7,18 +7,18 @@ RUN \ curl \ grep && \ if [ -z ${GO_VERSION+x} ]; then \ - GO_VERSION=$(curl -sX GET https://golang.org/dl/ | grep -o '.*linux-amd64.*' | grep -oP '(?<=go).*(?=.linux)'); \ + GO_VERSION=$(curl -sLX GET https://go.dev/dl/ | grep -o '.*linux-amd64.*' | grep -oP '(?<=go).*(?=.linux)'); \ fi && \ mkdir -p /root-layer/golang && \ curl -o \ /root-layer/golang/golang_x86_64.tar.gz -L \ - https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz && \ + https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz && \ curl -o \ /root-layer/golang/golang_armv7l.tar.gz -L \ - https://dl.google.com/go/go${GO_VERSION}.linux-armv6l.tar.gz && \ + https://go.dev/dl/go${GO_VERSION}.linux-armv6l.tar.gz && \ curl -o \ /root-layer/golang/golang_aarch64.tar.gz -L \ - https://dl.google.com/go/go${GO_VERSION}.linux-arm64.tar.gz + https://go.dev/dl/go${GO_VERSION}.linux-arm64.tar.gz COPY root/ /root-layer/ From 5aeb1615c1fc16a94cb060671460d45d6cf1235c Mon Sep 17 00:00:00 2001 From: aptalca Date: Sat, 30 Jul 2022 16:50:42 -0400 Subject: [PATCH 17/23] switch to hybrid --- Dockerfile | 6 ++--- README.md | 8 +++--- .../dependencies.d/init-mods | 0 .../run | 25 +++++++++++++++++++ .../type | 1 + .../up | 1 + .../init-mod-code-server-golang-add-package | 0 .../init-mod-code-server-golang-add-package | 0 8 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/dependencies.d/init-mods create mode 100755 root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/run create mode 100644 root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/type create mode 100644 root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/up create mode 100644 root/etc/s6-overlay/s6-rc.d/init-mods-package-install/dependencies.d/init-mod-code-server-golang-add-package create mode 100644 root/etc/s6-overlay/s6-rc.d/user/contents.d/init-mod-code-server-golang-add-package diff --git a/Dockerfile b/Dockerfile index ca636a5f..2bb4afe9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,13 +11,13 @@ RUN \ fi && \ mkdir -p /root-layer/golang && \ curl -o \ - /root-layer/golang/golang_x86_64.tar.gz -L \ + /root-layer/golang/golang_x86_64.tar.gz -fL \ https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz && \ curl -o \ - /root-layer/golang/golang_armv7l.tar.gz -L \ + /root-layer/golang/golang_armv7l.tar.gz -fL \ https://go.dev/dl/go${GO_VERSION}.linux-armv6l.tar.gz && \ curl -o \ - /root-layer/golang/golang_aarch64.tar.gz -L \ + /root-layer/golang/golang_aarch64.tar.gz -fL \ https://go.dev/dl/go${GO_VERSION}.linux-arm64.tar.gz COPY root/ /root-layer/ diff --git a/README.md b/README.md index 6074ff4a..6e9fcf26 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# Golang - Docker mod for code-server +# Golang - Docker mod for code-server and openvscode-server -This mod adds golang/go to code-server. +This mod adds golang/go to code-server and openvscode-server. -In code-server docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:code-server-golang` +In code-server or openvscode-server docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:code-server-golang` If adding multiple mods, enter them in an array separated by `|`, such as `DOCKER_MODS=linuxserver/mods:code-server-golang|linuxserver/mods:code-server-mod2` @@ -18,4 +18,4 @@ If adding multiple mods, enter them in an array separated by `|`, such as `DOCKE - `linuxserver/mods:code-server-golang` will install the latest stable release, which is `1.14.2` as of 2020/05/07 - `linuxserver/mods:code-server-golang-1.14.2` will install the specific `1.14.2` release -Visit https://hub.docker.com/r/linuxserver/mods/tags?page=1&name=code-server-golang to see all available tags \ No newline at end of file +Visit https://hub.docker.com/r/linuxserver/mods/tags?page=1&name=code-server-golang to see all available tags diff --git a/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/dependencies.d/init-mods b/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/dependencies.d/init-mods new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/run b/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/run new file mode 100755 index 00000000..b5050088 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/run @@ -0,0 +1,25 @@ +#!/usr/bin/with-contenv bash + +echo "**** ensuring golang is in PATH ****" +if grep -q -E '^(export )?PATH=' /etc/services.d/code-server/run; then + if ! grep -q -E '^(export )?PATH=.*/usr/local/go/bin.*' /etc/services.d/code-server/run; then + sed -i '/PATH/ s/$/:\/usr\/local\/go\/bin/' /etc/services.d/code-server/run + fi + if ! grep -q -E '^(export )?PATH=.*/config/go/bin:.*' /etc/services.d/code-server/run; then + sed -i 's/PATH=/PATH=\/config\/go\/bin:/g' /etc/services.d/code-server/run + fi +else + sed -i '/^#!\/usr\/bin/a \\n# Added by codeserver-golang\nexport PATH=/config/go/bin:$PATH:/usr/local/go/bin' /etc/services.d/code-server/run +fi + +ARCH=$(uname -m) +if [ -f "/golang/golang_${ARCH}.tar.gz" ]; then + echo "**** Installing golang ****" + tar xzf "/golang/golang_${ARCH}.tar.gz" -C /usr/local + rm -rf /golang + + echo "**** Adding gcc to package install list, to make CGO work ****" + echo "gcc" >> /mod-repo-packages-to-install.list +else + echo "**** Golang already installed, skipping ****" +fi diff --git a/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/type b/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/type new file mode 100644 index 00000000..3d92b15f --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/type @@ -0,0 +1 @@ +oneshot \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/up b/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/up new file mode 100644 index 00000000..91d8bfd9 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/run \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/init-mods-package-install/dependencies.d/init-mod-code-server-golang-add-package b/root/etc/s6-overlay/s6-rc.d/init-mods-package-install/dependencies.d/init-mod-code-server-golang-add-package new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-mod-code-server-golang-add-package b/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-mod-code-server-golang-add-package new file mode 100644 index 00000000..e69de29b From de35e6cb39422fa6350e2cd8ea0974810acfebdf Mon Sep 17 00:00:00 2001 From: Beariful <11493022+Beariful@users.noreply.github.com> Date: Wed, 11 Jan 2023 20:47:56 -0500 Subject: [PATCH 18/23] Update run to change Path Change /etc/services.d/code-server/run to /etc/s6-overlay/s6-rc.d/svc-code-server/run This allows the file to correctly change the path environment variable during the goland package add process. Currently when using the /etc/services.d/code-server/run path it results in an error and the path environment variable unchanged. I forked this repo, ran a build image to my own docker repo and was able to test that this change does indeed allow the file to change the environment variable correctly. --- .../init-mod-code-server-golang-add-package/run | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/run b/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/run index b5050088..af31ccc9 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/run +++ b/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/run @@ -1,15 +1,15 @@ #!/usr/bin/with-contenv bash echo "**** ensuring golang is in PATH ****" -if grep -q -E '^(export )?PATH=' /etc/services.d/code-server/run; then - if ! grep -q -E '^(export )?PATH=.*/usr/local/go/bin.*' /etc/services.d/code-server/run; then - sed -i '/PATH/ s/$/:\/usr\/local\/go\/bin/' /etc/services.d/code-server/run +if grep -q -E '^(export )?PATH=' /etc/s6-overlay/s6-rc.d/svc-code-server/run; then + if ! grep -q -E '^(export )?PATH=.*/usr/local/go/bin.*' /etc/s6-overlay/s6-rc.d/svc-code-server/run; then + sed -i '/PATH/ s/$/:\/usr\/local\/go\/bin/' /etc/s6-overlay/s6-rc.d/svc-code-server/run fi - if ! grep -q -E '^(export )?PATH=.*/config/go/bin:.*' /etc/services.d/code-server/run; then - sed -i 's/PATH=/PATH=\/config\/go\/bin:/g' /etc/services.d/code-server/run + if ! grep -q -E '^(export )?PATH=.*/config/go/bin:.*' /etc/s6-overlay/s6-rc.d/svc-code-server/run; then + sed -i 's/PATH=/PATH=\/config\/go\/bin:/g' /etc/s6-overlay/s6-rc.d/svc-code-server/run fi else - sed -i '/^#!\/usr\/bin/a \\n# Added by codeserver-golang\nexport PATH=/config/go/bin:$PATH:/usr/local/go/bin' /etc/services.d/code-server/run + sed -i '/^#!\/usr\/bin/a \\n# Added by codeserver-golang\nexport PATH=/config/go/bin:$PATH:/usr/local/go/bin' /etc/s6-overlay/s6-rc.d/svc-code-server/run fi ARCH=$(uname -m) From a4ab4f0ea6b05f3bf74de9ddf0aad939929bae1e Mon Sep 17 00:00:00 2001 From: aptalca <541623+aptalca@users.noreply.github.com> Date: Tue, 16 May 2023 22:03:02 -0400 Subject: [PATCH 19/23] code-server-golang update/add workflows --- .github/workflows/call_issue_pr_tracker.yml | 16 ++++++++++++ .github/workflows/permissions.yml | 10 ++++++++ Dockerfile | 5 ++-- root/etc/cont-init.d/95-apt-get | 3 --- root/etc/cont-init.d/98-golang | 25 ------------------- .../run | 14 ++++------- 6 files changed, 34 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/call_issue_pr_tracker.yml create mode 100644 .github/workflows/permissions.yml delete mode 100644 root/etc/cont-init.d/95-apt-get delete mode 100644 root/etc/cont-init.d/98-golang diff --git a/.github/workflows/call_issue_pr_tracker.yml b/.github/workflows/call_issue_pr_tracker.yml new file mode 100644 index 00000000..2c307843 --- /dev/null +++ b/.github/workflows/call_issue_pr_tracker.yml @@ -0,0 +1,16 @@ +name: Issue & PR Tracker + +on: + issues: + types: [opened,reopened,labeled,unlabeled,closed] + pull_request_target: + types: [opened,reopened,review_requested,review_request_removed,labeled,unlabeled,closed] + pull_request_review: + types: [submitted,edited,dismissed] + +jobs: + manage-project: + permissions: + issues: write + uses: linuxserver/github-workflows/.github/workflows/issue-pr-tracker.yml@v1 + secrets: inherit diff --git a/.github/workflows/permissions.yml b/.github/workflows/permissions.yml new file mode 100644 index 00000000..1447bc55 --- /dev/null +++ b/.github/workflows/permissions.yml @@ -0,0 +1,10 @@ +name: Permission check +on: + pull_request_target: + paths: + - '**/run' + - '**/finish' + - '**/check' +jobs: + permission_check: + uses: linuxserver/github-workflows/.github/workflows/init-svc-executable-permissions.yml@v1 diff --git a/Dockerfile b/Dockerfile index 2bb4afe9..6cd47f6b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,11 @@ -FROM ghcr.io/linuxserver/baseimage-alpine:3.15 as buildstage +# syntax=docker/dockerfile:1 + +FROM ghcr.io/linuxserver/baseimage-alpine:3.17 as buildstage ARG GO_VERSION RUN \ apk add --no-cache \ - curl \ grep && \ if [ -z ${GO_VERSION+x} ]; then \ GO_VERSION=$(curl -sLX GET https://go.dev/dl/ | grep -o '.*linux-amd64.*' | grep -oP '(?<=go).*(?=.linux)'); \ diff --git a/root/etc/cont-init.d/95-apt-get b/root/etc/cont-init.d/95-apt-get deleted file mode 100644 index 3a725eac..00000000 --- a/root/etc/cont-init.d/95-apt-get +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/with-contenv bash - -apt-get update \ No newline at end of file diff --git a/root/etc/cont-init.d/98-golang b/root/etc/cont-init.d/98-golang deleted file mode 100644 index 374b3245..00000000 --- a/root/etc/cont-init.d/98-golang +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/with-contenv bash - -echo "ensuring golang is in PATH" -if grep -q -E '^(export )?PATH=' /etc/services.d/code-server/run; then - if ! grep -q -E '^(export )?PATH=.*/usr/local/go/bin.*' /etc/services.d/code-server/run; then - sed -i '/PATH/ s/$/:\/usr\/local\/go\/bin/' /etc/services.d/code-server/run - fi - if ! grep -q -E '^(export )?PATH=.*/config/go/bin:.*' /etc/services.d/code-server/run; then - sed -i 's/PATH=/PATH=\/config\/go\/bin:/g' /etc/services.d/code-server/run - fi -else - sed -i '/^#!\/usr\/bin/a \\n# Added by codeserver-golang\nexport PATH=/config/go/bin:$PATH:/usr/local/go/bin' /etc/services.d/code-server/run -fi - -ARCH=$(uname -m) -if [ -f "/golang/golang_${ARCH}.tar.gz" ]; then - echo "Installing golang" - tar xzf "/golang/golang_${ARCH}.tar.gz" -C /usr/local - rm -rf /golang - - echo "Installing gcc, to make CGO work" - apt-get install -y gcc -else - echo "Golang already installed, skipping" -fi diff --git a/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/run b/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/run index af31ccc9..9b699311 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/run +++ b/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/run @@ -1,15 +1,11 @@ #!/usr/bin/with-contenv bash echo "**** ensuring golang is in PATH ****" -if grep -q -E '^(export )?PATH=' /etc/s6-overlay/s6-rc.d/svc-code-server/run; then - if ! grep -q -E '^(export )?PATH=.*/usr/local/go/bin.*' /etc/s6-overlay/s6-rc.d/svc-code-server/run; then - sed -i '/PATH/ s/$/:\/usr\/local\/go\/bin/' /etc/s6-overlay/s6-rc.d/svc-code-server/run - fi - if ! grep -q -E '^(export )?PATH=.*/config/go/bin:.*' /etc/s6-overlay/s6-rc.d/svc-code-server/run; then - sed -i 's/PATH=/PATH=\/config\/go\/bin:/g' /etc/s6-overlay/s6-rc.d/svc-code-server/run - fi -else - sed -i '/^#!\/usr\/bin/a \\n# Added by codeserver-golang\nexport PATH=/config/go/bin:$PATH:/usr/local/go/bin' /etc/s6-overlay/s6-rc.d/svc-code-server/run +if ! grep -q -E '.*/usr/local/go/bin.*' /var/run/s6/container_environment/PATH; then + printf ':/usr/local/go/bin' >> /var/run/s6/container_environment/PATH +fi +if ! grep -q -E '.*/config/go/bin:.*' /var/run/s6/container_environment/PATH; then + sed -i '1s|^|/config/go/bin:|' /var/run/s6/container_environment/PATH fi ARCH=$(uname -m) From b16e3fab809cbbe6c1915c3bfec936ac4c05264e Mon Sep 17 00:00:00 2001 From: aptalca <541623+aptalca@users.noreply.github.com> Date: Tue, 16 May 2023 22:14:42 -0400 Subject: [PATCH 20/23] optimize PATH --- .../s6-rc.d/init-mod-code-server-golang-add-package/run | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/run b/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/run index 9b699311..7e58b397 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/run +++ b/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/run @@ -1,10 +1,10 @@ #!/usr/bin/with-contenv bash echo "**** ensuring golang is in PATH ****" -if ! grep -q -E '.*/usr/local/go/bin.*' /var/run/s6/container_environment/PATH; then +if ! grep -q '/usr/local/go/bin' /var/run/s6/container_environment/PATH; then printf ':/usr/local/go/bin' >> /var/run/s6/container_environment/PATH fi -if ! grep -q -E '.*/config/go/bin:.*' /var/run/s6/container_environment/PATH; then +if ! grep -q '/config/go/bin' /var/run/s6/container_environment/PATH; then sed -i '1s|^|/config/go/bin:|' /var/run/s6/container_environment/PATH fi From a2ba44e5992a68c9e2fb6d85ebcea5d68c6559e8 Mon Sep 17 00:00:00 2001 From: aptalca <541623+aptalca@users.noreply.github.com> Date: Thu, 18 May 2023 16:30:43 -0400 Subject: [PATCH 21/23] update actions checkout --- .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 756f55ec..ffed9c00 100644 --- a/.github/workflows/BuildImage.yml +++ b/.github/workflows/BuildImage.yml @@ -16,7 +16,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.3.3 + - uses: actions/checkout@v3 - name: Build image run: | From 85d138c61ed383a6aef76236687e1998825b7f21 Mon Sep 17 00:00:00 2001 From: aptalca <541623+aptalca@users.noreply.github.com> Date: Thu, 18 Apr 2024 21:16:50 -0400 Subject: [PATCH 22/23] USe alpine 3.19 Signed-off-by: aptalca <541623+aptalca@users.noreply.github.com> --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6cd47f6b..8b1afe97 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1 -FROM ghcr.io/linuxserver/baseimage-alpine:3.17 as buildstage +FROM ghcr.io/linuxserver/baseimage-alpine:3.19 as buildstage ARG GO_VERSION From 7fcfb87d709120b4e13ccedc11276f72eba27db2 Mon Sep 17 00:00:00 2001 From: aptalca <541623+aptalca@users.noreply.github.com> Date: Fri, 26 Dec 2025 00:38:21 -0500 Subject: [PATCH 23/23] Update baseimage version to 3.23 Signed-off-by: aptalca <541623+aptalca@users.noreply.github.com> --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8b1afe97..1b6f289b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1 -FROM ghcr.io/linuxserver/baseimage-alpine:3.19 as buildstage +FROM ghcr.io/linuxserver/baseimage-alpine:3.23 AS buildstage ARG GO_VERSION