Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.gitlab-ci.yml error: "apk: command not found"

I have the following .gitlab-ci.yml file:

image: docker

services:
  - docker:dind

stages:
  - test
  - build
  - deploy

test:
  stage: test
  before_script:
    - apk add --update -y python-pip
    - pip install docker-compose
  script:
    - echo "Testing the app"
    - docker-compose run app sh -c "python manage.py test && flake8"

build:
  stage: build
  only:
    - develop
    - production
    - feature/deploy-debug-gitlab
  before_script:
    - apk add --update -y python-pip
    - pip install docker-compose
  script:
    - echo "Building the app"
    - docker-compose build

deploy:
  stage: deploy
  only:
    - master
    - develop
    - feature/deploy
    - feature/deploy-debug-gitlab
  before_script:
    - apk add --update -y python-pip
    - pip install docker-compose
  script:
    - echo "Deploying the app"
    - docker-compose up -d
  environment: production
  when: manual

When the Gitlab runner executes it, I get the following error:

$ apk add --update -y python-pip
bash: line 82: apk: command not found
ERROR: Job failed: exit status 1

How am I supposed to install apk? Or what image other than docker should I be using to run this gitlab-ci.yml file?

like image 786
Xar Avatar asked May 30 '19 19:05

Xar


2 Answers

Well, it turns out I had two different runners: one marked as "shell executor" (Ubuntu) and the other marked as "docker executor“.

This error was being thrown out only when the Ubuntu runner was dispatching the job, since Ubuntu doesn´t come with apk.

I disabled the Ubuntu runner and solved the problem.

like image 177
Xar Avatar answered Nov 20 '22 15:11

Xar


The alternative is to set your installation on step above test, as in this issue

image: docker:latest

services:
- docker:dind

before_script:
- apk add --update python-pip
like image 3
VonC Avatar answered Nov 20 '22 15:11

VonC