on
Setting up a local docker for Bitrise
So I had encountered an issue where things were working locally but not on our CI server Bitrise. This turned out to be an unrelated issue with Java 8 and minifying. In the process, I learnt about how to set up Docker locally with the same server set up as Bitrise so that I could test there build locally. This is the beauty with Bitrise, it is open source and you can see how things run on your own machine via Docker. By no means am I a Docker expert, but here are the main commands to get you up and running for Bitrise (official instructions here)
I’ll assume you are using a Mac! Download Docker for Mac. Run the following:
docker pull quay.io/bitriseio/android:latest
docker run --privileged --env CI=false --volume "$(pwd):/bitrise/src" --volume "/var/run/docker.sock:/var/run/docker.sock" --rm quay.io/bitriseio/android:latest bitrise run WORKFLOW`
The first command will take a while as the base image is about 15gb now. Be sure to put in the bitrise.yml in the directory you are running it from, and change “WORKFLOW” to your named Bitrise workflow. You can also add other volumes e.g. -v /tmp/bitrise-cache:/bitrise/cache -v /tmp/bitrise-deploy:/bitrise/deploy. Running the command with –env CI=false lets the Bitrise build know that it’s not the CI server running and that you’re just running the build, so the stages in the workflow such as git clones of your code will be skipped, so you will need to run this command from the root of your source code with your bitrise.yml file there as well!
The “–rm” will remove the container once it is done, so if you want to do something interactive with it, you can remove this parameter. You can thereafter connect to it by first finding out the name of the container with
docker ps -a
or if you’re more UI inclined:
docker pull portainer/portainer
docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer
and hit http://localhost:9000 to see the list of created containers. With the listed entries using the container name (top for most recent), you can run the command:
docker exec -it "container_name" -v $(pwd):/bitrise/src -v /tmp/bitrise-cache:/bitrise/cache -v /tmp/bitrise-deploy:/bitrise/deploy /bin/bash
From here you have a shell in to the container and see the exact configuration of the server. You can also run the build manually from the shell with:
bitrise run WORKFLOW