use `base` container for SDKs/IBs

This way not every SDK/IB build installs all dependencies via `apt` but
rather pulls in a container.

Signed-off-by: Paul Spooren <mail@aparcar.org>
pull/79/head
Paul Spooren 2021-03-18 09:12:57 -10:00
parent ba196c53ad
commit 53846dccff
5 changed files with 52 additions and 31 deletions

View File

@ -9,7 +9,7 @@ include:
stages:
- pre-build
- build-deploy-container
- build-work-containers
- build
- test
- generate_targets
@ -18,6 +18,9 @@ stages:
build deploy container:
extends: .build-deploy-container
build base container:
extends: .build-base-container
check scripts with shellcheck:
stage: pre-build
extends: .openwrt-shellcheck

View File

@ -1,6 +1,6 @@
.build-deploy-container:
image: docker:latest
stage: build-deploy-container
stage: build-work-containers
services:
- docker:dind
script:
@ -8,6 +8,16 @@
- docker build -t "$CI_REGISTRY_IMAGE:deploy" -f Dockerfile.deploy .
- docker push "$CI_REGISTRY_IMAGE:deploy"
.build-base-container:
image: docker:latest
stage: build-work-containers
services:
- docker:dind
script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
- docker build -t "$CI_REGISTRY_IMAGE:base" -f Dockerfile.base .
- docker push "$CI_REGISTRY_IMAGE:base"
.build:
image: "$CI_REGISTRY_IMAGE:deploy"
stage: build

View File

@ -1,37 +1,12 @@
FROM debian:latest
ARG CI_REGISTRY_IMAGE
FROM $CI_REGISTRY_IMAGE:base
MAINTAINER Paul Spooren <mail@aparcar.org>
RUN apt-get update -qq &&\
apt-get install -y \
build-essential \
clang \
curl \
file \
gawk \
gcc-multilib \
gettext \
git \
libncurses5-dev \
libssl-dev \
python2.7 \
python3 \
rsync \
subversion \
sudo \
swig \
unzip \
wget \
zlib1g-dev \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
RUN useradd -c "OpenWrt Builder" -m -d /home/build -G sudo -s /bin/bash build
COPY --chown=build:build . /home/build/openwrt/
RUN chown build:build /home/build/openwrt/
USER build
ENV HOME /home/build
WORKDIR /home/build/openwrt/

29
Dockerfile.base 100644
View File

@ -0,0 +1,29 @@
FROM debian:10
RUN apt-get update -qq &&\
apt-get install -y \
build-essential \
clang \
curl \
file \
gawk \
gcc-multilib \
gettext \
git \
libncurses5-dev \
libssl-dev \
python2.7 \
python3 \
rsync \
subversion \
sudo \
swig \
unzip \
wget \
zlib1g-dev \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
RUN useradd -c "OpenWrt Builder" -m -d /home/build -G sudo -s /bin/bash build

View File

@ -6,7 +6,11 @@ set -ex
# See https://github.com/docker/cli/pull/886
cp "$DOCKERFILE" ./build/Dockerfile
TMP_IMAGE_NAME=$(tr -dc '[:lower:]' </dev/urandom | fold -w 32 | head -n 1)
docker build -t "$TMP_IMAGE_NAME" -f "./build/Dockerfile" ./build
docker build \
--build-arg CI_REGISTRY_IMAGE \
--file "./build/Dockerfile" \
--tag "$TMP_IMAGE_NAME" \
./build
for IMAGE in $DOCKER_IMAGE; do
if [ "$TYPE" = "imagebuilder" ] || [ "$TYPE" = "rootfs" ]; then