0

I have a self-hosted GitLab that stores my codes. My flutter project uses this pipeline to build an app bundle:

stages:
  - build

cache: paths: - $CI_PROJECT_DIR/.pub-cache/

image: ghcr.io/cirruslabs/flutter:3.16.3

workflow: rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' when: always - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' when: always - when: never

build-android: stage: build tags: - flutter before_script: - export PUB_CACHE=$CI_PROJECT_DIR/.pub-cache - export PATH="$PATH":"$PUB_CACHE/bin" - cd src - flutter doctor --android-licenses script: - flutter build appbundle --release artifacts: paths: - "<build dir>/*.aab" expire_in: 1 week

I configured a runner for this project that specially run this building process. The runner config.toml is this:

concurrent = 1
check_interval = 0
shutdown_timeout = 0

[session_server] session_timeout = 1800

[[runners]] name = "<name>" url = "<git url>" id = <id> token = "<token>" token_obtained_at = <date> token_expires_at = <date> executor = "docker" [runners.cache] MaxUploadedArchiveSize = 0 [runners.docker] tls_verify = false image = "docker:stable" privileged = false disable_entrypoint_overwrite = false oom_kill_disable = false disable_cache = false volumes = ["/cache"] shm_size = 0

My problem issued when the pipeline triggers, and it starts to build the app bundle. This process takes a long time (near 25-30m) although when I build it on my PC it will do so quickly (near 2-3m). Why it's like this? How can I make it faster?

P.S: Resources of both systems are nearly the same! My PC is MacBook Pro m1 2021 and the runner is a LXC that has 10 core Intel(R) Xeon(R) CPU E5-2690 CPU, 16 GB RAM and 40 GB hard.

1 Answers1

0

I installed an S3 server for the runner to cache files inside it (Alternatively, you can use AWS S3). Then reconfigured runner to use this S3 server by adding these lines:

  [runners.custom_build_dir]
  [runners.cache]
    Type = "s3"
    Shared = true
    [runners.cache.s3]
      ServerAddress = "<url>"
      AccessKey = "<Access Key>"
      SecretKey = "<Secret Key>"
      BucketName = "<Bucket name>"

Then added these paths to .gitlab-ci.yml to cache them:

  • /root/.gradle
  • /opt

Now Gradle build takes near 2 minutes but another operation after building that is called Preparing "Install Android Emulator..." takes some time near 10 minutes.