如何加速 GitLab runner?

问题描述 投票:0回答:0

我在

t2.medium
AWS 实例(磁盘是 gp3)上通过 Docker 有一个 GitLab runner,用于以下
.gitlab-ci.yml

# This file is a template, and might need editing before it works on your project.
# To contribute improvements to CI/CD templates, please follow the Development guide at:
# https://docs.gitlab.com/ee/development/cicd/templates.html
# This specific template is located at:
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Python.gitlab-ci.yml

# Official language image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/python/tags/
image: python:3.10

# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
variables:
    PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"

# Pip's cache doesn't store the python packages
# https://pip.pypa.io/en/stable/topics/caching/
#
# If you want to also cache the installed packages, you have to install
# them in a virtualenv and cache it as well.
cache:
    paths:
        - .cache/pip
        - venv/

before_script:
    - python --version ; pip --version # For debugging
    - pip install virtualenv
    - virtualenv venv
    - source venv/bin/activate

stages:
    - build
    - lint

build:
    stage: build
    script:
        - pip install -r requirements-dev.txt

lint:
    stage: lint
    script:
        - flake8 .
        - mypy src

formatting:
    stage: lint
    script:
        - black --check .
        - isort --check .

我有以下问题:

  • 工作超级慢(例如
    build
    阶段需要8分钟),尤其是缓存
  • 由于某些未知原因,缓存创建发生在每个作业之后。我真的不明白为什么,因为
    linting
    formatting
    工作不会改变
    venv
    目录中的任何东西。
  • 几次运行后缓存创建失败,因为磁盘已满(只有 16 GB)。如何教 GitLab runner 清理磁盘?
amazon-ec2 gitlab-ci gitlab-ci-runner
© www.soinside.com 2019 - 2024. All rights reserved.