上个月在 YouTube 上搜索,发现了一个免费容器 Uppcoder,有一个 Stack 的免费容器,而且给的配置很是大方。

官网声明免费档 Spark 价格:€0/月,永久免费,状态 Active:

  • 1 个 Stack:1 个常驻应用栈,含 1 个数据库
  • 2GB 内存、2GB 磁盘(每个 Stack)
  • 每天 500 CPU 秒(每个 Stack),即 CPU 100% 运行 1 秒算一次,大多数都不会出现 100% CPU 的情况
  • 常驻在线不休眠:面板和定价页都写的是 “1 always-on stack”,没出现休眠提示
  • 浏览器内编辑器、终端、SSH:免费档也含
  • 自动 TLS 证书:部署的应用自带 HTTPS,但免费档不能自定义域名,得使用他给的域名
  • 每晚备份:免费档也含,每个应用的文件和数据库每天备份到另一台服务器,保留最近 7 天每天一份、最近 4 周每周一份

免费档的用度情况

应 Uppcoder 官方补充说明条款: 服务条款 7.1 中明确有说明不能在上面开隧道、代理。VPN 和隧道在 Uppcoder 上是不允许的,否则这类应用会被自动停掉、账户会被关闭。

Uppcoder 服务条款中关于隧道和代理的说明Uppcoder 服务条款中关于隧道和代理的说明

免费档的用度情况:

Uppcoder 免费档的用度情况Uppcoder 免费档的用度情况

免费档本身不花钱,也不会自动扣费。注册、邮箱验证、来回部署和删除 Stack 全免费,也没有出现要绑卡啥的操作,所以暂时可以放心。不过这个平台很新,2026 年 10 月中才上线的,能否稳定,还待验证。

Node 应用部署实战

我是来回折腾了很久,才成功将 Node 项目给部署上,并实现前端访问的。坑的是这个网站的说明文档真的很少,全靠自己摸索。下面说一下全过程,全程避免大家踩坑(坑我都帮大家踩完了)。

1、注册

这一步我就不多说了。注册地址:https://portal.uppcoder.com/

建议使用 GitHub 直接来就好,免得使用邮箱注册后,还要再关联 GitHub,还不如一步到位。

2、创建一个 Stack

第 1 个 Stack 是免费的,后续再想多创建的话就是收费的了。

在这里可以选择支持 Node 的 Next.js 和 Express,当然你也可以选择 Jam.py 这种支持 Python 的,主要看你自己了。我的项目只是基本的 Express 的,所以我就选择了 Express + SQLite 这项。

创建 Stack 时选择 Express + SQLite创建 Stack 时选择 Express + SQLite

3、配置 Stack

配置 Stack,按图片来即可。有一点需要说明,我上面选择的是 Express + SQLite 这项,所以默认就有一个 Express 组件要配置,SQLite 是可选择的配置项,如果有需要可以从右侧选择对应的数据库项,右侧所有高亮的都是可选择的数据库,不要被 SQLite 这个词影响了,它甚至可以选择 MySQL、PGSQL 这种组成数据库,要选择哪个主要看你项目集成的是哪个数据库。我这个项目使用的是 Node 默认集成的 SQLite,所以就不选择数据库的插件了。

我部署的项目地址,大家可以参考一下(欢迎点 Start 和 Fork): hakd-code/gallery - GitHub

Stack 配置界面Stack 配置界面

4、Deploy 部署后踩坑:502

点击右上的 Deploy 完成部署,等待一下就可以完成了。完成后会收到邮件。下图是部署成功后的情况。

部署成功后的面板部署成功后的面板

这个时候,你点击访问网站,发现前端返回的是 nginx 的 502,说白了就是不通。我就是在这里自己摸索了好久,查了不少文档,问了 AI 不少问题才搞通的。

访问应用返回 nginx 502访问应用返回 nginx 502

5、进入 WebSSH,找到启动入口

从上图中,进入 ssh 网页版本。在这里可以直接 ssh 操作整个 Stack 容器。

进入 WebSSH 终端进入 WebSSH 终端

我发现在这里按 npm start 项目也是无法访问到前端的。直到我意外翻到了日志目录,看了所有日志输出才找到了基本的入口。这个 Stack 启动时,找的文件是 index.js 文件,并且监听了 8000 端口。

日志中找到的启动入口信息日志中找到的启动入口信息

再继续找,发现了 /opt/start-scripts/start-express.sh 这个容器启动时的主要文件。仔细读了源码,发现这个启动脚本的逻辑非常清晰,而且平台本身专门预留了自定义启动钩子!

从 start-express.sh 的源码可以看出两个核心机制:

  • 自定义入口优先级最高:脚本第 38-41 行写明,只要 /home/uppcoder/app/startup-app.sh 存在,它就会直接跳过后面的 node --watch index.js,转而执行你的 startup-app.sh。
  • 端口环境变量是 APP_PORT:即平台默认期望你的应用监听在 ${APP_PORT:-8000}(即 8000 端口),而我的 server.js 读取的是 process.env.PORT,写的端口是 3100。

<details> <summary>start-express.sh 脚本内容,有兴趣可以看一下</summary>

bash
#!/bin/bash
# =============================================================================
# Start Express.
#
# Express is a BACKEND: it has no /api proxy to generate, it is the thing other
# tiers proxy AT. What it needs from service discovery is the other direction --
# the database it was composed with.
#
# Nothing can pre-install a database client, because a combination expressed as
# a template row does not know its database until it is provisioned and the
# platform offers 21 of them. So the connection string's SCHEME decides, and
# the client is installed on first start and written into package.json.
# =============================================================================
set -eo pipefail

APP_DIR="${APP_DIR:-/home/uppcoder/app}"

_START_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=lib-service-discovery.sh
. "$_START_DIR/lib-service-discovery.sh"

main() {
    cd "$APP_DIR"

    if ! command -v npm >/dev/null 2>&1; then
        echo "ERROR: npm not found. No Node.js environment available." >&2
        ls -1 /opt/pixi/.pixi/envs/ 2>/dev/null >&2 || true
        exit 1
    fi

    if [ ! -d node_modules ]; then
        echo "Running npm install..."
        npm install
    fi

    ensure_node_db_client

    if [ -f "$APP_DIR/startup-app.sh" ]; then
        echo "Running user startup command..."
        exec bash "$APP_DIR/startup-app.sh"
    fi

    # 🚨 --watch, because an agent's edit has to take effect without anybody
    # knowing to restart anything.
    #
    # This was `exec node index.js`, which made Express the ONLY framework here
    # that does not reload: every sibling runs a dev server that does (npm run
    # dev for vite/next/nuxt/astro/svelte/preact/react/vue, npm run start:dev
    # for nest, uvicorn --reload for fastapi).
    #
    # Measured 2026-09-11 on a builder project: the agent wrote correct routes
    # at 11:58:28 against a process started 11:57:46, so the app kept serving
    # the pre-edit file. A 404 on a route that is plainly in the source reads as
    # a broken build -- and the agent then spent turns "fixing" Express 5
    # routing and, on an earlier run, unset DATABASE_URL and started its own
    # database, because the evidence in front of it said its code was not
    # running. It was not; nothing had restarted it.
    #
    # Stable since Node 22 (the fullstack-node env ships 22.13). Fall back if
    # the runtime is older, so a changed pixi env cannot leave a dead app.
    # 🚨 NOT `node --watch --eval ""` -- node refuses that combination outright
    # ("either --watch or --eval can be used, not both", exit 9), so the probe
    # failed on a runtime that supports --watch perfectly well and every app
    # silently took the fallback. Ask whether the flag EXISTS instead.
    if node --help 2>/dev/null | grep -q -- "--watch"; then
        echo "Starting Express on port ${APP_PORT:-8000} (watching for changes)..."
        exec node --watch index.js
    fi
    echo "Starting Express on port ${APP_PORT:-8000} (no --watch on $(node -v))..."
    exec node index.js
}

if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
    main "$@"
fi

</details>

6、解决问题

从上面了解了 Stack 的运行机制后,就很好解决问题了。

我们要么写一个 startup-app.sh,在这个文件中直接启动项目,要么就将项目中的 server.js 改成 index.js 并默认启动项目时监听在 8000 端口就行。两种方向均可。

7、自定义启动脚本 startup-app.sh

我自己写了一个 startup-app.sh:

bash
# 写入 startup-app.sh 文件
cat << 'EOF' > /home/uppcoder/app/startup-app.sh
#!/bin/bash
export PORT="${APP_PORT:-8000}"
exec npm install
exec npm run seed
exec npm start
EOF
# 给文件添加执行权限
chmod +x /home/uppcoder/app/startup-app.sh
# 重启框架模块
supervisorctl restart framework

8、部署成功

重新访问项目地址,发现现在可以正常了: https://px331bi9-express-pic.apps-3.websson.cloud/

部署成功的图片分享站点部署成功的图片分享站点

9、补充:用本机 SSH 工具连接

这个容器是支持 ssh 的,除了上面介绍过的源站的 webssh 外,还可以用自己的 ssh 工具连接的。

先在设置这一块创建一个 key for ssh,创建好后一般会自动将这个文件下载到你的电脑中的,Windows 电脑一般是下载到你的下载目录的,自己找一下。

创建 SSH Key创建 SSH Key

找到 Stack 中对应的 ssh 块,这里有明确告诉你如何 ssh。你完全可以复制你的这一串信息,在你 Windows 中打开 PowerShell 后直接执行,但大概率会报错。因为你下载的这个文件的权限太大了,系统要求缩小权限为当前用户只读才行。

Stack 中的 SSH 连接信息Stack 中的 SSH 连接信息

所以最好的方式是将这个下载好的 uppcoder_20261109-161014_ed25519 文件(不同用户不同时间生成的文件名不全相同,这里改成你的文件名哦)上传到你的 Linux 系统中,这样方便做权限控制,例如我上传到的 Windows 中的 WSL 子系统 Ubuntu 22.04 下的 /root 中,先给 600 权限,再用 ssh 中给你的串,将文件名改正确就可以完好的 ssh 了。

text
root@IWKPC:~# ls
uppcoder_20261109-161014_ed25519
root@IWKPC:~# chmod 600 uppcoder_20261109-161014_ed25519
root@IWKPC:~# ssh -i uppcoder_20261109-161014_ed25519 -o StrictHostKeyChecking=accept-new -p 2222 px331bi9@px331bi9-express-pic.apps-3.websson.cloud
Warning: Permanently added '[px331bi9-express-pic.apps-3.websson.cloud]:2222' (ED25519) to the list of known hosts.

Environment: web-express

Two pixi environments available:
  default      - System tools       | add <pkg>, remove <pkg>
  web-express  - Framework packages | pixi add <pkg>

Quick commands:
  add vim            # Install vim
  pixi add numpy     # Add numpy to your app
  supervisorctl      # Manage services

uppcoder@uppcoder:~/app$ ls
README.md  docs      node_modules       package.json  pixi.toml  server.js  startup-app.sh
data       index.js  package-lock.json  pixi.lock     public     src        tests
uppcoder@uppcoder:~/app$

SSH 成功连入容器SSH 成功连入容器

总结

由于没有文档,项目全靠自行摸索。但好在已完成了解项目的运行机制。

start-express.sh 文件是执行入口,可以在这里做很多想做的事情,包括建节点啥的,但我不建议大家这么做,毕竟有可能会删号。

不同项目的入口可能会不同,这里主要是以 Express + SQLite 为说明,想知道项目的加载机制,可以看一下对应的日志就很清楚了。

相关地址

相关文章