├── .gitignore ├── LICENSE ├── README.MD ├── entrypoint.sh ├── run.sh └── update.sh /.gitignore: -------------------------------------------------------------------------------- 1 | ./id_rsa 2 | ./id_rsa.pub 3 | ./cache 4 | ./idea 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Rust中文社区 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | # Lernaean Deploy 2 | 3 | 该项目用于部署基于[lernaean](https://github.com/rustcc/lernaean)的[crates.io](https://crates.io)镜像,该项目不具有通用性,仅用于配置[rust.cc](https://rust.cc)社区的镜像。 4 | 5 | # 如何使用这个镜像 6 | 7 | 在你的Cargo配置文件中如下配置 8 | 9 | ```toml 10 | [source.crates-io] 11 | replace-with = "rustcc" 12 | 13 | [source.rustcc] 14 | registry = "https://code.aliyun.com/rustcc/crates.io-index.git" 15 | ``` 16 | 17 | # 其他 18 | 19 | 当前该镜像仍然处于实验阶段,镜像配置方式后期可能发生变化,仅建议用于日常开发用途,不建议配置在长期无人值守的流程中,如持续集成/持续部署脚本。强烈建议订阅[该issue](https://github.com/rustcc/lernaean-deploy/issues/2)及时获取最新信息。 20 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -ex 4 | 5 | rm -f /etc/localtime 6 | ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 7 | echo "StrictHostKeyChecking no" >> /root/.ssh/config 8 | 9 | echo "nameserver 119.29.29.29" > /etc/resolv.conf 10 | echo "nameserver 114.114.114.114" >> /etc/resolv.conf 11 | 12 | lernaean \ 13 | --dl https://crates.longhash.com.cn/api/v1/crates \ 14 | --origin git@code.aliyun.com:rustcc/crates.io-index.git \ 15 | --prefetch_interval 0 -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | function die() { 6 | echo "$1"; 7 | echo "exit with code 1"; 8 | exit 1; 9 | } 10 | 11 | readonly current_dir=$(cd `dirname $0`; pwd) 12 | readonly cache_dir=${current_dir}/cache 13 | readonly key_path=${current_dir}/id_rsa 14 | readonly entrypoint_path=${current_dir}/entrypoint.sh 15 | 16 | if [[ ! -f ${key_path} ]]; then 17 | die "can't found private key file" 18 | fi; 19 | 20 | mkdir -p ${cache_dir} 21 | 22 | docker run -d \ 23 | --log-driver json-file \ 24 | --log-opt max-size=10m \ 25 | --log-opt max-file=10 \ 26 | -p 127.0.0.1:8000:8000 \ 27 | -v ${cache_dir}:/cache \ 28 | -v ${key_path}:/root/.ssh/id_rsa \ 29 | -v ${entrypoint_path}:/workdir/entrypoint.sh \ 30 | --name lernaean \ 31 | reg.qiniu.com/dcjanus/lernaean:latest \ 32 | /workdir/entrypoint.sh 33 | -------------------------------------------------------------------------------- /update.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -ex 4 | 5 | readonly current_dir=$(cd `dirname $0`; pwd) 6 | 7 | docker pull reg.qiniu.com/dcjanus/lernaean 8 | docker stop lernaean 9 | docker container prune -f 10 | 11 | ${current_dir}/run.sh --------------------------------------------------------------------------------