是的,您可以将 DataJoint LabBook 服务移至不同的端口,但是需要进行一些更改才能使其正常运行。
TL;DR
假设您在本地访问 DataJoint LabBook,请执行以下步骤:
- 将
127.0.0.1 fakeservices.datajoint.io 行添加到您的hosts 文件中。验证hosts 文件location in your file system。
- 将
docker-compose-deploy.yaml中的ports配置修改为:
ports:
- "3000:443" # replace 3000 with the port of your choosing
#- "80:80" # disables HTTP -> HTTPS redirect
- 在您的 Google Chrome 浏览器中导航至
https://fakeservices.datajoint.io:3000
详细说明
让我先谈谈架构,然后描述相关的变化。
以下是文档中提供的Docker Compose file。我会假设您正在尝试在本地运行它。
# PHARUS_VERSION=0.1.0 DJLABBOOK_VERSION=0.1.0 docker-compose -f docker-compose-deploy.yaml pull
# PHARUS_VERSION=0.1.0 DJLABBOOK_VERSION=0.1.0 docker-compose -f docker-compose-deploy.yaml up -d
#
# Intended for production deployment.
# Note: You must run both commands above for minimal outage.
# Make sure to add an entry into your /etc/hosts file as `127.0.0.1 fakeservices.datajoint.io`
# This serves as an alias for the domain to resolve locally.
# With this config and the configuration below in NGINX, you should be able to verify it is
# running properly by navigating in your browser to `https://fakeservices.datajoint.io`.
# If you don't update your hosts file, you will still have access at `https://localhost`
# however it should simply display 'Not secure' since the cert will be invalid.
version: "2.4"
x-net: &net
networks:
- main
services:
pharus:
<<: *net
image: datajoint/pharus:${PHARUS_VERSION}
environment:
- PHARUS_PORT=5000
fakeservices.datajoint.io:
<<: *net
image: datajoint/nginx:v0.0.16
environment:
- ADD_zlabbook_TYPE=STATIC
- ADD_zlabbook_PREFIX=/
- ADD_pharus_TYPE=REST
- ADD_pharus_ENDPOINT=pharus:5000
- ADD_pharus_PREFIX=/api
- HTTPS_PASSTHRU=TRUE
entrypoint: sh
command:
- -c
- |
rm -R /usr/share/nginx/html
curl -L $$(echo "https://github.com/datajoint/datajoint-labbook/releases/download/\
${DJLABBOOK_VERSION}/static-djlabbook-${DJLABBOOK_VERSION}.zip" | tr -d '\n' | \
tr -d '\t') -o static.zip
unzip static.zip -d /usr/share/nginx
mv /usr/share/nginx/build /usr/share/nginx/html
rm static.zip
/entrypoint.sh
ports:
- "443:443"
- "80:80"
depends_on:
pharus:
condition: service_healthy
networks:
main:
首先,上面标题注释中的Note 很重要,似乎在DataJoint LabBook 文档中被遗漏了(我已经提交了这个issue 来更新它)。确保遵循Note 中的说明,因为“安全”访问权限是required from pharus(更多内容见下文)。
从 Docker Compose 文件中,您会注意到 2 个服务:
-
pharus - DataJoint REST API 后端服务。此服务配置为侦听端口5000,但是,它实际上并未暴露给主机。这意味着它不会发生冲突,也不需要任何更改,因为它完全包含在本地虚拟 docker 网络中。
-
fakeservices.datajoint.io - 向主机公开的代理服务,因此可以在本地和公开访问主机。其主要目的是:
a) 将以/api 开头的请求转发到pharus,或
b) 解决对 DataJoint LabBook GUI 的其他请求。
DataJoint LabBook 的 GUI 是一个静态 Web 应用程序,这意味着它可以用作不安全(HTTP,通常是端口 80)和安全(HTTPS,通常是端口 443)。由于来自pharus 的安全要求,对端口80 的请求被简单地重定向到443 并为了方便而暴露。因此,如果我们想将 DataJoint LabBook 移动到新端口,我们只需将443 的映射更改为主机上的新端口并禁用80 -> 443 重定向。因此,端口更新如下所示:
ports:
- "3000:443" # replace 3000 with the port of your choosing
#- "80:80" # disables HTTP -> HTTPS redirect
最后,在配置和启动服务后,您应该能够通过在 Google Chrome 浏览器中导航到 https://fakerservices.datajoint.io:3000 来确认端口更改。