Skip to content

Commit 05a486b

Browse files
authored
Merge pull request #808 from totraku/code-server-rust
code-server: rust initial release
2 parents cc80a43 + baf40da commit 05a486b

File tree

23 files changed

+69
-101
lines changed

23 files changed

+69
-101
lines changed

.github/workflows/BuildImage.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ on: [push, pull_request_target, workflow_dispatch]
55
env:
66
GITHUB_REPO: "linuxserver/docker-mods" #don't modify
77
ENDPOINT: "linuxserver/mods" #don't modify
8-
BASEIMAGE: "replace_baseimage" #replace
9-
MODNAME: "replace_modname" #replace
8+
BASEIMAGE: "code-server"
9+
MODNAME: "rust"
1010

1111
jobs:
1212
set-vars:
@@ -20,7 +20,7 @@ jobs:
2020
echo "BASEIMAGE=${{ env.BASEIMAGE }}" >> $GITHUB_OUTPUT
2121
echo "MODNAME=${{ env.MODNAME }}" >> $GITHUB_OUTPUT
2222
# **** If the mod needs to be versioned, set the versioning logic below. Otherwise leave as is. ****
23-
MOD_VERSION=""
23+
MOD_VERSION=$(curl -s https://api.github.com/repos/rust-lang/rust/releases/latest | jq -r .tag_name)
2424
echo "MOD_VERSION=${MOD_VERSION}" >> $GITHUB_OUTPUT
2525
outputs:
2626
GITHUB_REPO: ${{ steps.outputs.outputs.GITHUB_REPO }}

Dockerfile

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
# syntax=docker/dockerfile:1
2+
FROM ghcr.io/linuxserver/baseimage-alpine:3.19 as buildstage
3+
4+
ARG MOD_VERSION
5+
6+
RUN if [ -z "$MOD_VERSION" ]; then \
7+
MOD_VERSION=$(curl -s https://api.github.com/repos/rust-lang/rust/releases/latest | jq -r .tag_name); \
8+
fi && \
9+
mkdir -p /root-layer/rust-bins && \
10+
SUPPORTED_PLATFORMS="x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu" && \
11+
for PLATFORM in $SUPPORTED_PLATFORMS; do \
12+
ARCH=${PLATFORM%%-*}; \
13+
RUST_BINS=/root-layer/rust-bins/rust-${ARCH}-gnu.tar.gz; \
14+
RUST_BINS_URL=https://static.rust-lang.org/dist/rust-${MOD_VERSION}-${PLATFORM}.tar.gz; \
15+
echo "Downloading rust for $PLATFORM"; \
16+
curl -o $RUST_BINS -sSf $RUST_BINS_URL; \
17+
done;
18+
19+
COPY root/ /root-layer/
220

321
FROM scratch
422

5-
LABEL maintainer="username"
23+
LABEL maintainer="totraku"
624

7-
# copy local files
8-
COPY root/ /
25+
COPY --from=buildstage /root-layer/ /

Dockerfile.complex

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

README.md

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,15 @@
1-
# Rsync - Docker mod for openssh-server
1+
# Rust - Docker mod for code-server and openvscode-server
2+
This mod adds Rust to code-server and openvscode-server.
23

3-
This mod adds rsync to openssh-server, to be installed/updated during container start.
4+
In code-server or openvscode-server docker arguments, set an environment variable DOCKER_MODS=linuxserver/mods:code-server-rust
45

5-
In openssh-server docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:openssh-server-rsync`
6+
If adding multiple mods, enter them in an array separated by |, such as DOCKER_MODS=linuxserver/mods:code-server-rust|linuxserver/mods:code-server-mod2
67

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`
8+
By default, the mod will install the latest stable version of Rust. If you'd like to install a different version, you can specify the version as a tag, from a list of published tags: https://hub.docker.com/r/linuxserver/mods/tags?page=1&name=code-server-rust
89

9-
# Mod creation instructions
10+
Supported architectures:
11+
- [x] linux/amd64
12+
- [x] linux/aarch64
1013

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-
* After all init scripts and services are created, run `find ./ -path "./.git" -prune -o \( -name "run" -o -name "finish" -o -name "check" \) -not -perm -u=x,g=x,o=x -print -exec chmod +x {} +` to fix permissions.
15-
* Edit this readme with pertinent info, delete these instructions.
16-
* Finally edit the `.github/workflows/BuildImage.yml`. Customize the vars for `BASEIMAGE` and `MODNAME`. Set the versioning logic if needed.
17-
* 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.
18-
* Submit PR against the branch created by the team.
19-
20-
21-
## Tips and tricks
22-
23-
* Some images have helpers built in, these images are currently:
24-
* [Openvscode-server](https://github.com/linuxserver/docker-openvscode-server/pull/10/files)
25-
* [Code-server](https://github.com/linuxserver/docker-code-server/pull/95)
14+
Supported docker base images:
15+
- [x] ubuntu:jammy

root/etc/s6-overlay/s6-rc.d/init-mod-imagename-modname-add-package/dependencies.d/init-mods renamed to root/etc/s6-overlay/s6-rc.d/init-mod-code-server-rust-install/dependencies.d/init-mods

File renamed without changes.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/with-contenv bash
2+
3+
set -e
4+
5+
RUST_BINS_PATH="/rust-bins"
6+
PACKAGES_TO_INSTALL_LIST="/mod-repo-packages-to-install.list"
7+
8+
ARCH=$(uname -m)
9+
SUPPORTED_ARCHS=("x86_64" "aarch64")
10+
11+
if [[ ! " ${SUPPORTED_ARCHS[@]} " =~ " ${ARCH} " ]]; then
12+
echo "**** unsupported architecture: $ARCH ****"
13+
exit 1
14+
fi
15+
16+
if ! dpkg -l | grep build-essential >/dev/null; then
17+
echo "**** adding build-essential to install list ****"
18+
echo "build-essential" >>"$PACKAGES_TO_INSTALL_LIST"
19+
else
20+
echo "**** build-essential already installed ****"
21+
fi
22+
23+
RUST_BINARY_ARCHIVE_PATH="$RUST_BINS_PATH/rust-$ARCH-gnu.tar.gz"
24+
25+
if [[ -f "$RUST_BINARY_ARCHIVE_PATH" ]]; then
26+
echo "**** unpacking rust tar ****"
27+
tar -xzf "$RUST_BINARY_ARCHIVE_PATH" -C "$RUST_BINS_PATH" --strip-components=1
28+
29+
echo "**** installing rust ****"
30+
"$RUST_BINS_PATH/install.sh"
31+
rm -rf "$RUST_BINS_PATH"
32+
else
33+
echo "**** latest rust is already installed ****"
34+
fi
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
oneshot
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/etc/s6-overlay/s6-rc.d/init-mod-code-server-rust-install/run

root/etc/s6-overlay/s6-rc.d/init-mod-imagename-modname-add-package/run

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

root/etc/s6-overlay/s6-rc.d/init-mod-imagename-modname-add-package/type

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)