mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
feat: connect terminal service to backend
feat: put terminal service into container refactor: separate main into terminal and websocket feat: create zsh using commander in home feat: pass backendUrl to container feat: pass token to ws server to cmd-hook feat: gen terminal access token for frontend feat: success to connect through traefik fix: handle invalid jwt feat: connect to session container via traefik
This commit is contained in:
1 parent
0b08a9a5d9
commit
5e81db2759
20 files changed
+281
-209
No files matched your search
@@ -29,7 +29,7 @@ precmd() {
|
||||
export CMD_ERROR_FILE=/tmp/cmd.error
|
||||
|
||||
# Now run your Node.js script with the result as an argument
|
||||
/usr/local/bin/cmd-hook; rm /tmp/cmd.out /tmp/cmd.error 2>/dev/null
|
||||
/usr/local/lib/cmd-hook/cmd-hook; rm /tmp/cmd.out /tmp/cmd.error 2>/dev/null
|
||||
|
||||
# Reset variables
|
||||
unset CMD_START_TIME
|
||||
|
||||
+13
-13
@@ -1,15 +1,18 @@
|
||||
FROM golang:1.24-alpine as builder
|
||||
|
||||
FROM golang:1.24-alpine as cmd-hook-builder
|
||||
WORKDIR /app
|
||||
|
||||
COPY ./services/cmd-hook/go.mod ./
|
||||
|
||||
RUN go mod download
|
||||
|
||||
COPY ./services/cmd-hook ./
|
||||
|
||||
RUN go build -o cmd-hook
|
||||
|
||||
FROM golang:1.24-alpine as terminal-builder
|
||||
WORKDIR /app
|
||||
COPY ./services/terminal-service/go.mod ./
|
||||
COPY ./services/terminal-service/go.sum ./
|
||||
RUN go mod download
|
||||
COPY ./services/terminal-service ./
|
||||
RUN go build -o terminal-service
|
||||
|
||||
FROM debian:bookworm-slim as main
|
||||
|
||||
LABEL maintainer="wancat@wancat.cc"
|
||||
@@ -18,16 +21,13 @@ RUN apt-get update && apt-get install -y \
|
||||
vim \
|
||||
zsh \
|
||||
curl \
|
||||
openssh-server
|
||||
|
||||
COPY --from=builder /app/cmd-hook /usr/local/bin/cmd-hook
|
||||
sudo
|
||||
COPY ./quests/.includes/zshrc /etc/zsh/zshrc
|
||||
RUN rm -f /etc/motd /etc/issue /etc/issue.net /etc/update-motd.d/*
|
||||
RUN rm -rf /etc/skel && mkdir -p /etc/skel
|
||||
RUN mkdir -p /etc/ssh/authorized_keys && chmod 755 /etc/ssh/authorized_keys
|
||||
COPY ./quests/.includes/sshd_config /etc/ssh/sshd_config
|
||||
COPY ./quests/entrypoint.sh /entrypoint.sh
|
||||
COPY --from=cmd-hook-builder /app/cmd-hook /usr/local/lib/cmd-hook/cmd-hook
|
||||
COPY --from=terminal-builder /app/terminal-service /usr/local/lib/terminal-service/terminal-service
|
||||
|
||||
EXPOSE 22
|
||||
EXPOSE 9090
|
||||
|
||||
ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]
|
||||
@@ -3,19 +3,16 @@
|
||||
USERNAME=commander
|
||||
|
||||
echo "Initializing container for $USERNAME"
|
||||
echo "BACKEND_URL: $BACKEND_URL"
|
||||
|
||||
if ! id -u ${USERNAME} >/dev/null 2>&1; then
|
||||
echo "Adding user $USERNAME"
|
||||
adduser --disabled-password --gecos '' --shell /bin/zsh ${USERNAME} && \
|
||||
find / -name ".gitkeep" -type f -exec rm -f {} +
|
||||
|
||||
echo "Adding public key for $USERNAME"
|
||||
echo "Public key: $PUB_KEY"
|
||||
PUB_KEY_PATH=/etc/ssh/authorized_keys/${USERNAME}
|
||||
echo $PUB_KEY > ${PUB_KEY_PATH}
|
||||
chmod 644 ${PUB_KEY_PATH}
|
||||
fi
|
||||
|
||||
mkdir -p /run/sshd
|
||||
echo "Starting SSH server"
|
||||
/usr/sbin/sshd -D -e
|
||||
# Preserve environment variables
|
||||
export BACKEND_URL
|
||||
|
||||
echo "Starting terminal service"
|
||||
su - ${USERNAME} -w BACKEND_URL -c "/usr/local/lib/terminal-service/terminal-service"
|
||||
Reference in new issue
Block a user