如何让nektos/act创建已挂载指定卷的Docker容器?
如何让
act创建已挂载指定卷的容器? 我已经搭建了本地Docker环境,正在优化setup-miniconda的运行效率:
- 已构建自定义Docker镜像并推送到本地仓库
- 改用
conda-lock,无需再解析environment.yaml - 最后一步需要让
act创建容器时自动挂载指定卷,实现Conda包下载目录的共享,效果等同于执行:
docker run -it -v /home/vagrant/miniconda/pkgs/:/root/miniconda3/pkgs localhost:5000/my-act /bin/bash
我尝试修改了docker_run.go文件:
func (cr *containerReference) Create(capAdd []string, capDrop []string) common.Executor { cr.input.Mounts["/root/miniconda3/pkgs"] = "/home/vagrant/miniconda/pkgs" return common. NewInfoExecutor("%sdocker create image=%s platform=%s entrypoint=%+q cmd=%+q", logPrefix, cr.input.Image, cr.input.Platform, cr.input.Entrypoint, cr.input.Cmd). Then( common.NewPipelineExecutor( cr.connect(), cr.find(), cr.create(capAdd, capDrop), ).IfNot(common.Dryrun), ) }
.actrc配置:
-P ubuntu-latest=localhost:5000/my-act
本地仓库创建脚本:
actimg="localhost:5000/my-act" docker run -d -p 5000:5000 --restart=always --name registry registry:2 docker build --no-cache -t act-custom:v1 . docker tag act-custom:v1 $actimg docker push $actimg
Dockerfile内容:
FROM catthehacker/ubuntu:act-latest ARG CONDA=/root/miniconda ENV CONDA=$CONDA ENV INSTALL_MINICONDA=$CONDA ARG NODE=/opt/hostedtoolcache/node/16.18.1/x64/bin/node ENV RUNNER_TOOL_CACHE=/opt/hostedtoolcache ENV RUNNER_TEMP=/tmp RUN dl=$( curl -s https://api.github.com/repos/conda-incubator/setup-miniconda/releases/latest | jq -r '.zipball_url' ) \ && wget -q -O dl2.zip $dl \ && unzip -q dl2.zip -d dl2 \ && env INPUT_ARCHITECTURE=x64 \ INPUT_AUTO-ACTIVATE-BASE=true \ INPUT_AUTO-UPDATE-CONDA=false \ INPUT_CLEAN-PATCHED-ENVIRONMENT-FILE=true \ INPUT_MINIFORGE-VARIANT=mambaforge \ INPUT_MINIFORGE-VERSION=latest \ INPUT_REMOVE-PROFILES=false \ INPUT_RUN-POST=true \ INPUT_USE-MAMBA=true \ ${NODE} $( find dl2/ -wholename "*/dist/setup/index.js" ) \ && source ${CONDA}3/etc/profile.d/conda.sh \ && conda config --set default_threads 4 \ && ${NODE} $( find dl2/ -wholename "*/dist/delete/index.js" ) \ && mamba install conda-lock \ && mamba clean --all \ && rm -r /opt/hostedtoolcache/mambaforge/ \ && rm -rf * \ && mv /usr/local/bin/ /usr/local/bin-old \ && ln -s ${CONDA}3/bin /usr/local/bin ENV CONDA=${CONDA}3 ENV PATH=${CONDA}/bin:${PATH} VOLUME /root/miniconda3/pkgs COPY /home/vagrant/geopandas/ci/lock /root/lock CMD [ "/usr/bin/tail -f /dev/null" ]
内容的提问来源于stack exchange,提问作者Rob Raymond
相关产品推荐
相关产品推荐

