-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tooling: Use buildkit frontend for building Docker images
The buildkit tooling is part of the standard Docker installation and can be activated by specifying DOCKER_BUILDKIT=1 in the environment. - Buildkit allows us to authenticate in a build temporarily without leaking authentication information in the Docker images. - Buildkit allows us to leverage ccache for all image builds, reducing compilation duration. - Buildkit allows us to mount directories from other Docker images, allowing us to build a VTD package from within the build process without needing to copy the sources into the image at any point. The only downside with the buildkit tooling is that it is not possible to docker exec on intermediate layers.
- Loading branch information
Showing
10 changed files
with
336 additions
and
311 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
.env | ||
setup.sh |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,71 @@ | ||
# syntax = docker/dockerfile:1.2-labs | ||
# Dockerfile.archlinux | ||
# | ||
# See Dockerfile.focal for documentation of each of the lines. | ||
ARG BUILD_FROM=archlinux:latest | ||
ARG DEPLOY_FROM=${BUILD_FROM} | ||
|
||
FROM ${BUILD_FROM} AS build | ||
FROM archlinux:latest | ||
|
||
# Install System Packages | ||
COPY Makefile.setup /cloe/Makefile.setup | ||
RUN pacman -Syu --noconfirm --needed make && \ | ||
RUN pacman -Syu --noconfirm --needed make ccache && \ | ||
make -f /cloe/Makefile.setup \ | ||
WITHOUT_DEV_DEPS=yes \ | ||
PACMAN_ARGS="--noconfirm --needed" \ | ||
install-system-deps \ | ||
&& \ | ||
locale-gen en_US.UTF-8 && \ | ||
locale-gen && \ | ||
pacman -Scc --noconfirm | ||
|
||
ENV LANG=C.UTF-8 | ||
ENV LC_ALL=C.UTF-8 | ||
ENV CCACHE_DIR=/ccache | ||
ENV PATH=/usr/lib/ccache:$PATH | ||
|
||
RUN pip3 install --upgrade pip && \ | ||
make -f /cloe/Makefile.setup \ | ||
PIP_INSTALL_ARGS="" \ | ||
install-python-deps | ||
|
||
# Install and Setup Conan | ||
ARG CONAN_REMOTE=https://conan.bintray.com | ||
ARG CONAN_REMOTE_VERIFY_SSL=true | ||
ARG CONAN_LOGIN_USERNAME | ||
ARG CONAN_PASSWORD | ||
ARG BUILD_TYPE=RelWithDebInfo | ||
RUN conan profile new --detect default && \ | ||
conan profile update settings.compiler.libcxx=libstdc++11 default && \ | ||
conan config set general.request_timeout=360 && \ | ||
conan remote clean && \ | ||
conan remote add default ${CONAN_REMOTE} ${CONAN_REMOTE_VERIFY_SSL} | ||
conan profile update settings.build_type=${BUILD_TYPE} default && \ | ||
conan profile update settings.compiler.libcxx=libstdc++11 default | ||
|
||
ENV CONAN_NON_INTERACTIVE=yes | ||
|
||
# Build and Install Cloe | ||
WORKDIR /cloe | ||
COPY . /cloe | ||
ARG WITH_VTD=0 | ||
ARG PACKAGE_TARGET=package-select | ||
RUN export CONAN_NON_INTERACTIVE=yes && \ | ||
if [ ${CONAN_LOGIN_USERNAME} != "" ]; then \ | ||
CONAN_LOGIN_USERNAME="${CONAN_LOGIN_USERNAME}" CONAN_PASSWORD="${CONAN_PASSWORD}" conan user --remote=default -p || exit 1; \ | ||
fi && \ | ||
make export-vendor export && \ | ||
|
||
# Download or build dependencies: | ||
COPY vendor /cloe/vendor | ||
COPY Makefile.package /cloe | ||
COPY Makefile.all /cloe | ||
ARG VENDOR_TARGET="export-vendor download-vendor" | ||
RUN --mount=type=cache,target=/ccache \ | ||
--mount=type=bind,target=/cloe/vendor/vtd/vires,from=cloe/vtd-sources:2.2.0 \ | ||
--mount=type=secret,target=/root/setup.sh,id=setup,mode=0400 \ | ||
if [ -r /root/setup.sh ]; then . /root/setup.sh; fi && \ | ||
make -f Makefile.all WITH_VTD=${WITH_VTD} ${VENDOR_TARGET} && \ | ||
# Clean up: | ||
find /root/.conan/data -name dl -type d -maxdepth 5 -exec rm -r {} + && \ | ||
conan remove \* -s -b -f && \ | ||
conan user --clean | ||
|
||
# Build Cloe. | ||
COPY . /cloe | ||
ARG PACKAGE_TARGET=package-auto | ||
RUN --mount=type=cache,target=/ccache \ | ||
--mount=type=secret,target=/root/setup.sh,id=setup,mode=0400 \ | ||
if [ -r /root/setup.sh ]; then . /root/setup.sh; fi && \ | ||
make WITH_VTD=${WITH_VTD} ${PACKAGE_TARGET} && \ | ||
conan remove \* -b -f && \ | ||
# Clean up: | ||
find /root/.conan/data -name dl -type d -maxdepth 5 -exec rm -r {} + && \ | ||
conan remove \* -s -b -f && \ | ||
conan user --clean | ||
|
||
ARG VI_LIC_SERVER | ||
RUN export LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ | ||
export VI_LIC_SERVER="${VI_LIC_SERVER}" && \ | ||
make WITH_VTD=${WITH_VTD} smoketest && \ | ||
make WITH_VTD=${WITH_VTD} INSTALL_DIR="/deploy" deploy | ||
|
||
# Create Deploy Image | ||
FROM ${DEPLOY_FROM} | ||
COPY --from=build /deploy /usr/local/ | ||
ENV LD_LIBRARY_PATH=/usr/local/lib | ||
ENTRYPOINT [ "cloe-engine" ] | ||
# Run smoketests. | ||
RUN --mount=type=secret,target=/root/setup.sh,id=setup,mode=0400 \ | ||
--network=default \ | ||
if [ -r /root/setup.sh ]; then . /root/setup.sh; fi && \ | ||
make WITH_VTD=${WITH_VTD} smoketest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,75 @@ | ||
# syntax = docker/dockerfile:1.2-labs | ||
# Dockerfile.bionic | ||
# | ||
# See Dockerfile.focal for documentation of each of the lines. | ||
ARG BUILD_FROM=ubuntu:18.04 | ||
ARG DEPLOY_FROM=${BUILD_FROM} | ||
|
||
FROM ${BUILD_FROM} AS build | ||
FROM ubuntu:18.04 | ||
|
||
# Install System Packages | ||
COPY Makefile.setup /cloe/Makefile.setup | ||
RUN apt-get update && \ | ||
apt-get install -y make locales && \ | ||
RUN --mount=type=cache,id=bionic-cache,target=/var/cache/apt \ | ||
--mount=type=cache,id=bionic-lib,target=/var/lib/apt \ | ||
apt-get update && \ | ||
apt-get install -y make ccache locales libbsd0 && \ | ||
make -f /cloe/Makefile.setup \ | ||
WITHOUT_DEV_DEPS=yes \ | ||
DEBIAN_FRONTEND=noninteractive \ | ||
APT_ARGS="--no-install-recommends -y" \ | ||
install-system-deps \ | ||
&& \ | ||
locale-gen en_US.UTF-8 && \ | ||
locale-gen && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
ENV LANG=C.UTF-8 | ||
ENV LC_ALL=C.UTF-8 | ||
ENV CCACHE_DIR=/ccache | ||
ENV PATH=/usr/lib/ccache:$PATH | ||
|
||
RUN pip3 install --upgrade pip && \ | ||
make -f /cloe/Makefile.setup \ | ||
PIP_INSTALL_ARGS="" \ | ||
install-python-deps | ||
|
||
# Install and Setup Conan | ||
ARG CONAN_REMOTE=https://conan.bintray.com | ||
ARG CONAN_REMOTE_VERIFY_SSL=true | ||
ARG CONAN_LOGIN_USERNAME | ||
ARG CONAN_PASSWORD | ||
ARG BUILD_TYPE=RelWithDebInfo | ||
RUN conan profile new --detect default && \ | ||
conan profile update settings.compiler.libcxx=libstdc++11 default && \ | ||
conan config set general.request_timeout=360 && \ | ||
conan remote clean && \ | ||
conan remote add default ${CONAN_REMOTE} ${CONAN_REMOTE_VERIFY_SSL} | ||
conan profile update settings.build_type=${BUILD_TYPE} default && \ | ||
conan profile update settings.compiler.libcxx=libstdc++11 default | ||
|
||
ENV CONAN_NON_INTERACTIVE=yes | ||
|
||
# Build and Install Cloe | ||
WORKDIR /cloe | ||
COPY . /cloe | ||
ARG WITH_VTD=0 | ||
ARG PACKAGE_TARGET=package-select | ||
RUN export CONAN_NON_INTERACTIVE=yes && \ | ||
if [ ${CONAN_LOGIN_USERNAME} != "" ]; then \ | ||
CONAN_LOGIN_USERNAME="${CONAN_LOGIN_USERNAME}" CONAN_PASSWORD="${CONAN_PASSWORD}" conan user --remote=default -p || exit 1; \ | ||
fi && \ | ||
make export-vendor export && \ | ||
|
||
# Download or build dependencies: | ||
COPY vendor /cloe/vendor | ||
COPY Makefile.package /cloe | ||
COPY Makefile.all /cloe | ||
ARG VENDOR_TARGET="export-vendor download-vendor" | ||
RUN --mount=type=cache,target=/ccache \ | ||
--mount=type=bind,target=/cloe/vendor/vtd/vires,from=cloe/vtd-sources:2.2.0 \ | ||
--mount=type=secret,target=/root/setup.sh,id=setup,mode=0400 \ | ||
if [ -r /root/setup.sh ]; then . /root/setup.sh; fi && \ | ||
make -f Makefile.all WITH_VTD=${WITH_VTD} ${VENDOR_TARGET} && \ | ||
# Clean up: | ||
find /root/.conan/data -name dl -type d -maxdepth 5 -exec rm -r {} + && \ | ||
conan remove \* -s -b -f && \ | ||
conan user --clean | ||
|
||
# Build Cloe. | ||
COPY . /cloe | ||
ARG PACKAGE_TARGET=package-auto | ||
RUN --mount=type=cache,target=/ccache \ | ||
--mount=type=secret,target=/root/setup.sh,id=setup,mode=0400 \ | ||
if [ -r /root/setup.sh ]; then . /root/setup.sh; fi && \ | ||
make WITH_VTD=${WITH_VTD} ${PACKAGE_TARGET} && \ | ||
conan remove \* -b -f && \ | ||
# Clean up: | ||
find /root/.conan/data -name dl -type d -maxdepth 5 -exec rm -r {} + && \ | ||
conan remove \* -s -b -f && \ | ||
conan user --clean | ||
|
||
ARG VI_LIC_SERVER | ||
RUN export LC_ALL=C.UTF-8 LANG=C.UTF-8 && \ | ||
export VI_LIC_SERVER="${VI_LIC_SERVER}" && \ | ||
make WITH_VTD=${WITH_VTD} smoketest && \ | ||
make WITH_VTD=${WITH_VTD} INSTALL_DIR="/deploy" deploy | ||
|
||
# Create Deploy Image | ||
FROM ${DEPLOY_FROM} | ||
COPY --from=build /deploy /usr/local/ | ||
ENV LD_LIBRARY_PATH=/usr/local/lib | ||
ENTRYPOINT [ "cloe-engine" ] | ||
# Run smoketests. | ||
RUN --mount=type=secret,target=/root/setup.sh,id=setup,mode=0400 \ | ||
--network=default \ | ||
if [ -r /root/setup.sh ]; then . /root/setup.sh; fi && \ | ||
make WITH_VTD=${WITH_VTD} smoketest |
Oops, something went wrong.