Hi, I’m trying to run a build from a docker-compose file with 3 services, one of them use a Dockerfile in a gitlab repo, I’m able to build the image in my local machine, but the CI process fails in gitlab because dind doesn’t have installed git, so I create a custom docker image copying the dind Dockerfile and adding the git install, but doesn’t work, I don’t know how to get git inside dind in the CI environment.
Next my files:
docker-compose-dev.yml
version: '3.6'
services:
front:
container_name: client-front
build:
context: .
dockerfile: Dockerfile-dev
volumes:
- '.:/usr/src/app'
- '/usr/src/app/node_modules'
ports:
- 3001:3000
environment:
- NODE_ENV=development
- REACT_APP_USERS_SERVICE_URL=http://localhost:5001
depends_on:
- users-service
users-service:
container_name: mock-users-service
build:
context: ./mockServices/users-service
dockerfile: Dockerfile
ports:
- 5001:80
users-service-swagger:
container_name: users-service-swagger
build:
context: "XXX:YYY@gitlab.com/gusisoft/OneLike/client/users-service.git#devel:swagger"
dockerfile: Dockerfile
ports:
- 8081:8080
environment:
- API_URL=definitions/users-service.yml
depends_on:
- users-service
.gitlab-ci.yml
image: docker
services:
- docker:dind
stages:
- unit_test
- build_test
before_script:
- apk update
- apk upgrade
- apk add --no-cache python python-dev py-pip build-base
- pip install docker-compose
unit_test:
stage: unit_test
script:
- docker-compose -f docker-compose-dev.yml up -d --build
build_test:
stage: build_test
script:
- docker-compose -f docker-compose.yml build --no-cache
gitlab-ci log
Running with gitlab-runner 11.4.2 (cf91d5e1)
on docker-auto-scale ed2dce3a
Using Docker executor with image docker ...
Starting service docker:dind ...
Pulling docker image docker:dind ...
Using docker image sha256:acfec978837639b4230111b35a775a67ccbc2b08b442c1ae2cca4e95c3e6d08a for docker:dind ...
Waiting for services to be up and running...
Pulling docker image docker ...
Using docker image sha256:fd7e073eb60f300c2e6c7e4035e23fff313c3a72f73c704a52095f0db736e62e for docker ...
Running on runner-ed2dce3a-project-9197775-concurrent-0 via runner-ed2dce3a-srm-1541708115-d934a2be...
Cloning repository...
Cloning into '/builds/gusisoft/OneLike/client/front'...
Checking out fbdfd27c as devel...
Skipping Git submodules setup
$ apk update
fetch dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch /dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
v3.8.1-59-ge104e0f441 [dl-cdn.alpinelinux.org/alpine/v3.8/main]
v3.8.1-42-ge6bc061baf [dl-cdn.alpinelinux.org/alpine/v3.8/community]
OK: 9546 distinct packages available
$ apk upgrade
OK: 5 MiB in 14 packages
$ apk add --no-cache python python-dev py-pip build-base
fetch dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
(1/32) Installing binutils (2.30-r5)
(2/32) Installing libmagic (5.32-r0)
(3/32) Installing file (5.32-r0)
(4/32) Installing gmp (6.1.2-r1)
(5/32) Installing isl (0.18-r0)
(6/32) Installing libgomp (6.4.0-r9)
(7/32) Installing libatomic (6.4.0-r9)
(8/32) Installing pkgconf (1.5.3-r0)
(9/32) Installing libgcc (6.4.0-r9)
(10/32) Installing mpfr3 (3.1.5-r1)
(11/32) Installing mpc1 (1.0.3-r1)
(12/32) Installing libstdc++ (6.4.0-r9)
(13/32) Installing gcc (6.4.0-r9)
(14/32) Installing musl-dev (1.1.19-r10)
(15/32) Installing libc-dev (0.7.1-r0)
(16/32) Installing g++ (6.4.0-r9)
(17/32) Installing make (4.2.1-r2)
(18/32) Installing fortify-headers (0.9-r0)
(19/32) Installing build-base (0.5-r1)
(20/32) Installing libbz2 (1.0.6-r6)
(21/32) Installing expat (2.2.5-r0)
(22/32) Installing libffi (3.2.1-r4)
(23/32) Installing gdbm (1.13-r1)
(24/32) Installing ncurses-terminfo-base (6.1_p20180818-r1)
(25/32) Installing ncurses-terminfo (6.1_p20180818-r1)
(26/32) Installing ncurses-libs (6.1_p20180818-r1)
(27/32) Installing readline (7.0.003-r0)
(28/32) Installing sqlite-libs (3.24.0-r0)
(29/32) Installing python2 (2.7.15-r1)
(30/32) Installing py-setuptools (39.1.0-r0)
(31/32) Installing py2-pip (10.0.1-r0)
(32/32) Installing python2-dev (2.7.15-r1)
Executing busybox-1.28.4-r1.trigger
OK: 233 MiB in 46 packages
Running setup.py install for PyYAML: started
Running setup.py install for PyYAML: finished with status 'done'
Running setup.py install for dockerpty: started
Running setup.py install for dockerpty: finished with status 'done'
Running setup.py install for backports.ssl-match-hostname: started
Running setup.py install for backports.ssl-match-hostname: finished with status 'done'
Running setup.py install for docopt: started
Running setup.py install for docopt: finished with status 'done'
Running setup.py install for texttable: started
Running setup.py install for texttable: finished with status 'done'
Running setup.py install for functools32: started
Running setup.py install for functools32: finished with status 'done'
Successfully installed PyYAML-3.13 backports.ssl-match-hostname-3.5.0.1 cached-property-1.5.1 certifi-2018.10.15 chardet-3.0.4 docker-3.5.1 docker-compose-1.23.1 docker-pycreds-0.3.0 dockerpty-0.4.1 docopt-0.6.2 enum34-1.1.6 functools32-3.2.3.post2 idna-2.7 ipaddress-1.0.22 jsonschema-2.6.0 requests-2.20.1 six-1.11.0 texttable-0.9.1 urllib3-1.24.1 websocket-client-0.54.0
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
$ docker-compose -f docker-compose-dev.yml up -d --build
Creating network "front_default" with the default driver
Building users-service
Step 1/10 : FROM node:11.1.0
11.1.0: Pulling from library/node
Digest: sha256:4c42c2b2f908cdd43e833047e38ac553dfed79a51b0583bcd4550c60d35bf383
Status: Downloaded newer image for node:11.1.0
---> 4e4c445311e6
Step 2/10 : RUN mkdir -p /app/db
---> Running in 6b4448ef6225
Removing intermediate container 6b4448ef6225
---> 7747f4ba93ba
Step 3/10 : RUN mkdir -p /app/routes
---> Running in 0a2dd69f5557
Removing intermediate container 0a2dd69f5557
---> c1252ecd10a5
Step 4/10 : WORKDIR /app
---> Running in 3c56e29ef99d
Removing intermediate container 3c56e29ef99d
---> a667ceca628a
Step 5/10 : COPY package.json /app/package.json
---> 47308c66236c
Step 6/10 : COPY server.js /app/server.js
---> 6a4510dfe7a8
Step 7/10 : COPY db/db.json /app/db/db.json
---> 4cc16d10e89b
Step 8/10 : COPY routes/openRoutes.json /app/routes/openRoutes.json
---> fbb022773399
Step 9/10 : RUN npm install --silent
---> Running in 70b1757bafb4
added 227 packages from 121 contributors and audited 448 packages in 8.515s
found 0 vulnerabilities
Removing intermediate container 70b1757bafb4
---> 6495cb684e61
Step 10/10 : CMD ["node", "server.js"]
---> Running in 1fbd6753af59
Removing intermediate container 1fbd6753af59
---> 8f24189592e8
Successfully built 8f24189592e8
Successfully tagged front_users-service:latest
Building users-service-swagger
failed to init repo at /var/lib/docker/tmp/docker-build-git597457475: : exec: "git": executable file not found in $PATH
ERROR: Job failed: exit code 1
When I change the image docker:dind with gusisoft/dind-git (A image bases on docker:dind) I get the following error on build
Running with gitlab-runner 11.4.2 (cf91d5e1)
on docker-auto-scale ed2dce3a
Using Docker executor with image docker ...
Starting service gusisoft/dind-git:latest ...
Pulling docker image gusisoft/dind-git:latest ...
Using docker image sha256:fd25c12bcf539a899374835abf1963684e8f76909dc67ce7593111771d953ef0 for gusisoft/dind-git:latest ...
Waiting for services to be up and running...
Pulling docker image docker ...
Using docker image sha256:fd7e073eb60f300c2e6c7e4035e23fff313c3a72f73c704a52095f0db736e62e for docker ...
Running on runner-ed2dce3a-project-9197775-concurrent-0 via runner-ed2dce3a-srm-1541708084-3724a3e8...
Cloning repository...
Cloning into '/builds/gusisoft/OneLike/client/front'...
Checking out 08aa8633 as devel...
Skipping Git submodules setup
$ apk update
fetch dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
v3.8.1-59-ge104e0f441 [dl-cdn.alpinelinux.org/alpine/v3.8/main]
v3.8.1-42-ge6bc061baf [dl-cdn.alpinelinux.org/alpine/v3.8/community]
OK: 9546 distinct packages available
$ apk upgrade
OK: 5 MiB in 14 packages
$ apk add --no-cache python python-dev py-pip build-base
fetch dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
(1/32) Installing binutils (2.30-r5)
(2/32) Installing libmagic (5.32-r0)
(3/32) Installing file (5.32-r0)
(4/32) Installing gmp (6.1.2-r1)
(5/32) Installing isl (0.18-r0)
(6/32) Installing libgomp (6.4.0-r9)
(7/32) Installing libatomic (6.4.0-r9)
(8/32) Installing pkgconf (1.5.3-r0)
(9/32) Installing libgcc (6.4.0-r9)
(10/32) Installing mpfr3 (3.1.5-r1)
(11/32) Installing mpc1 (1.0.3-r1)
(12/32) Installing libstdc++ (6.4.0-r9)
(13/32) Installing gcc (6.4.0-r9)
(14/32) Installing musl-dev (1.1.19-r10)
(15/32) Installing libc-dev (0.7.1-r0)
(16/32) Installing g++ (6.4.0-r9)
(17/32) Installing make (4.2.1-r2)
(18/32) Installing fortify-headers (0.9-r0)
(19/32) Installing build-base (0.5-r1)
(20/32) Installing libbz2 (1.0.6-r6)
(21/32) Installing expat (2.2.5-r0)
(22/32) Installing libffi (3.2.1-r4)
(23/32) Installing gdbm (1.13-r1)
(24/32) Installing ncurses-terminfo-base (6.1_p20180818-r1)
(25/32) Installing ncurses-terminfo (6.1_p20180818-r1)
(26/32) Installing ncurses-libs (6.1_p20180818-r1)
(27/32) Installing readline (7.0.003-r0)
(28/32) Installing sqlite-libs (3.24.0-r0)
(29/32) Installing python2 (2.7.15-r1)
(30/32) Installing py-setuptools (39.1.0-r0)
(31/32) Installing py2-pip (10.0.1-r0)
(32/32) Installing python2-dev (2.7.15-r1)
Executing busybox-1.28.4-r1.trigger
OK: 233 MiB in 46 packages
Running setup.py install for PyYAML: started
Running setup.py install for PyYAML: finished with status 'done'
Running setup.py install for dockerpty: started
Running setup.py install for dockerpty: finished with status 'done'
Running setup.py install for backports.ssl-match-hostname: started
Running setup.py install for backports.ssl-match-hostname: finished with status 'done'
Running setup.py install for docopt: started
Running setup.py install for docopt: finished with status 'done'
Running setup.py install for texttable: started
Running setup.py install for texttable: finished with status 'done'
Running setup.py install for functools32: started
Running setup.py install for functools32: finished with status 'done'
Successfully installed PyYAML-3.13 backports.ssl-match-hostname-3.5.0.1 cached-property-1.5.1 certifi-2018.10.15 chardet-3.0.4 docker-3.5.1 docker-compose-1.23.1 docker-pycreds-0.3.0 dockerpty-0.4.1 docopt-0.6.2 enum34-1.1.6 functools32-3.2.3.post2 idna-2.7 ipaddress-1.0.22 jsonschema-2.6.0 requests-2.20.1 six-1.11.0 texttable-0.9.1 urllib3-1.24.1 websocket-client-0.54.0
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
$ docker-compose -f docker-compose-dev.yml up -d --build
Couldn't connect to Docker daemon at http+docker://localhost - is it running?
If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
ERROR: Job failed: exit code 1