关于 Mattermost 服务端的安装搭建在此不做赘述，如果有朋友需要经验可以留言评论。我使用的是官方的 Dockerfile 构建并运行的。主程序 Dockerfile 位于 app/Dockerfile，mm 官方 GitHub 仓库地址: https://github.com/mattermost/mattermost-server FROM alpine:3.10 # Some ENV variables ENV PATH="/mattermost/bin:${PATH}" ENV MM_INSTALL_TYPE=docker # Build argument to set Mattermost edition ARG edition=enterprise ARG PUID=1002 ARG PGID=1003 ARG MM_BINARY= #ARG MM_VERSION=5.37.9 ARG MM_VERSION=7.8.0 # Install some needed packages RUN apk add --no-cache \ ca-certificates \ curl \ jq \ libc6-compat \ libffi-dev \ libcap \ linux-headers \ mailcap \ netcat-openbsd \ xmlsec-dev \ tzdata \ && rm -rf /tmp/* # Get Mattermost RUN mkdir -p /mattermost/data /mattermost/plugins /mattermost/client/plugins \ && if [ ! -z "$MM_BINARY" ]; then curl $MM_BINARY | tar -xvz ; \ elif [ "$edition" = "team" ] ; then curl https://releases.mattermost.com/$MM_VERSION/mattermost-team-$MM_VERSION-linux-amd64.tar.gz?src=docker-app | tar -xvz ; \ else curl https://releases.mattermost.com/$MM_VERSION/mattermost-$MM_VERSION-linux-amd64.tar.gz?src=docker-app | tar -xvz ; fi \ && cp /mattermost/config/config.json /config.json.save \ && rm -rf /mattermost/config/config.json \ && addgroup -g ${PGID} mattermost \ && adduser -D -u ${PUID} -G mattermost -h /mattermost -D mattermost \ && chown -R mattermost:mattermost /mattermost /config.json.save /mattermost/plugins /mattermost/client/plugins \ && setcap cap_net_bind_service=+ep /mattermost/bin/mattermost USER mattermost #Healthcheck to make sure container is ready HEALTHCHECK CMD curl --fail http://localhost:8000 || exit 1 # Configure entrypoint and command COPY entrypoint.sh / ENTRYPOINT ["/entrypoint.sh"] WORKDIR /mattermost CMD ["mattermost"] # Expose port 8000 of the container EXPOSE 8000 # Declare volumes for mount point directories VOLUME ["/mattermost/data", "/mattermost/logs", "/mattermost/config", "/mattermost/plugins", "/mattermost/client/plugins"] 修改 MM_VERSION 为 7.8.0 之后发现卡在了 # Get Mattermost 的步骤，原因是与官方的服务器网络不通畅，下载速度特别慢，还容易丢失连接。 curl https://releases.mattermost.com/$MM_VERSION/mattermost-$MM_VERSION-linux-amd64.tar.gz?src=docker-app | tar -xvz 将此压缩包下载到本地， https://releases.mattermost.com/7.8.0/mattermost-7.8.0-linux-amd64.tar.gz?src=docker-app 然后上传到我的 Seafile，生成分享链接后通过 curl 获取文件直链，参考文章 获取 seafile 分享的文件直链 ，再更改 Dockerfile，就可以很快的 docker-compose build 了。 当时用 curl/wget -O mattermost-7.8.0-linux-amd64.tar.gz 都没有成功，拿到文件直链轻松解决。 https://emby.940304.xyz:23399/seafhttp/files/ac915dbb-14b7-4815-80c9-2d989f1830a2/mattermost-7.8.0-linux-amd64.tar.gz.tar
创建一个带有效期的分享文件的链接，比如 http://192.168.1.29:8088/f/266c337aab4c40598023/ 点击即下载的直链是 http://192.168.1.29:8088/f/266c337aab4c40598023/?dl=1 但这些都还需要 js 运行后下载器才能获取到文件的直链。之前更新 Mattermost 后端需要下载最新版的 mm 压缩包程序，由于官网太慢，我就下载到了本地然后通过公网的 seafile 分享了个链接，试图修改 Dockerfile 让 curl 直接下载文件，最终找到了文件直链。 $ curl -vv http://192.168.1.29:8088/f/266c337aab4c40598023/?dl=1 * Trying 192.168.1.29... * TCP_NODELAY set * Connected to 192.168.1.29 (192.168.1.29) port 8088 (#0) > GET /f/266c337aab4c40598023/?dl=1 HTTP/1.1 > Host: 192.168.1.29:8088 > User-Agent: curl/7.52.1 > Accept: */* > < HTTP/1.1 302 Found < Server: nginx/1.18.0 (Ubuntu) < Date: Wed, 22 Feb 2023 01:46:28 GMT < Content-Type: text/html; charset=utf-8 < Content-Length: 0 < Connection: keep-alive < Location: http://192.168.1.29:8088/seafhttp/files/ab1a6620-1623-41e2-8838-3920199694e3/Snipaste_2022-06-09_11-02-04.png < Vary: Cookie, Accept-Language < Content-Language: en < Set-Cookie: sfcsrftoken=FoZm3c677QZ3S99XuZe17Wl8wivMUBafSYH02DMBxFTsZcq7V4o5IMCxHzteWfr0; expires=Wed, 21 Feb 2024 01:46:28 GMT; Max-Age=31449600; Path=/; SameSite=Lax < * Curl_http_done: called premature == 0 * Connection #0 to host 192.168.1.29 left intact 可以看到 curl 之后 HTTP/1.1 302 Found，目标路径 location 是 http://192.168.1.29:8088/seafhttp/files/ab1a6620-1623-41e2-8838-3920199694e3/Snipaste_2022-06-09_11-02-04.png，这个就是文件直链。但在有效期过了之后文件直链便不可访问了。