【问题标题】:Github Actions - create a fast running actionGithub Actions - 创建一个快速运行的动作
【发布时间】:2020-06-25 18:53:32
【问题描述】:

我正在创建一个 github docker 容器操作,该操作涉及许多依赖项 python、node、pypi 包和 npm 包。为了加快操作,我将大量依赖项安装从入口点移动到 Dockerfile。现在我的动作运行得非常快,但每次构建动作都需要很长时间。

有没有一种方法可以预先构建操作,或者我是否需要将我的操作 docker 映像发布到某个存储库并从我的自定义映像中提供?

供参考,这是我的 Dockerfile。

FROM python:3

LABEL "com.github.actions.name"="kedro-action"
LABEL "com.github.actions.description"="A Github Action to run kedro commands"
LABEL "com.github.actions.icon"="it-branch"
LABEL "com.github.actions.color"="black"

LABEL "repository"="http://github.com/WaylonWalker/kedro-action"
LABEL "maintainer"="Waylon Walker <waylon@waylonwalker.com>"

RUN apt-get update
RUN apt-get install -y jq

ENV PYENV_ROOT /root/.pyenv
ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
RUN curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash

### INSTALL PYTHON ###
RUN pyenv install 3.7.6
RUN pyenv global 3.7.6
RUN python -m pip install --upgrade pip
RUN pip install kedro
RUN pip install kedro-viz

### INSTALL NODEJS ###
RUN apt-get install curl -y
RUN curl -sL https://deb.nodesource.com/setup_11.x | bash -
RUN apt-get install nodejs -y

### CLONE KEDRO-STATIC-VIZ ###
RUN mkdir ~/build_dir && cd ~/build_dir
RUN git clone https://github.com/WaylonWalker/kedro-static-viz.git
RUN cd kedro-static-viz
RUN npm install -g gatsby-cli
RUN cd kedro-static-viz && npm install && npm audit fix


ADD entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

【问题讨论】:

    标签: docker github-actions github-package-registry docker-repository


    【解决方案1】:

    您可以为您的操作预构建 Docker 映像,然后在 action.yml 文件中指定预构建的映像而不是 Dockerfile。请参阅文档here

    这是我的一个操作示例,即prebuilt here

    runs:
      using: 'docker'
      image: 'docker://peterevans/dockerhub-description:2.1.0'
    

    【讨论】:

    • 请务必这样做!让我抓狂的是,github 是如何让人们不应该为他们的行为发布图像而不是 dockerfile 变得如此模糊的。一件小事。您应该不时重建映像以下载最新的操作系统包,以修复安全漏洞。
    猜你喜欢
    • 2021-04-26
    • 2020-10-26
    • 2021-09-23
    • 2022-01-10
    • 1970-01-01
    • 2020-05-02
    • 1970-01-01
    • 1970-01-01
    • 2019-11-05
    相关资源
    最近更新 更多