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
I fixed the issue by running all commands in the docker-compose file
docker-compose.testing.yml
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 mountgui
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 ofgui
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: