整体思路#
- 安装 Docker 和 Docker Compose
- 下载星表
- 启动 Docker 容器
- 通过命令调用 Docker 运行
最终效果#
1
2
3
4
5
6
7
8
9
10
11
| # 进入目录:
cd /opt/astrometry
# 运行解算
docker compose run --rm solver-heavy \
--config /etc/astrometry.cfg \
--dir /output/heavy \
--overwrite \
/input/test.fits
# 等待得到结果
|
详细部署过程#
1. 安装 Docker#
Ubuntu 服务器上使用的安装文档:
https://docs.docker.com/engine/install/ubuntu/
- 安装后,可以将需要使用 Docker 的用户加入
docker 组。 - 注意:
docker 组用户实际上拥有接近 root 的权限。 - 添加用户:
sudo usermod -aG docker user_to_use
Mac 安装请参考:
https://docs.docker.com/desktop/setup/install/mac-install/
2. 创建目录#
1
2
3
4
5
6
7
8
9
10
| /opt/astrometry/
├── docker-compose.yml # Docker Compose 启动配置
├── config/ # 配置文件
│ └── astrometry.cfg
├── indexes-light/ # 轻量星表
├── indexes-heavy/ # 重型星表
├── input/ # 待测图像
└── output/ # 输出结果
├── light/
└── heavy/
|
Mac 上可使用:
1
2
| mkdir -p ~/astrometry/{indexes-light,indexes-heavy,input,output/light,output/heavy,config}
cd ~/astrometry
|
3. 下载星表#
轻量星表(60 GB)#
1
2
| cd /opt/astrometry/indexes-light
wget -c -r -l1 -np -nd -A "*.fits" https://portal.nersc.gov/project/cosmo/temp/dstn/index-5200/LITE/
|
重型星表(128 GB)#
1
2
| cd /opt/astrometry/indexes-heavy
wget -c -r -l1 -np -nd -A "*.fits" https://portal.nersc.gov/project/cosmo/temp/dstn/index-5200/
|
4. 准备 Docker Compose 配置并拉取镜像#
在 docker-compose.yml 中写入:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
| name: astrometry
services:
solver-light:
image: astrometrynet/solver:0.98
init: true
user: "${UID}:${GID}"
network_mode: "none"
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
tmpfs:
- /tmp:rw,noexec,nosuid,size=1g
volumes:
- ./indexes-light:/usr/local/data:ro
- ./config/astrometry.cfg:/etc/astrometry.cfg:ro
- ./input:/input:ro
- ./output:/output:rw
entrypoint: ["solve-field"]
command: ["--help"]
solver-heavy:
image: astrometrynet/solver:0.98
init: true
user: "${UID}:${GID}"
network_mode: "none"
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
tmpfs:
- /tmp:rw,noexec,nosuid,size=1g
volumes:
- ./indexes-heavy:/usr/local/data:ro
- ./config/astrometry.cfg:/etc/astrometry.cfg:ro
- ./input:/input:ro
- ./output:/output:rw
entrypoint: ["solve-field"]
command: ["--help"]
|
在 config/astrometry.cfg 中写入:
1
2
3
4
5
| cat > config/astrometry.cfg <<'EOF'
add_path /usr/local/data
autoindex
inparallel
EOF
|
拉取镜像:
5. 运行#
将待测图像 test.fits 放入 input/ 中。
运行:
1
2
3
4
5
| docker compose run --rm solver-heavy \
--config /etc/astrometry.cfg \
--dir /output/heavy \
--overwrite \
/input/test.fits
|
即可得到结果。
使用轻量星表时,将命令中的 heavy 替换为 light 即可。