Skip to content

Commit 260a0f0

Browse files
authored
Merge pull request #36 from linuxserver/code-server-golang-dev
code-server: golang initial release
2 parents f4cb91a + 30f904f commit 260a0f0

File tree

7 files changed

+74
-73
lines changed

7 files changed

+74
-73
lines changed

.travis.yml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ language: shell
44

55
branches:
66
only:
7-
- <baseimagename>-<modname> #replace variables, omit brackets
7+
- code-server-golang
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="golang"
1717

1818
jobs:
1919
include:
@@ -25,11 +25,26 @@ jobs:
2525
- stage: BuildImage
2626
if: (NOT (type IN (pull_request)))
2727
script:
28+
# Set version
29+
- GO_WEBSITE=$(curl -sX GET https://golang.org/dl/)
30+
- GO_VERSION=${GO_VERSION:-$(echo "$GO_WEBSITE" | grep -o '<span.*>.*linux-amd64.*</span>' | grep -oP '(?<=go).*(?=.linux)')}
31+
- if [ $(echo "$GO_VERSION" | tr -d -c '.' | awk '{ print length; }') = "1" ]; then GO_TAG="${GO_VERSION}.0"; else GO_TAG="${GO_VERSION}"; fi
32+
- GO_TAG_MINOR=$(echo "$GO_TAG" | awk 'BEGIN{FS=OFS="."} NF--')
33+
- GO_TAG_MAJOR=$(echo "$GO_TAG_MINOR" | awk 'BEGIN{FS=OFS="."} NF--')
34+
- echo "GO_TAG is $GO_TAG GO_TAG_MINOR is $GO_TAG_MINOR GO_TAG_MAJOR is $GO_TAG_MAJOR"
35+
- if [ "$GO_VERSION" == $(echo "$GO_WEBSITE" | grep -o '<span.*>.*linux-amd64.*</span>' | grep -oP '(?<=go).*(?=.linux)') ]; then LATEST="true"; fi
36+
- 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
37+
- 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
38+
- echo "LATEST is ${LATEST:-not true}, LATEST_MINOR is ${LATEST_MINOR:-not true}, LATEST_MAJOR is ${LATEST_MAJOR:-not true}"
2839
# Build image
29-
- docker build --no-cache -t ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT} .
30-
- docker tag ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT} ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}
40+
- docker build --no-cache --build-arg GO_VERSION=${GO_VERSION} -t ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${GO_TAG} .
41+
- if [ "$LATEST_MAJOR" == "true" ]; then docker tag ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${GO_TAG} ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${GO_TAG_MAJOR}; fi
42+
- if [ "$LATEST_MINOR" == "true" ]; then docker tag ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${GO_TAG} ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${GO_TAG_MINOR}; fi
43+
- if [ "$LATEST" == "true" ]; then docker tag ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${GO_TAG} ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}; fi
3144
# Login to DockerHub
3245
- echo $DOCKERPASS | docker login -u $DOCKERUSER --password-stdin
3346
# Push all of the tags
34-
- docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT}
35-
- docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}
47+
- docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${GO_TAG}
48+
- if [ "$LATEST_MAJOR" == "true" ]; then docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${GO_TAG_MAJOR}; fi
49+
- if [ "$LATEST_MINOR" == "true" ]; then docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${GO_TAG_MINOR}; fi
50+
- if [ "$LATEST" == "true" ]; then docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}; fi

Dockerfile

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
1+
FROM lsiobase/alpine:3.11 as buildstage
2+
3+
ARG GO_VERSION
4+
5+
RUN \
6+
apk add --no-cache \
7+
curl \
8+
grep && \
9+
if [ -z ${GO_VERSION+x} ]; then \
10+
GO_VERSION=$(curl -sX GET https://golang.org/dl/ | grep -o '<span.*>.*linux-amd64.*</span>' | grep -oP '(?<=go).*(?=.linux)'); \
11+
fi && \
12+
mkdir -p /root-layer/usr/local && \
13+
curl -o \
14+
/tmp/golang.tar.gz -L \
15+
https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz && \
16+
tar xzf /tmp/golang.tar.gz -C \
17+
/root-layer/usr/local
18+
19+
COPY root/ /root-layer/
20+
21+
# runtime stage
122
FROM scratch
223

3-
# copy local files
4-
COPY root/ /
24+
LABEL maintainer="n-i-x"
25+
26+
# Add files from buildstage
27+
COPY --from=buildstage /root-layer/ /

Dockerfile.complex

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

README.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
# Rsync - Docker mod for openssh-server
1+
# Golang - 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 golang/go 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-golang`
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-golang|linuxserver/mods:code-server-mod2`
88

9-
# Mod creation instructions
9+
## Available Image Tags
10+
- `code-server-golang` : installs the latest stable version
11+
- `code-server-golang-X` : installs the latest major `X` version
12+
- `code-server-golang-X.X` : installs the latest minor `X.X` version
13+
- `code-server-golang-X.X.X` : installs the specific `X.X.X` version
1014

11-
* 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.
12-
* Fork the repo, checkout the newly created branch.
13-
* Edit the `Dockerfile` for the mod. `Dockerfile.complex` is only an example and included for reference; it should be deleted when done.
14-
* Inspect the `root` folder contents. Edit, add and remove as necessary.
15-
* Edit this readme with pertinent info, delete these instructions.
16-
* Finally edit the `travis.yml`. Customize the build branch, and the vars for `BASEIMAGE` and `MODNAME`.
17-
* Submit PR against the branch created by the team.
15+
### Examples
16+
- `linuxserver/mods:code-server-golang-1.13` will install the latest `1.13` release, which is `1.13.10` as of 2020/05/07
17+
- `linuxserver/mods:code-server-golang-1` will install the latest `1` release, which is `1.14.2` as of 2020/05/07
18+
- `linuxserver/mods:code-server-golang` will install the latest stable release, which is `1.14.2` as of 2020/05/07
19+
- `linuxserver/mods:code-server-golang-1.14.2` will install the specific `1.14.2` release
20+
21+
Visit https://hub.docker.com/r/linuxserver/mods/tags?page=1&name=code-server-golang to see all available tags

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/with-contenv bash
2+
3+
echo "ensuring golang is in PATH"
4+
if grep -q '^PATH=' /etc/services.d/code-server/run; then
5+
if ! grep -q '^PATH=.*/usr/local/go/bin.*' /etc/services.d/code-server/run; then
6+
sed -i '/PATH/ s/$/:\/usr\/local\/go\/bin/' /etc/services.d/code-server/run
7+
fi
8+
else
9+
sed -i '/^#!\/usr\/bin/a \\n# Added by codeserver-golang\nexport PATH=$PATH:/usr/local/go/bin' /etc/services.d/code-server/run
10+
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)