Update.
This commit is contained in:
parent
1b2ad3965b
commit
5f06d7e04c
@ -10,3 +10,9 @@ RUN chmod +x r
|
|||||||
|
|
||||||
RUN mv r /usr/local/bin/r
|
RUN mv r /usr/local/bin/r
|
||||||
|
|
||||||
|
RUN echo 'root:root' | chpasswd
|
||||||
|
|
||||||
|
COPY ./terminal /opt/bootstrap
|
||||||
|
COPY ./terminal /opt/snek
|
||||||
|
RUN cp -r ./root /opt/bootrap/root
|
||||||
|
COPY ./terminal/entry /usr/local/bin/entry
|
||||||
|
@ -84,7 +84,7 @@ class ContainerService(BaseService):
|
|||||||
"./"
|
"./"
|
||||||
+ str(await self.services.channel.get_home_folder(channel_uid))
|
+ str(await self.services.channel.get_home_folder(channel_uid))
|
||||||
+ ":"
|
+ ":"
|
||||||
+ "/home/ubuntu"
|
+ "/root"
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
return await self.compose.get_instance(name)
|
return await self.compose.get_instance(name)
|
||||||
|
@ -66,7 +66,9 @@ class ComposeFileManager:
|
|||||||
"context": ".",
|
"context": ".",
|
||||||
"dockerfile": "DockerfileUbuntu",
|
"dockerfile": "DockerfileUbuntu",
|
||||||
},
|
},
|
||||||
"user":"ubuntu"
|
"user":"root",
|
||||||
|
"working_dir": "/home/retoor/projects/snek",
|
||||||
|
"environment": [f"SNEK_UID={name}"],
|
||||||
}
|
}
|
||||||
service["command"] = command or "tail -f /dev/null"
|
service["command"] = command or "tail -f /dev/null"
|
||||||
if cpus or memory:
|
if cpus or memory:
|
||||||
@ -165,14 +167,13 @@ class ComposeFileManager:
|
|||||||
stdout = b''
|
stdout = b''
|
||||||
stderr = str(ex).encode()
|
stderr = str(ex).encode()
|
||||||
await self.event_handler(name,"stdout",stdout or stderr)
|
await self.event_handler(name,"stdout",stdout or stderr)
|
||||||
if proc.returncode != 0:
|
print("Return code", proc.returncode)
|
||||||
raise RuntimeError(f"Failed to stop {name}: {stderr.decode()}")
|
|
||||||
if stdout:
|
if stdout:
|
||||||
await self.event_handler(name,"stdout",stdout)
|
await self.event_handler(name,"stdout",stdout or b'')
|
||||||
return stdout.decode(errors="ignore")
|
return stdout and stdout.decode(errors="ignore") or ""
|
||||||
|
|
||||||
await self.event_handler(name,"stdout",stderr)
|
await self.event_handler(name,"stdout",stderr or b'')
|
||||||
return stderr.decode(errors="ignore")
|
return stderr and stderr.decode(errors="ignore") or ""
|
||||||
|
|
||||||
async def start(self, name):
|
async def start(self, name):
|
||||||
"""Asynchronously start a container by doing 'docker compose up -d [name]'."""
|
"""Asynchronously start a container by doing 'docker compose up -d [name]'."""
|
||||||
@ -187,15 +188,27 @@ class ComposeFileManager:
|
|||||||
|
|
||||||
proc = await asyncio.create_subprocess_exec(
|
proc = await asyncio.create_subprocess_exec(
|
||||||
"docker", "compose", "-f", self.compose_path, "up", name, "-d",
|
"docker", "compose", "-f", self.compose_path, "up", name, "-d",
|
||||||
|
stdout=asyncio.subprocess.PIPE,
|
||||||
|
stderr=asyncio.subprocess.PIPE,
|
||||||
stdin=asyncio.subprocess.PIPE,
|
stdin=asyncio.subprocess.PIPE,
|
||||||
)
|
)
|
||||||
stdout,stderr = await proc.communicate()
|
stdout, stderr = None, None
|
||||||
if proc.returncode != 0:
|
while proc.returncode is None:
|
||||||
print(f"Failed to start {name}: {stderr.decode(errors='ignore')}")
|
try:
|
||||||
return False
|
stdout, stderr = await proc.communicate()
|
||||||
|
except Exception as ex:
|
||||||
|
stdout = b''
|
||||||
|
stderr = str(ex).encode()
|
||||||
|
if stdout:
|
||||||
|
print(stdout.decode(errors="ignore"))
|
||||||
|
if stderr:
|
||||||
|
print(stderr.decode(errors="ignore"))
|
||||||
|
await self.event_handler(name,"stdout",stdout or stderr)
|
||||||
|
print("Return code", proc.returncode)
|
||||||
|
|
||||||
master, slave = pty.openpty()
|
master, slave = pty.openpty()
|
||||||
proc = await asyncio.create_subprocess_exec(
|
proc = await asyncio.create_subprocess_exec(
|
||||||
"docker", "compose", "-f", self.compose_path, "exec", name, "/bin/bash",
|
"docker", "compose", "-f", self.compose_path, "exec", name, "/usr/local/bin/entry",
|
||||||
stdin=slave,
|
stdin=slave,
|
||||||
stdout=slave,
|
stdout=slave,
|
||||||
stderr=slave,
|
stderr=slave,
|
||||||
|
47
terminal/.welcome.txt
Normal file
47
terminal/.welcome.txt
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
π Welcome to your custom Ubuntu development environment!
|
||||||
|
|
||||||
|
This container is pre-configured with a rich set of tools to help you hit the ground running:
|
||||||
|
|
||||||
|
π§ Development Libraries & Tools:
|
||||||
|
|
||||||
|
Full support for building and debugging C/C++ and Python code
|
||||||
|
|
||||||
|
Libraries for SSL, readline, SQLite, zlib, bz2, ffi, lzma, and JSON-C
|
||||||
|
|
||||||
|
Valgrind for memory debugging and profiling
|
||||||
|
|
||||||
|
π Python:
|
||||||
|
|
||||||
|
Python 3 with pip and virtual environment support (venv)
|
||||||
|
|
||||||
|
π¦ Rust:
|
||||||
|
|
||||||
|
Rust installed with the nightly toolchain via rustup
|
||||||
|
|
||||||
|
π Command-line Essentials:
|
||||||
|
|
||||||
|
vim, tmux, htop, git, curl, wget, xterm, ack, and more
|
||||||
|
|
||||||
|
π¬ Networking & Communication:
|
||||||
|
|
||||||
|
irssi for IRC and lynx for browsing from the terminal
|
||||||
|
|
||||||
|
π¦ Custom Tool Installed:
|
||||||
|
|
||||||
|
Latest version of AI vibe coding tool r is installed from the
|
||||||
|
retoor.molodetz.nl repository.
|
||||||
|
|
||||||
|
To get started, open a new terminal and type "r" to launch the tool.
|
||||||
|
|
||||||
|
Configure ~/.rcontext.txt to describe it's behavior. It can be a friend
|
||||||
|
or a whatever you like.
|
||||||
|
|
||||||
|
π Credentials:
|
||||||
|
|
||||||
|
Default root password is set to: root (please change it if needed)
|
||||||
|
|
||||||
|
π Custom Terminal Files:
|
||||||
|
|
||||||
|
Files from ./terminal/ have been copied to your home directory (/root/)
|
||||||
|
|
||||||
|
Enjoy hacking in your personalized command-line workspace!
|
26
terminal/entry
Executable file
26
terminal/entry
Executable file
@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import pathlib
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
os.chdir("/root")
|
||||||
|
|
||||||
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
||||||
|
sys.path.insert(0, "/root/bin")
|
||||||
|
sys.path.insert(0, "/root/bin/local/bin")
|
||||||
|
|
||||||
|
if not pathlib.Path(".welcome.txt").exists():
|
||||||
|
os.system("python3 -m venv --prompt '' .venv")
|
||||||
|
os.system("cp -r /opt/bootstrap/root/.* /root")
|
||||||
|
os.system("cp /opt/bootstrap/.welcome.txt /root/.welcome.txt")
|
||||||
|
pathlib.Path(".bashrc").write_text(pathlib.Path(".bashrc").read_text() + "\n" + "source .venv/bin/activate")
|
||||||
|
os.environ["SNEK"] = "1"
|
||||||
|
|
||||||
|
if pathlib.Path(".welcome.txt").exists():
|
||||||
|
with open(".welcome.txt") as f:
|
||||||
|
print(f.read())
|
||||||
|
|
||||||
|
os.system("bash")
|
Loadingβ¦
Reference in New Issue
Block a user