SUSE / container-suseconnect

Provides access to repositories inside containers using the host entitlements
Apache License 2.0
19 stars 16 forks source link

Building images with container-suseconnect takes way too long... #53

Open Gagrio opened 3 years ago

Gagrio commented 3 years ago

Hi, I noticed that building images with container-suseconnect can take a very long time

Example:

ENV ADDITIONAL_MODULES sle-module-basesystem,sle-module-development-tools

RUN --mount=type=secret,id=SCCcredentials,required \ zypper --non-interactive up && \ zypper --non-interactive in git


- Build command:
`DOCKER_BUILDKIT=1 docker image build --pull --secret id=SCCcredentials,src=SCCcredentials -t reg-build .` (already had credentials pulled)

[+] Building 3386.3s (4/6)
[+] Building 3386.5s (4/6)
[+] Building 338[+] Building 4206.6s (4/6)
[+] Building 4551.4s (5/6)

In this particular case the build failed because I had not add the `sle-development-tools` module, but still took about an hour to do so, spending most of it to build and add repos...

>5 4550.9 No provider of 'git' found.

Thank you!
Gagrio commented 3 years ago

Getting too long...

Finally finished:

Gagrio commented 3 years ago

More tests:

DOCKER_BUILDKIT=1 docker image build --pull --secret id=SCCcredentials,src=SCCcredentials -t suse-wiki .
[+] Building 13907.2s (8/8) FINISHED                                                                                                                                         
 => [internal] load build definition from Dockerfile                                                                                                                    0.0s
 => => transferring dockerfile: 739B                                                                                                                                    0.0s
 => [internal] load .dockerignore                                                                                                                                       0.0s
 => => transferring context: 2B                                                                                                                                         0.0s
 => [internal] load metadata for registry.suse.com/suse/sle15:latest                                                                                                    0.5s
 => CACHED [1/4] FROM registry.suse.com/suse/sle15:latest@sha256:2847fe882f8f22a70acb4d24039705b224ea22c4ffa3cc4ca88ae226bc9e9d63                                       0.0s
 => [2/4] RUN --mount=type=secret,id=SCCcredentials,required     zypper --non-interactive up &&     zypper --non-interactive install git &&     zypper --non-inter  13898.4s
 => [3/4] RUN wget https://github.com/wikimedia/mediawiki/archive/refs/heads/REL1_26.zip                                                                                5.4s
 => [4/4] RUN unzip -a REL1_26.zip                                                                                                                                      1.3s 
 => exporting to image                                                                                                                                                  1.4s 
 => => exporting layers                                                                                                                                                 1.4s 
 => => writing image sha256:5e3a6947fa9ce6b8076b9010761cdc0e98e00feda0376606688d604b8609ac21                                                                            0.0s 
 => => naming to docker.io/library/suse-wiki  
# syntax=docker/dockerfile:experimental
FROM registry.suse.com/suse/sle15:latest

LABEL description="SUSE Linux Image with Mediawiki 1.26"

ENV ADDITIONAL_MODULES sle-module-basesystem,sle-module-development-tools

RUN --mount=type=secret,id=SCCcredentials,required \
    zypper --non-interactive up && \
    zypper --non-interactive install git && \
    zypper --non-interactive install wget && \
    zypper --non-interactive install unzip

# Download Mediawiki from GitHub
RUN wget https://github.com/wikimedia/mediawiki/archive/refs/heads/REL1_26.zip

RUN unzip -a REL1_26.zip
alexandrevicenzi commented 6 months ago

I'm not able to reproduce this.

One potential issue could be the zypper up command, which triggers packages to be installed, and this might take a while.

container-suseconnect connects to the SCC API and refreshes the repositories, this is often fast (few seconds). From there, zypper refreshes repositories and installs packages, which can take time.