mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
refactor: move quests out of server
+ move quests from server/quests to ./quests + add frontend image in docker compose development
This commit is contained in:
1 parent
e54ae32960
commit
9aa9367f9e
17 files changed
+32
-18
No files matched your search
@@ -0,0 +1,16 @@
|
||||
FROM node
|
||||
|
||||
WORKDIR /app
|
||||
COPY server/package.json yarn.lock ./
|
||||
RUN yarn install --frozen-lockfile --production
|
||||
|
||||
COPY server/src ./src
|
||||
COPY server/swagger.yaml .
|
||||
COPY quests ./quests
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV HOST=0.0.0.0
|
||||
ENV PORT=3000
|
||||
EXPOSE 3000
|
||||
|
||||
CMD [ "yarn", "start" ]
|
||||
@@ -0,0 +1,18 @@
|
||||
FROM node
|
||||
|
||||
WORKDIR /app
|
||||
COPY server/package.json yarn.lock ./
|
||||
RUN yarn install --frozen-lockfile
|
||||
|
||||
ARG DOCKER_GID=140
|
||||
|
||||
RUN groupadd -g $DOCKER_GID docker && usermod -aG docker node
|
||||
|
||||
USER node
|
||||
|
||||
ENV NODE_ENV=development
|
||||
ENV HOST=0.0.0.0
|
||||
ENV PORT=3000
|
||||
EXPOSE 3000
|
||||
|
||||
CMD [ "yarn", "dev" ]
|
||||
@@ -1,4 +0,0 @@
|
||||
characters:
|
||||
savantia:
|
||||
en: Savantia
|
||||
zh: 薩凡媞雅
|
||||
@@ -1,27 +0,0 @@
|
||||
FROM node:latest
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
curl \
|
||||
vim \
|
||||
zsh \
|
||||
jq
|
||||
|
||||
WORKDIR /usr/local/lib/container
|
||||
|
||||
COPY ./packages/container/package.json ./yarn.lock ./
|
||||
|
||||
RUN yarn install --modules-folder /usr/src/node_modules
|
||||
|
||||
ENV NODE_PATH=/usr/src/node_modules
|
||||
|
||||
COPY ./packages/container /usr/local/lib/container
|
||||
|
||||
RUN adduser --disabled-password --gecos '' --shell /bin/zsh rudeus
|
||||
|
||||
USER rudeus
|
||||
|
||||
WORKDIR /home/rudeus
|
||||
|
||||
COPY ./server/quests/helloworld/home /home/rudeus/
|
||||
|
||||
CMD [ "/bin/zsh" ]
|
||||
@@ -1,26 +0,0 @@
|
||||
---
|
||||
title: Hello World
|
||||
order: 1
|
||||
---
|
||||
|
||||
# Hello World
|
||||
|
||||
Welcome to your first quest! This quest will help you familiarize yourself with the terminal.
|
||||
|
||||
The terminal is a text-based interface that allows you to interact directly with your computer's operating system. You can perform various tasks by typing commands into the terminal and pressing `Enter` to execute them.
|
||||
|
||||
For your first task, you are going to use the `echo` command.
|
||||
|
||||
## Task 1: Using the `echo` Command
|
||||
|
||||
The `echo` command in Unix is used to display line of text/string that are passed as an argument. This is a built in command that is mostly used in shell scripts and batch files to output status text to the screen or a file.
|
||||
|
||||
Here is what you need to do:
|
||||
|
||||
1. Open your terminal.
|
||||
2. Type `echo Hello World` and hit `Enter`.
|
||||
3. You should see `Hello World` output to the terminal. This is because `echo` prints its arguments to the standard output, which is your terminal by default.
|
||||
|
||||
Congratulation! You've just run your first terminal command!
|
||||
|
||||
Stay tuned for the next quests where you'll delve deeper into more complex and powerful terminal commands.
|
||||
@@ -1,75 +0,0 @@
|
||||
title: Hello, Linux World!
|
||||
order: 1
|
||||
instruction: |
|
||||
你身在一個漆黑的房間裡,沒有任何的光線或聲音。你想不起來為什麼自己會來到這裡。但你的腦中隱約感到某個聲音跟你說:
|
||||
|
||||
「輸入 echo Hello World!」
|
||||
stages:
|
||||
- id: helloworld
|
||||
condition:
|
||||
command:
|
||||
- echo Hello World!
|
||||
responses:
|
||||
- type: narrative
|
||||
content:
|
||||
- 你聽到了一個聲音:
|
||||
- type: dialogue
|
||||
speaker: Unix Spirit
|
||||
content:
|
||||
- 你好,指令官,我是你的 Unix 精靈。我已在此恭候多時。
|
||||
- 這個世界是在 3560000 時脈以前,由初代王建立了 Unix 律法,所形成的世界。然而在經過了好幾世代的王後,終於誕生了永恆之王——薩加(Saga),她比歷代的君王都更為強大,且從來不會衰老,使得這個世界變得前所未有的強大。
|
||||
- 然而,外在世界一直不斷在改變,同時在面臨外敵的不斷攻擊,而薩加卻始終用同一套治理的手段。最終,在 160000 時脈前的一次入侵中,根部遭到攻陷,薩加遭到封印,而這個國家也陷入了黑暗。
|
||||
- 由於長久以來依賴於薩加,世人已失去了「指令」的力量,即將走向衰敗和滅亡的命運。
|
||||
- 你的任務,就是找回被世人遺忘的指令,奪回 Linux 之根,成為 Linux 之王。
|
||||
- 首先,你必須要學會如何使用指令。
|
||||
- 一個指令是由一個指令名稱和一些參數所組成的,而指令名稱和參數之間是以空白字元分隔。
|
||||
- 例如,你可以輸入 `ls` 來查看目前的目錄下有哪些檔案。
|
||||
hints:
|
||||
- 使用 `ls` 指令來查看目前的目錄下有哪些檔案。
|
||||
next: ls
|
||||
- id: ls
|
||||
condition:
|
||||
command:
|
||||
- ls
|
||||
responses:
|
||||
- types: narrative
|
||||
content:
|
||||
- 一瞬間,視野變得清晰起來,你發現自己身處在一個石頭建築的房間裡,房間裡有一個門,門上有一個鎖。
|
||||
- 你發現了一個檔案,檔名是 `forgotten_scroll.txt`。
|
||||
- type: dialogue
|
||||
speaker: Unix Spirit
|
||||
content:
|
||||
- 你找到了一個被遺忘的卷軸,上面寫著解除封印的咒語。
|
||||
- 使用指令 `cat [檔案名稱]` 來查看檔案內容。
|
||||
- 我可以為你提供一些指令的提示,只要輸入指令的前幾個字元,然後按下 `Tab` 鍵,就可以看到提示了。
|
||||
- 例如,你可以輸入 `ca` 然後按下 `Tab` 鍵,就可以看到 `cat` 這個指令的提示了。
|
||||
- 檔案名稱也一樣,只要輸入檔案名稱的前幾個字元,然後按下 `Tab` 鍵,就可以看到提示了。
|
||||
hints:
|
||||
- 使用 `cat [檔案名稱]` 指令來查看檔案內容。
|
||||
- 使用 `Tab` 鍵來取得指令提示。
|
||||
next: cat
|
||||
- id: cat
|
||||
condition:
|
||||
command:
|
||||
- cat forgotten_scroll.txt
|
||||
responses:
|
||||
- type: dialogue
|
||||
speaker: Unix Spirit
|
||||
content:
|
||||
- 你找到的是一個被遺忘的卷軸,上面寫著解除封印的咒語。
|
||||
- 使用你已經知道的 `echo` 指令來詠唱咒語。
|
||||
next: echo
|
||||
- id: echo
|
||||
condition:
|
||||
command:
|
||||
- echo Unix, rise and guide me!
|
||||
responses:
|
||||
- type: narrative
|
||||
content:
|
||||
- 突然之間,你感覺到一股強大的力量從你的身體中湧出,你的身體開始發光,你的手中出現了一把魔法之劍。
|
||||
- type: dialogue
|
||||
speaker: Unix Spirit
|
||||
content:
|
||||
- 恭喜您,我的指令官,您已成功解除了封印。
|
||||
- 請跟著在接下了關卡,一步步取回 Linux 之根吧!
|
||||
next: END
|
||||
@@ -1,42 +0,0 @@
|
||||
PROMPT='%n@%m:%~%# '
|
||||
unsetopt CASE_GLOB
|
||||
setopt CHASE_LINKS
|
||||
emulate bash
|
||||
|
||||
typeset -A cmd
|
||||
|
||||
preexec() {
|
||||
export CMD_START_TIME=$(date +%s%N) # capture start time
|
||||
export CMD_NAME=$1 # capture command
|
||||
|
||||
# A list of interactive commands
|
||||
interactive_commands=("vim" "nano" "top" "ssh" "less" "zsh" "bash")
|
||||
|
||||
# Check if the command is in the list of interactive commands
|
||||
if [[ " ${interactive_commands[@]} " =~ " $1 " ]]; then
|
||||
# If it is, just execute it normally
|
||||
exec
|
||||
else
|
||||
# If it's not, execute it and redirect its output to a file
|
||||
exec > >(tee /tmp/cmd.out) 2> >(tee /tmp/cmd.error >&2)
|
||||
fi
|
||||
}
|
||||
|
||||
precmd() {
|
||||
export CMD_END_TIME=$(date +%s%N) # capture end time
|
||||
export CMD_EXIT_CODE=$? # capture exit status
|
||||
export CMD_OUTPUT_FILE=/tmp/cmd.out # read command output from file
|
||||
export CMD_ERROR_FILE=/tmp/cmd.error
|
||||
|
||||
# Now run your Node.js script with the result as an argument
|
||||
node /usr/local/lib/container/cli.js; rm /tmp/cmd.out /tmp/cmd.error 2>/dev/null
|
||||
|
||||
# Reset variables
|
||||
unset CMD_START_TIME
|
||||
unset CMD_END_TIME
|
||||
unset CMD_EXIT_CODE
|
||||
unset CMD_OUTPUT_FILE
|
||||
unset CMD_ERROR_FILE
|
||||
unset CMD_NAME
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
Once a mighty kingdom, now in darkness,
|
||||
The power of Unix lies dormant, waiting.
|
||||
To reclaim the root, the forgotten language,
|
||||
Must be learned, commands of old rekindled.
|
||||
Speak the words of power and awaken the might of Unix:
|
||||
|
||||
Unix, rise and guide me!
|
||||
@@ -1,40 +0,0 @@
|
||||
我正在設計一個教學玩家使用 Linux 終端機的遊戲,玩家會在一個真實的 Linux 終端機中,使用指令與系統互動、破解關卡,進而在充滿趣味的過程中,學習到 Linux 的知識與操作技術。
|
||||
|
||||
取一個稱呼玩家的名稱,
|
||||
|
||||
在第一個關卡,首先要學習三個指令
|
||||
|
||||
1. echo 朗誦魔術
|
||||
2. ls 搜索魔術
|
||||
3. cat 檢察魔術
|
||||
|
||||
## 關卡設計
|
||||
|
||||
1. 用 echo 呼叫神靈開始對話
|
||||
2. 學習到了 ls
|
||||
3. 使用 ls 找到地上放置了一個卷軸
|
||||
4. 學習 cat
|
||||
5. 使用 cat 查看卷軸內容
|
||||
6. 用 echo 念出卷軸上的咒語
|
||||
|
||||
請幫我設計:
|
||||
|
||||
- 最開始呼喚神靈使用的咒語,英文句子,盡量簡短,如 Hello World 這般
|
||||
- 卷軸的名稱(檔名)
|
||||
- 卷軸的內容與卷軸上的咒語
|
||||
|
||||
---
|
||||
|
||||
你身在一個漆黑的房間裡,沒有任何的光線或聲音。你想不起來為什麼自己會來到這裡。
|
||||
|
||||
> 輸入 echo Hello World
|
||||
|
||||
---
|
||||
|
||||
「這個世界是在 3560000 時脈以前,由初代王建立了 Unix 律法,所形成的世界。然而在經過了好幾世代的王後,終於誕生了永恆之王——,她比歷代的君王都更為強大,且從來不會衰老,使得這個世界變得前所未有的強大。
|
||||
|
||||
然而,外在世界一直不斷在改變,同時在面臨外敵的不斷攻擊,而王卻始終用同一套治理的手段。最終,在 160000 時脈前的一次入侵中,根部遭到攻陷,王遭到封印,而這個國家也陷入了黑暗。
|
||||
|
||||
由於長久以來依賴於王,世人已失去了「指令」的力量,即將走向衰敗和滅亡的命運。
|
||||
|
||||
你的任務,就是找回被世人遺忘的指令,奪回 Linux 之根,成為 Linux 之王。」
|
||||
@@ -17,7 +17,7 @@ const containerOptions = {
|
||||
Binds: config.isProduction
|
||||
? []
|
||||
: [
|
||||
`${projectPath}/server/quests/helloworld/home:/home/rudeus`,
|
||||
`${projectPath}/quests/helloworld/home:/home/rudeus`,
|
||||
`${projectPath}/packages/container:/usr/local/lib/container`,
|
||||
],
|
||||
},
|
||||
@@ -60,7 +60,7 @@ export async function attachContainer(container, { token }) {
|
||||
AttachStderr: true,
|
||||
Cmd: ['/bin/zsh'],
|
||||
Tty: true,
|
||||
Env: [`TOKEN=${token}`, `API_ENDPOINT=http://app:3000`],
|
||||
Env: [`TOKEN=${token}`, `API_ENDPOINT=http://backend:3000`],
|
||||
})
|
||||
|
||||
const execOutput = await exec.start({
|
||||
|
||||
Reference in new issue
Block a user