sonic-buildimage/dockers/docker-sonic-sdk-buildenv/Dockerfile.j2
Kalimuthu-Velappan bc30528341
Parallel building of sonic dockers using native dockerd(dood). (#10352)
Currently, the build dockers are created as a user dockers(docker-base-stretch-<user>, etc) that are
specific to each user. But the sonic dockers (docker-database, docker-swss, etc) are
created with a fixed docker name and common to all the users.

    docker-database:latest
    docker-swss:latest

When multiple builds are triggered on the same build server that creates parallel building issue because
all the build jobs are trying to create the same docker with latest tag.
This happens only when sonic dockers are built using native host dockerd for sonic docker image creation.

This patch creates all sonic dockers as user sonic dockers and then, while
saving and loading the user sonic dockers, it rename the user sonic
dockers into correct sonic dockers with tag as latest.

	docker-database:latest <== SAVE/LOAD ==> docker-database-<user>:tag

The user sonic docker names are derived from 'DOCKER_USERNAME and DOCKER_USERTAG' make env
variable and using Jinja template, it replaces the FROM docker name with correct user sonic docker name for
loading and saving the docker image.
2022-04-28 08:39:37 +08:00

44 lines
1.5 KiB
Django/Jinja
Executable File

{% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %}
FROM sonic-sdk-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}}
ARG base_os_version
ARG docker_database_version
ARG docker_swss_version
ARG docker_syncd_version
ARG image_version
# Make apt-get non-interactive
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -f -y \
build-essential
{% if docker_sonic_sdk_buildenv_debs.strip() -%}
# Copy locally-built Debian package dependencies
{{ copy_files("debs/", docker_sonic_sdk_buildenv_debs.split(' '), "/debs/") }}
# Install locally-built Debian packages and implicitly install their dependencies
{{ install_debian_packages(docker_sonic_sdk_buildenv_debs.split(' ')) }}
{%- endif %}
{% if docker_sonic_sdk_buildenv_whls.strip() %}
# Copy locally-built Python wheel dependencies
{{ copy_files("python-wheels/", docker_sonic_sdk_buildenv_whls.split(' '), "/python-wheels/") }}
# Install locally-built Python wheel dependencies
{{ install_python_wheels(docker_sonic_sdk_buildenv_whls.split(' ')) }}
{% endif %}
# Clean up
RUN apt-get clean -y && \
apt-get autoclean -y && \
apt-get autoremove -y && \
rm -rf /debs /python-wheels/
LABEL com.azure.sonic.sdk.versions.base-os=$base_os_version
LABEL com.azure.sonic.sdk.versions.database=$docker_database_version
LABEL com.azure.sonic.sdk.versions.swss=$docker_swss_version
LABEL com.azure.sonic.sdk.versions.syncd=$docker_syncd_version
LABEL com.azure.sonic.sdk.version.image_hash=$image_version