-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
180 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
FROM docker.io/library/python:3.12-slim-bookworm | ||
|
||
LABEL \ | ||
maintainer="Liana64" \ | ||
org.opencontainers.image.source="https://github.com/RareCompute/containers" | ||
|
||
ARG TARGETPLATFORM | ||
ARG VERSION | ||
ARG CHANNEL | ||
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
ENV \ | ||
NVIDIA_DRIVER_CAPABILITIES="compute,video,utility,graphics" \ | ||
#PATH="/opt/venv/bin:$PATH" \ | ||
UMASK="0002" \ | ||
LANG=C.UTF-8 \ | ||
TZ="Etc/UTC" \ | ||
PYTHONDONTWRITEBYTECODE=1 \ | ||
PYTHONUNBUFFERED=1 \ | ||
PYTHONFAULTHANDLER=1 \ | ||
PIP_ROOT_USER_ACTION=ignore \ | ||
PIP_NO_CACHE_DIR=1 \ | ||
PIP_DISABLE_PIP_VERSION_CHECK=1 \ | ||
PIP_BREAK_SYSTEM_PACKAGES=1 \ | ||
UV_HTTP_TIMEOUT=1000 | ||
|
||
ENV \ | ||
USER_NAME=rare \ | ||
UID=1000 \ | ||
GID=1000 \ | ||
SUDO_ACCESS=false \ | ||
LISTEN_PORT=2222 \ | ||
PUBLIC_KEY="" | ||
|
||
USER root | ||
WORKDIR /config | ||
|
||
COPY ./apps/devserver/root/entrypoint.sh /entrypoint.sh | ||
COPY ./apps/devserver/root/config/ssh/sshd_config.template /config/ssh/sshd_config.template | ||
|
||
RUN \ | ||
apt-get update && apt-get install -y --no-install-recommends \ | ||
curl wget unzip build-essential catatonit jq lsb-release \ | ||
nano vim tree tmux git htop net-tools sudo strace \ | ||
socat rsync aria2 restic iftop iotop \ | ||
less man fzf ffmpeg ripgrep \ | ||
openssh-server pciutils \ | ||
&& mkdir -p /var/run/sshd \ | ||
&& printf "UpdateMethod=docker\nBranch=master\nPackageVersion=%s\nPackageAuthor=[RareCompute](https://github.com/RareCompute)\n" "${VERSION}" > /config/package_info \ | ||
&& chown -R ${UID}:${GID} /config && chmod -R 755 /config \ | ||
&& chmod 755 /entrypoint.sh \ | ||
&& chown -R root:root /config/ssh \ | ||
&& chmod 600 /config/ssh/sshd_config.template \ | ||
&& apt-get autoremove -y \ | ||
&& apt-get clean \ | ||
&& rm -rf /root/.cache /var/lib/apt/lists/* /tmp/* /var/tmp/* \ | ||
&& chsh -s /bin/bash | ||
|
||
EXPOSE ${LISTEN_PORT} | ||
ENTRYPOINT ["/usr/bin/catatonit", "--", "/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/goss-org/goss/master/docs/schema.yaml | ||
file: | ||
/app/LICENSE: | ||
exists: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
version="0.0.1" | ||
printf "%s" "${version}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
#yamllint disable | ||
app: devserver | ||
semver: true | ||
channels: | ||
- name: stable | ||
platforms: ["linux/amd64"] | ||
stable: true | ||
tests: | ||
enabled: false | ||
type: cli |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Port 22 | ||
Protocol 2 | ||
HostKey /config/ssh/ssh_host_rsa_key | ||
HostKey /config/ssh/ssh_host_ed25519_key | ||
|
||
UsePAM yes | ||
PermitRootLogin no | ||
PasswordAuthentication no | ||
PubkeyAuthentication yes | ||
ChallengeResponseAuthentication no | ||
ClientAliveInterval 180 | ||
ClientAliveCountMax 2 | ||
StrictModes yes | ||
HostbasedAuthentication no | ||
AllowGroups ssh | ||
PrintMotd yes | ||
PrintLastLog no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
USER_HOME="/config" | ||
AUTH_KEYS="$USER_HOME/.ssh/authorized_keys" | ||
|
||
echo ' | ||
Rare Compute Devserver | ||
───────────────────────────────────────' | ||
echo " | ||
Username: ${USER_NAME} | ||
User UID: ${UID} | ||
User GID: ${GID} | ||
Listen Port: ${LISTEN_PORT} | ||
───────────────────────────────────────" | ||
|
||
if ! getent group "${GID}" >/dev/null; then | ||
groupadd -g "${GID}" ssh | ||
fi | ||
|
||
if ! id "$USER_NAME" &> /dev/null; then | ||
useradd -u "${UID}" -g "${GID}" -d /config -s /bin/bash -m "$USER_NAME" | ||
fi | ||
|
||
if [ "${SUDO_ACCESS}" = "true" ]; then | ||
usermod -aG sudo "$USER_NAME" | ||
echo "$USER_NAME ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/$USER_NAME | ||
chmod 440 /etc/sudoers.d/$USER_NAME | ||
fi | ||
|
||
chown root:root /config/ssh | ||
chmod 700 /config/ssh | ||
|
||
if [ ! -f /config/ssh/sshd_config ]; then | ||
cp /config/ssh/sshd_config.template /config/ssh/sshd_config | ||
chown root:root /config/ssh/sshd_config | ||
chmod 600 /config/ssh/sshd_config | ||
fi | ||
|
||
if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then | ||
echo "Host keys not found, generating..." | ||
ssh-keygen -f /config/ssh/ssh_host_rsa_key -N '' -t rsa | ||
ssh-keygen -f /config/ssh/ssh_host_ed25519_key -N '' -t ed25519 | ||
chmod 600 /etc/ssh/ssh_host_*_key | ||
fi | ||
|
||
if [ ! -d "$USER_HOME/.ssh" ]; then | ||
mkdir -p "$USER_HOME/.ssh" | ||
chown -R "$UID":"$GID" "$USER_HOME/.ssh" | ||
chmod 755 "$USER_HOME" | ||
chmod 700 "$USER_HOME/.ssh" | ||
fi | ||
|
||
if [ ! -f "$AUTH_KEYS" ]; then | ||
touch "$AUTH_KEYS" | ||
chmod 600 "$AUTH_KEYS" | ||
chown "$UID":"$GID" "$AUTH_KEYS" | ||
|
||
if [ -n "$PUBLIC_KEY" ]; then | ||
echo "$PUBLIC_KEY" >> "$AUTH_KEYS" | ||
fi | ||
fi | ||
|
||
sed -i '/pam_motd.so/d' /etc/pam.d/sshd \ | ||
|
||
if [ -d /custom-cont-init.d ]; then | ||
for f in /custom-cont-init.d/*; do | ||
if [ -f "$f" ]; then | ||
echo "Running custom init script: $f" | ||
if [ -x "$f" ]; then | ||
"$f" | ||
else | ||
bash "$f" | ||
fi | ||
fi | ||
done | ||
fi | ||
|
||
exec \ | ||
/usr/sbin/sshd \ | ||
-p "$LISTEN_PORT" \ | ||
-f /config/ssh/sshd_config \ | ||
-D |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Welcome to Rare Compute |