diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index d313a457a5069da5f67ed8ca898465779d618cd4..f584452da717016af305439e8d41a357664f4737 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -156,7 +156,8 @@ test:arch:
   variables:
     DOCKER_DRIVER: overlay2
     DOCKER_HOST: docker
-    IMAGE_TAG_NIGHTLY: $CI_REGISTRY_IMAGE/nightly:latest
+    IMAGE_TAG_NIGHTLY_FULL: $CI_REGISTRY_IMAGE/nightly:latest
+    IMAGE_TAG_NIGHTLY_CLI:  $CI_REGISTRY_IMAGE/nightly-cli:latest
     IMAGE_TAG_RELEASE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
     IMAGE_TAG_LATEST: $CI_REGISTRY_IMAGE:latest
   services:
@@ -175,9 +176,12 @@ docker:build-nightly:
     variables:
       - $SCHEDULED_NIGHTLY
   script:
-    - docker build -t "$IMAGE_TAG_NIGHTLY" .
-    - docker run "$IMAGE_TAG_NIGHTLY" /usr/bin/aql2 --help
-    - docker push "$IMAGE_TAG_NIGHTLY"
+    - docker build -f extra/docker/master/Dockerfile     -t "$IMAGE_TAG_NIGHTLY_FULL" .
+    - docker build -f extra/docker/master-cli/Dockerfile -t "$IMAGE_TAG_NIGHTLY_CLI" .
+    - docker run "$IMAGE_TAG_NIGHTLY_FULL" /usr/bin/aql2 --help
+    - docker run "$IMAGE_TAG_NIGHTLY_CLI"  /usr/bin/aql2 --help
+    - docker push "$IMAGE_TAG_NIGHTLY_FULL"
+    - docker push "$IMAGE_TAG_NIGHTLY_CLI"
 
 docker:build-release:
   <<: *docker_template
@@ -186,7 +190,7 @@ docker:build-release:
   except:
     - branches
   script:
-    - docker build -t "$IMAGE_TAG_RELEASE" -t "$IMAGE_TAG_LATEST" .
+    - docker build -f extra/docker/master/Dockerfile -t "$IMAGE_TAG_RELEASE" -t "$IMAGE_TAG_LATEST" .
     - docker run "$IMAGE_TAG_RELEASE" /usr/bin/aql2 --help
     - docker push "$IMAGE_TAG_RELEASE"
     - docker push "$IMAGE_TAG_LATEST"
diff --git a/extra/docker/master-cli/Dockerfile b/extra/docker/master-cli/Dockerfile
index 16dba3061af7ebbe4c18a2895e2599f30b5989f0..f6c669a0ca35c9badc8ce11e62baa26535e4e7e9 100644
--- a/extra/docker/master-cli/Dockerfile
+++ b/extra/docker/master-cli/Dockerfile
@@ -24,7 +24,7 @@ RUN	CMake/generate.py -wm -p aql2
 WORKDIR	$BASEDIR/release
 RUN	cmake \
 		-DCMAKE_BUILD_TYPE=Release \
-		-DCMAKE_INSTALL_PREFIX=/usr/local \
+		-DCMAKE_INSTALL_PREFIX=$BASEDIR/install \
 		.. && \
 	make -j $(grep -c processor /proc/cpuinfo) && \
 	make test && \
@@ -35,10 +35,8 @@ RUN	cmake \
 # deploy stage
 FROM alpine:3.8
 
-LABEL maintainer="tomas.pecka@fit.cvut.cz"
+LABEL maintainer="peckato1@fit.cvut.cz"
 
-ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/app/lib"
-ENV PATH="${PATH}:/app/bin"
 
 RUN apk add --update \
 	bash \
@@ -49,7 +47,6 @@ RUN apk add --update \
 	tclap \
 	readline
 
-COPY --from=builder /usr/local/bin /app/bin
-COPY --from=builder /usr/local/lib /app/lib
+COPY --from=builder /build/install /usr
 
-CMD aql2
+CMD /usr/bin/aql2