Docker build failing on Travis, works local

I’m kind of at the end of my rope when it comes to Travis-CI and was hoping there’d be some more experienced people on this forum who could help me out or guide me in the right direction.

I’ve built a docker container that might not conform to the idea of being able to scale an application, but I just found it useful to be able to create a container that should basically always be the same and thus my web application should work on all devices the same.

On my local machine the container builds fine, the phpunit tests run fine, etc.

On Travis however, it either isn’t allowed access to files within the container, or it’ll complain about missing PHP plugins, just all of these weird errors that I cannot reproduce on my local computer, not even if I remove all images and containers and just rebuild it fresh.

Additionally I tried to re-run the build in debug mode so I could investigate it better, but I keep getting an unauthorized response, even though I’m sure my account token that I got is correct.

Does Travis perhaps not use “root” as it’s default user in containers, whereas Docker Desktop for Windows does? Or have I misconfigured my travis.yml file?

This is the travis “repository”: https://travis-ci.com/xorinzor/Shoutz0r
and this is the associated github repository: https://github.com/xorinzor/Shoutz0r

Thanks in advance.

Your start.sh doesn’t have the execute bit on:

$ git clone https://github.com/xorinzor/Shoutz0r.git
Cloning into 'Shoutz0r'...
remote: Enumerating objects: 2385, done.
remote: Counting objects: 100% (2385/2385), done.
remote: Compressing objects: 100% (1728/1728), done.
remote: Total 2385 (delta 560), reused 2361 (delta 539), pack-reused 0
Receiving objects: 100% (2385/2385), 17.31 MiB | 8.58 MiB/s, done.
Resolving deltas: 100% (560/560), done.
$ cd Shoutz0r
$ ls -l start.sh
-rw-r--r--  1 asari  staff  519 Feb  9 07:35 start.sh

So you get the Permission denied error.

1 Like

but it works fine if I build the container locally, so what exactly is causing this difference in behaviour?

I suspect Docker on Windows is more forgiving.

That’s not really an answer that would be an solution for me, merely a workaround.

Since docker containers are supposed to be the same, no matter where you build them, I really would like to figure out what’s different between my build and Travis-CI’s build.

To attempt to start the build in debug mode I use:
curl -s -X POST
-H “Content-Type: application/json”
-H “Accept: application/json”
-H “Travis-API-Version: 3”
-H “Authorization: token API_TOKEN”
-d “{“quiet”: true}”
https://api.travis-ci.org/job/JOB_ID/debug

Where I get API_TOKEN from travis-ci.com/account/preferences in the “settings” tab, where it says “API authentication”. And the JOB_ID from line 11 of the log file from (in this case) build 16.

The result of that command however is “Permission denied”.

I think you have a little bit of misunderstanding here.

Docker has a lofty goal of providing you with same user experience across OSes, but as you observed, it behaves differently with the “execution bit”. Setting the execution bit in your case is not a workaround; it is a solution.

For debug builds on public repositories, the debug feature needs to be enabled. This is explained in the documentation. https://docs.travis-ci.com/user/running-build-in-debug-mode/#enabling-debug-mode Please email support@travis-ci.com.

Maybe not a workaround, but it isn’t really a solution to my original question either. As stated I ran into multiple issues, one following another, without any real reason as to why they should be happening.

I think I read over the part where it stated that I had to request debug mode for open-source repositories, thanks for letting me know. I have now requested the debug mode to be enabled, and will most likely be able to solve any current and future issues with it.

This is a common error. If you initially commit a file without the execute bit set changing it on your local copy will have no effect unless you tell git to change the permissions, check/set the mode correctly locally then:

$ git update-index --add --chmod=+x THEFILE
$ git commit -m 'change mode' THEFILE
$ git push

Your alternative is to simply prefix the script with the relevant shell that needs to execute it (bash, sh, tcsh)

2 Likes