i'm currently trying to build my own Jenkins docker image with the purpose to have a Jenkins server, that can build Android gradle based projects and docker images.
From my github repo (https://github.com/mikedolx/docker-jenkins-android) this is how my docker file looks like:
FROM xmartlabs/android AS android
USER root
RUN apt-get update && \
apt-get install -y apt-transport-https curl software-properties-common && \
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - && \
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" && \
apt-get update && \
apt-cache policy docker-ce && \
apt-get clean && \
apt-get install -y docker-ce
FROM jenkins/jenkins
ENV ANDROID_HOME /opt/android-sdk-linux
COPY --from=android ${ANDROID_HOME} ${ANDROID_HOME}
COPY --from=android /usr/lib/jvm/java-8-oracle /usr/lib/jvm/java-8-oracle
COPY --from=android /usr/bin/gradle /usr/bin/gradle
ENV JAVA_HOME /usr/lib/jvm/java-8-oracle
ENV PATH ${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
# Unfortunately, "chown" flag seems not to be available for COPY in DockerHub.
USER root
RUN chown -R jenkins:jenkins ${ANDROID_HOME}
USER jenkins
ENV ANDROID_EMULATOR_FORCE_32BIT true
I have added the needed steps to install docker. I took them from this blog: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04.
I can successfully build the image, and run jenkins server with the following docker-compose.yml
version: '2.2'
services:
jenkins:
image: mikedolx/jenkins-android:latest
container_name: jenkins
user: jenkins
volumes:
- jenkins-data:/var/jenkins_home
ports:
- 8080:8080
- 50000:50000
volumes:
jenkins-data:
I have a pipeline project setup to build this image (https://github.com/mikedolx/docker-nextcloud). When i start the build it stops on the second stage, with the following log:
[Nextcloud-Github] Running shell script
+ docker build -t mikedolx/nextcloud:14.0.1 --file Dockerfile.14.0 .
/var/jenkins_home/workspace/Nextcloud-Github@tmp/durable-f5e443ce/script.sh: 2: /var/jenkins_home/workspace/Nextcloud-Github@tmp/durable-f5e443ce/script.sh: docker: not found
When i ssh into the jenkins container and try to run "docker", i get the same error.
Questions:
- how do i build the jenkins docker image to contain the needed binaries to build a docker image?
- Is this the correct approach to buid a docker image via jenkins?
Thanks in advance,
Regards,
Michael