skip to Main Content

Everything runs perfectly fine on my local machine. However when I push my code to GitLab I get the following error:

From GitLab Job viewer

GUI                | sh: 1: /usr/src/app/test.startup.sh: Permission denied
GUI exited with code 126

This is my setup:

gui/Dockerfile

#cypress image is needed for automated testing, for production a simple node image is enough
FROM cypress/browsers:node14.16.0-chrome89-ff86

ENV PORT 3000

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

COPY package*.json /usr/src/app/

EXPOSE 3000

COPY test.startup.sh /usr/src/app/test.startup.sh

COPY startup.sh /usr/src/app/startup.sh

# the following 4 lines were added to try and solve the problem, they did not. On my local machine it runs fine even without them
RUN chmod 777 /usr
RUN chmod 777 /usr/src
RUN chmod 777 /usr/src/app
RUN chmod 777 /usr/src/app/test.startup.sh

ENTRYPOINT []

docker-compose.testing.yml

version: '3.7'

services:

  GUI:
    network_mode: host
    build: "./gui"
    container_name: GUI

    volumes:
      - "./gui:/usr/src/app"
      - /usr/src/app/node_modules
      - /usr/src/app/.next

    depends_on:
      - rhasspy
      - rhasspy_de
      - rhasspy_adapter

    command: sh -c "/usr/src/app/test.startup.sh"

.gitlab-ci.yml

application:
  stage: application_test
  image: docker
  services: 
    - docker:dind
  script:
    - apk add --no-cache docker-compose
    - docker-compose --file docker-compose.testing.yml build
    - docker-compose --file docker-compose.testing.yml up --abort-on-container-exit

I am out of Ideas so any help is greatly appreciated,
thank you

2

Answers


  1. Chosen as BEST ANSWER

    I fixed the issue by running all commands in the docker-compose file

    docker-compose.testing.yml

    version: '3.7'
    
    services:
    
      GUI:
        network_mode: host
        build: "./gui"
        container_name: GUI
    
        volumes:
          - "./gui:/usr/src/app"
          - /usr/src/app/node_modules
          - /usr/src/app/.next
    
        depends_on:
          - rhasspy
          - rhasspy_de
          - rhasspy_adapter
        
        entrypoint: ["/bin/sh","-c"]
        command: 
          - | 
            npm ci
            npm run start:ci &
            sleep 5
            npm run test:ci
    

  2. In your gitlab-ci.yml, you use docker-compose (which is bad itself, but not is the subject of the question).

    In your docker-compose.yml you mount gui directory as /usr/src/app. So, it does not matter what was in the built image in that directory, all contents will be replaced with contents of gui directory of git working copy.

    To make it work in CI, you need to make sure your script is executable in the git tree. You need to push it as executable.

    Example:

    ~/pipes $ cat gui/test.script.sh
    #!/bin/sh
    
    echo "I'm a script"
    
    ~/pipes $ ls -l gui/test.script.sh 
    -rw-rw-r--. 1 test test 32 Dec 22 01:47 gui/test.script.sh
    
    ~/pipes $ chmod +x gui/test.script.sh 
    
    ~/pipes $ ls -l gui/test.script.sh 
    -rwxrwxr-x. 1 test test 32 Dec 22 01:47 gui/test.script.sh
    
    ~/pipes $ git commit gui/test.script.sh -m 'Now executable.'
    [feature-123 b524b0d] Now executable.
     1 file changed, 0 insertions(+), 0 deletions(-)
     mode change 100644 => 100755 gui/test.script.sh
    
    ~/pipes $ git push
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search