From a5c8c90eb0ab9dc530f5d5ff6c5c151537e99009 Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Sat, 7 Nov 2020 00:41:41 +0530 Subject: [PATCH] gitlabci: Update Dockerfile and script Re-heating a server template is a bad idea in the case of Docker images since they are composed of immutable layers. The size of the image will keep going up with each subsequent build. Building using debian:testing instead. GitLab is no longer allowing docker login with the main password. A personal access token with the permissions of "api, read_registry, write_registry" should be used instead. Avoided copying the massive .container directory into the Docker container by using a .dockerignore file. Signed-off-by: Joseph Nuthalapati Reviewed-by: James Valleroy --- .ci/Dockerfile.gitlabci | 26 ++++++++++++++++---------- .ci/Dockerfile.gitlabci.dockerignore | 10 ++++++++++ .ci/update-gitlabci-docker-image.sh | 5 ++--- 3 files changed, 28 insertions(+), 13 deletions(-) create mode 100644 .ci/Dockerfile.gitlabci.dockerignore diff --git a/.ci/Dockerfile.gitlabci b/.ci/Dockerfile.gitlabci index 867b53c28..0e22916a6 100644 --- a/.ci/Dockerfile.gitlabci +++ b/.ci/Dockerfile.gitlabci @@ -1,22 +1,28 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# This is an IaC pattern called "reheating a server template". -# This is very fast but can accumulate cruft over time. -# Use debian:testing if you want to build a fresh image. -FROM registry.salsa.debian.org/freedombox-team/freedombox:gitlabci +FROM debian:testing USER root COPY . /plinth WORKDIR /plinth RUN echo "deb http://deb.debian.org/debian testing main" > /etc/apt/sources.list -RUN echo "deb-src http://deb.debian.org/debian testing main" >> /etc/apt/sources.list ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update -RUN apt-get build-dep -y . # Dependencies of the freedombox Debian package -RUN apt-get install -y build-essential # Build dependencies -RUN apt-get install -y sshpass parted # Test dependencies -RUN apt-get install -y sudo -RUN apt-get install -y $(./run --list-dependencies) # Module dependencies + +# Dependencies of the freedombox Debian package +RUN apt-get build-dep -y . + +# Build dependencies +RUN apt-get install -y build-essential \ + # Test dependencies + sshpass parted \ + sudo python3-pip + +# Module dependencies +RUN apt-get install -y $(./run --list-dependencies) + +# Coverage should know that test_functional.py files are tests +RUN pip3 install splinter pytest-bdd diff --git a/.ci/Dockerfile.gitlabci.dockerignore b/.ci/Dockerfile.gitlabci.dockerignore new file mode 100644 index 000000000..89ddad767 --- /dev/null +++ b/.ci/Dockerfile.gitlabci.dockerignore @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later + +**/.git +**/.container +**/.vagrant +**/.ci +**/functional_tests +**/doc +**/build +**/static diff --git a/.ci/update-gitlabci-docker-image.sh b/.ci/update-gitlabci-docker-image.sh index 4143610b9..9ada7724d 100755 --- a/.ci/update-gitlabci-docker-image.sh +++ b/.ci/update-gitlabci-docker-image.sh @@ -1,9 +1,8 @@ #! /bin/bash # SPDX-License-Identifier: AGPL-3.0-or-later -# Provide your Salsa credentials here docker login registry.salsa.debian.org -# This might need 20 minutes to run -docker build -t registry.salsa.debian.org/freedombox-team/freedombox:gitlabci -f .ci/Dockerfile.gitlabci . +# Build and upload a new image to the container registry +DOCKER_BUILDKIT=1 docker build -t registry.salsa.debian.org/freedombox-team/freedombox:gitlabci -f .ci/Dockerfile.gitlabci . docker push registry.salsa.debian.org/freedombox-team/freedombox:gitlabci