docker: Allow interrupting packaging jobs with C-c.

Use the recommended exec syntax for the CMD directive in the
Dockerfiles, which invokes the command directly rather than through an
intermediate shell.  Also provide the -i option, but conditionally as
Docker checks if there is a real TTY to connect to, which is not the
case in Jenkins.

* scripts/make-packaging-target.py (PACKAGE_*_DOCKER_RUN_COMMAND)
[IS_SHELL_INTERACTIVE]: Conditionally provide the '-i' option.
(package-*-interactive) <DOCKER_EXTRA_ARGS>: Remove target-specific variable.
(DOCKER_EXTRA_ARGS): Move/rename variable to ...
* Makefile (DOCKER_RUN_EXTRA_ARGS): ... here/this.
(IS_SHELL_INTERACTIVE): New variable.

The rest of this change was automated using the command:

  $ git grep -l CMD | xargs sed -i -E 's,CMD (.*)$,CMD ["\1"],g'

Change-Id: I93ba9ad8115541a7c7f02421384ae01a5b0650ad
parent 6f86ab42
......@@ -141,6 +141,12 @@ endif
## Packaging targets ##
#######################
IS_SHELL_INTERACTIVE := $(shell [ -t 0 ] && echo yes)
# The following Make variable can be used to provide extra arguments
# used with the 'docker run' commands invoked to build the packages.
DOCKER_RUN_EXTRA_ARGS =
# Append the output of make-packaging-target to this Makefile
# see Makefile.packaging.distro_targets
$(shell scripts/make-packaging-target.py --generate-all > Makefile.packaging.distro_targets)
......
......@@ -22,4 +22,4 @@ COPY packaging/rules/debian/control /tmp/builddeps/debian/control
RUN /opt/prebuild-package-debian.sh jami-deps
ADD scripts/build-package-debian.sh /opt/build-package-debian.sh
CMD /opt/build-package-debian.sh
CMD ["/opt/build-package-debian.sh"]
......@@ -22,4 +22,4 @@ COPY packaging/rules/debian/control /tmp/builddeps/debian/control
RUN /opt/prebuild-package-debian.sh jami-deps
ADD scripts/build-package-debian.sh /opt/build-package-debian.sh
CMD /opt/build-package-debian.sh
CMD ["/opt/build-package-debian.sh"]
......@@ -22,4 +22,4 @@ COPY packaging/rules/debian/control /tmp/builddeps/debian/control
RUN /opt/prebuild-package-debian.sh jami-deps
ADD scripts/build-package-debian.sh /opt/build-package-debian.sh
CMD /opt/build-package-debian.sh
CMD ["/opt/build-package-debian.sh"]
......@@ -76,4 +76,4 @@ RUN dnf install -y \
ADD scripts/build-package-rpm.sh /opt/build-package-rpm.sh
CMD /opt/build-package-rpm.sh
CMD ["/opt/build-package-rpm.sh"]
......@@ -76,4 +76,4 @@ RUN dnf install -y \
ADD scripts/build-package-rpm.sh /opt/build-package-rpm.sh
CMD /opt/build-package-rpm.sh
CMD ["/opt/build-package-rpm.sh"]
......@@ -76,4 +76,4 @@ RUN dnf install -y \
ADD scripts/build-package-rpm.sh /opt/build-package-rpm.sh
CMD /opt/build-package-rpm.sh
CMD ["/opt/build-package-rpm.sh"]
......@@ -96,4 +96,4 @@ RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 50
ADD scripts/build-package-rpm.sh /opt/build-package-rpm.sh
CMD /opt/build-package-rpm.sh
CMD ["/opt/build-package-rpm.sh"]
......@@ -96,4 +96,4 @@ RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 50
ADD scripts/build-package-rpm.sh /opt/build-package-rpm.sh
CMD /opt/build-package-rpm.sh
CMD ["/opt/build-package-rpm.sh"]
......@@ -101,4 +101,4 @@ RUN zypper --non-interactive install -y \
ADD scripts/build-package-rpm.sh /opt/build-package-rpm.sh
CMD /opt/build-package-rpm.sh
CMD ["/opt/build-package-rpm.sh"]
......@@ -79,4 +79,4 @@ RUN apt update && \
ADD scripts/build-package-debian.sh /opt/build-package-debian.sh
CMD /opt/build-package-debian.sh
CMD ["/opt/build-package-debian.sh"]
......@@ -82,4 +82,4 @@ RUN dnf install -y \
ADD scripts/build-package-rpm.sh /opt/build-package-rpm.sh
CMD /opt/build-package-rpm.sh
\ No newline at end of file
CMD ["/opt/build-package-rpm.sh"]
\ No newline at end of file
......@@ -27,4 +27,4 @@ RUN update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 50
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 50
ADD scripts/build-package-debian.sh /opt/build-package-debian.sh
CMD /opt/build-package-debian.sh
CMD ["/opt/build-package-debian.sh"]
......@@ -22,4 +22,4 @@ COPY packaging/rules/debian/control /tmp/builddeps/debian/control
RUN /opt/prebuild-package-debian.sh jami-deps
ADD scripts/build-package-debian.sh /opt/build-package-debian.sh
CMD /opt/build-package-debian.sh
CMD ["/opt/build-package-debian.sh"]
......@@ -22,4 +22,4 @@ COPY packaging/rules/debian/control /tmp/builddeps/debian/control
RUN /opt/prebuild-package-debian.sh jami-deps
ADD scripts/build-package-debian.sh /opt/build-package-debian.sh
CMD /opt/build-package-debian.sh
CMD ["/opt/build-package-debian.sh"]
......@@ -22,4 +22,4 @@ COPY packaging/rules/debian/control /tmp/builddeps/debian/control
RUN /opt/prebuild-package-debian.sh jami-deps
ADD scripts/build-package-debian.sh /opt/build-package-debian.sh
CMD /opt/build-package-debian.sh
CMD ["/opt/build-package-debian.sh"]
......@@ -27,4 +27,4 @@ Author: Amin Bandali <amin.bandali@savoirfairelinux.com>
+
+ADD scripts/build-package-snap.sh /opt/build-package-snap.sh
+
+CMD /opt/build-package-snap.sh
+CMD ["/opt/build-package-snap.sh"]
......@@ -43,8 +43,6 @@ target_template = """\
PACKAGE_%(distribution)s_DOCKER_IMAGE_NAME:=jami-packaging-%(distribution)s$(RING_PACKAGING_IMAGE_SUFFIX)
PACKAGE_%(distribution)s_DOCKER_IMAGE_FILE:=.docker-image-$(PACKAGE_%(distribution)s_DOCKER_IMAGE_NAME)
DOCKER_EXTRA_ARGS =
PACKAGE_%(distribution)s_DOCKER_RUN_COMMAND = docker run \\
--rm \\
......@@ -59,8 +57,9 @@ PACKAGE_%(distribution)s_DOCKER_RUN_COMMAND = docker run \\
-v $(CURDIR):/opt/ring-project-ro:ro \\
-v $(CURDIR)/packages/%(distribution)s:/opt/output \\
-v /opt/cache-packaging:/opt/cache-packaging \\
-t $(DOCKER_EXTRA_ARGS) %(options)s \\
-v /opt/ring-contrib:/opt/ring-contrib \\
-t $(and $(IS_SHELL_INTERACTIVE),-i) %(options)s \\
$(DOCKER_RUN_EXTRA_ARGS) \\
$(PACKAGE_%(distribution)s_DOCKER_IMAGE_NAME)
$(PACKAGE_%(distribution)s_DOCKER_IMAGE_FILE): docker/Dockerfile_%(docker_image)s
......@@ -82,7 +81,6 @@ package-%(distribution)s: packages/%(distribution)s/%(output_file)s
PACKAGE-TARGETS += package-%(distribution)s
.PHONY: package-%(distribution)s-interactive
package-%(distribution)s-interactive: DOCKER_EXTRA_ARGS = -i
package-%(distribution)s-interactive: $(RELEASE_TARBALL_FILENAME) packages/%(distribution)s $(PACKAGE_%(distribution)s_DOCKER_IMAGE_FILE)
$(PACKAGE_%(distribution)s_DOCKER_RUN_COMMAND) bash
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment