Skip to content

Commit 2bd67c8

Browse files
committed
tooling: Add authentication and extra parameters to Dockerfiles
1 parent 5693d31 commit 2bd67c8

File tree

6 files changed

+133
-92
lines changed

6 files changed

+133
-92
lines changed

dist/docker/Dockerfile.archlinux

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Dockerfile.archlinux
22
#
3-
# See Dockerfile.ubuntu for documentation of each of the lines.
3+
# See Dockerfile.focal for documentation of each of the lines.
44
ARG BUILD_FROM=archlinux:latest
55
ARG DEPLOY_FROM=${BUILD_FROM}
66

@@ -25,6 +25,8 @@ RUN pip3 install --upgrade pip && \
2525
# Install and Setup Conan
2626
ARG CONAN_REMOTE=https://conan.bintray.com
2727
ARG CONAN_REMOTE_VERIFY_SSL=true
28+
ARG CONAN_LOGIN_USERNAME
29+
ARG CONAN_PASSWORD
2830
RUN conan profile new --detect default && \
2931
conan profile update settings.compiler.libcxx=libstdc++11 default && \
3032
conan config set general.request_timeout=360 && \
@@ -36,12 +38,19 @@ WORKDIR /cloe
3638
COPY . /cloe
3739
ARG WITH_VTD=0
3840
ARG PACKAGE_TARGET=package-select
39-
RUN make export-vendor export && \
41+
RUN export CONAN_NON_INTERACTIVE=yes && \
42+
if [ ${CONAN_LOGIN_USERNAME} != "" ]; then \
43+
CONAN_LOGIN_USERNAME="${CONAN_LOGIN_USERNAME}" CONAN_PASSWORD="${CONAN_PASSWORD}" conan user --remote=default -p || exit 1; \
44+
fi && \
45+
make export-vendor export && \
4046
make WITH_VTD=${WITH_VTD} ${PACKAGE_TARGET} && \
41-
export LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \
42-
conan remove \* -b -f
47+
conan remove \* -b -f && \
48+
conan user --clean
4349

44-
RUN make WITH_VTD=${WITH_VTD} smoketest && \
50+
ARG VI_LIC_SERVER
51+
RUN export LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \
52+
export VI_LIC_SERVER="${VI_LIC_SERVER}" && \
53+
make WITH_VTD=${WITH_VTD} smoketest && \
4554
make WITH_VTD=${WITH_VTD} INSTALL_DIR="/deploy" deploy
4655

4756
# Create Deploy Image

dist/docker/Dockerfile.bionic

+13-40
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
1-
# Dockerfile.ubuntu
1+
# Dockerfile.bionic
22
#
3-
# This file acts partly as a Docker recipe for building Cloe on Ubuntu.
4-
# It is currently only tested with Ubuntu 18.04 and 20.04.
5-
#
6-
# If you are behind a proxy, make sure to pass in the respective HTTP_PROXY,
7-
# HTTPS_PROXY, and NO_PROXY variables.
3+
# See Dockerfile.focal for documentation of each of the lines.
84
ARG BUILD_FROM=ubuntu:18.04
95
ARG DEPLOY_FROM=${BUILD_FROM}
106

117
FROM ${BUILD_FROM} AS build
128

139
# Install System Packages
14-
#
15-
# These packages are required for building and testing Cloe.
1610
COPY Makefile.setup /cloe/Makefile.setup
1711
RUN apt-get update && \
1812
apt-get install -y make locales && \
@@ -31,58 +25,37 @@ RUN pip3 install --upgrade pip && \
3125
install-python-deps
3226

3327
# Install and Setup Conan
34-
#
35-
# You may not want to use the default Conan remote (conan-center), so we use
36-
# whatever is stored in the build arguments CONAN_REMOTE. Currently, only
37-
# anonymous access is possible in this Dockerfile.
3828
ARG CONAN_REMOTE=https://conan.bintray.com
3929
ARG CONAN_REMOTE_VERIFY_SSL=true
30+
ARG CONAN_LOGIN_USERNAME
31+
ARG CONAN_PASSWORD
4032
RUN conan profile new --detect default && \
4133
conan profile update settings.compiler.libcxx=libstdc++11 default && \
4234
conan config set general.request_timeout=360 && \
4335
conan remote clean && \
4436
conan remote add default ${CONAN_REMOTE} ${CONAN_REMOTE_VERIFY_SSL}
4537

4638
# Build and Install Cloe
47-
#
48-
# All common processes are made easy to apply by writing target recipes in the
49-
# Makefile at the root of the repository. This also acts as a form of
50-
# documentation.
5139
WORKDIR /cloe
5240
COPY . /cloe
5341
ARG WITH_VTD=0
5442
ARG PACKAGE_TARGET=package-select
55-
RUN \
56-
# Export our own Conan recipes, in case they are not available in the
57-
# CONAN_REMOTE specified above.
43+
RUN export CONAN_NON_INTERACTIVE=yes && \
44+
if [ ${CONAN_LOGIN_USERNAME} != "" ]; then \
45+
CONAN_LOGIN_USERNAME="${CONAN_LOGIN_USERNAME}" CONAN_PASSWORD="${CONAN_PASSWORD}" conan user --remote=default -p || exit 1; \
46+
fi && \
5847
make export-vendor export && \
59-
# Build all the packages, except for vtd, because that currently requires
60-
# dependencies we don't have in the Docker container.
61-
# You can specify more than one package here, see the Makefile for more
62-
# information on the WITH_*, PACKAGES, NOBUILD_PKGS, and BUILD_PKGS variables.
6348
make WITH_VTD=${WITH_VTD} ${PACKAGE_TARGET} && \
64-
# In the above commands, Conan downloads and creates packages into its
65-
# local cache. We don't need the build directories, since we have deployed
66-
# Cloe, so we should clean up to keep the Docker image down.
67-
conan remove \* -b -f
49+
conan remove \* -b -f && \
50+
conan user --clean
6851

69-
RUN \
70-
# Run smoketests.
71-
export LC_ALL=C.UTF-8 LANG=C.UTF-8 && \
52+
ARG VI_LIC_SERVER
53+
RUN export LC_ALL=C.UTF-8 LANG=C.UTF-8 && \
54+
export VI_LIC_SERVER="${VI_LIC_SERVER}" && \
7255
make WITH_VTD=${WITH_VTD} smoketest && \
73-
# Deploy all the Cloe packages to INSTALL_DIR, which is /usr/local by
74-
# default. This will also populate BUILD_DIR, so that should be removed
75-
# afterwards to prevent this image from getting too big.
7656
make WITH_VTD=${WITH_VTD} INSTALL_DIR="/deploy" deploy
7757

7858
# Create Deploy Image
79-
#
80-
# Unfortunately, there are still some issues with cloe-engine not finding
81-
# libcloe-runtime.so, so we need to explicitly set LD_LIBRARY_PATH.
82-
#
83-
# This image can now be used to work with stack files. You should mount in
84-
# whatever directory contains your stack files for best results, otherwise
85-
# the engine might try to read files that it doesn't have in its own filesystem.
8659
FROM ${DEPLOY_FROM}
8760
COPY --from=build /deploy /usr/local/
8861
ENV LD_LIBRARY_PATH=/usr/local/lib

dist/docker/Dockerfile.focal

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
# Dockerfile.ubuntu
1+
# Dockerfile.focal
22
#
33
# This file acts partly as a Docker recipe for building Cloe on Ubuntu.
4-
# It is currently only tested with Ubuntu 18.04 and 20.04.
54
#
65
# If you are behind a proxy, make sure to pass in the respective HTTP_PROXY,
76
# HTTPS_PROXY, and NO_PROXY variables.
@@ -37,6 +36,8 @@ RUN pip3 install --upgrade pip && \
3736
# anonymous access is possible in this Dockerfile.
3837
ARG CONAN_REMOTE=https://conan.bintray.com
3938
ARG CONAN_REMOTE_VERIFY_SSL=true
39+
ARG CONAN_LOGIN_USERNAME
40+
ARG CONAN_PASSWORD
4041
RUN conan profile new --detect default && \
4142
conan profile update settings.compiler.libcxx=libstdc++11 default && \
4243
conan config set general.request_timeout=360 && \
@@ -53,6 +54,10 @@ COPY . /cloe
5354
ARG WITH_VTD=0
5455
ARG PACKAGE_TARGET=package-select
5556
RUN \
57+
export CONAN_NON_INTERACTIVE=yes && \
58+
if [ ${CONAN_LOGIN_USERNAME} != "" ]; then \
59+
CONAN_LOGIN_USERNAME="${CONAN_LOGIN_USERNAME}" CONAN_PASSWORD="${CONAN_PASSWORD}" conan user --remote=default -p || exit 1; \
60+
fi && \
5661
# Export our own Conan recipes, in case they are not available in the
5762
# CONAN_REMOTE specified above.
5863
make export-vendor export && \
@@ -64,11 +69,14 @@ RUN \
6469
# In the above commands, Conan downloads and creates packages into its
6570
# local cache. We don't need the build directories, since we have deployed
6671
# Cloe, so we should clean up to keep the Docker image down.
67-
conan remove \* -b -f
72+
conan remove \* -b -f && \
73+
conan user --clean
6874

75+
ARG VI_LIC_SERVER
6976
RUN \
7077
# Run smoketests.
7178
export LC_ALL=C.UTF-8 LANG=C.UTF-8 && \
79+
export VI_LIC_SERVER="${VI_LIC_SERVER}" && \
7280
make WITH_VTD=${WITH_VTD} smoketest && \
7381
# Deploy all the Cloe packages to INSTALL_DIR, which is /usr/local by
7482
# default. This will also populate BUILD_DIR, so that should be removed

dist/docker/Dockerfile.xenial

+12-38
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
# Dockerfile.ubuntu
1+
# Dockerfile.xenial
22
#
3-
# This file acts partly as a Docker recipe for building Cloe on Ubuntu.
4-
# It is currently only tested with Ubuntu 16.04.
5-
#
6-
# If you are behind a proxy, make sure to pass in the respective HTTP_PROXY,
7-
# HTTPS_PROXY, and NO_PROXY variables.
3+
# See Dockerfile.focal for documentation of each of the lines.
84
ARG BUILD_FROM=ubuntu:16.04
95
ARG DEPLOY_FROM=${BUILD_FROM}
106

@@ -13,7 +9,6 @@ FROM ${BUILD_FROM} AS build
139
# Install Newer CMake and GCC Packages
1410
RUN apt-get update && \
1511
apt-get install --no-install-recommends -y apt-transport-https ca-certificates gnupg software-properties-common wget && \
16-
# Add cmake repository:
1712
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - > /etc/apt/trusted.gpg.d/kitware.gpg && \
1813
apt-add-repository "deb https://apt.kitware.com/ubuntu/ xenial main" && \
1914
add-apt-repository "ppa:ubuntu-toolchain-r/test" && \
@@ -58,8 +53,6 @@ RUN . /etc/profile.d/pyenv.sh && \
5853
pyenv global ${PYTHON_VERSION}
5954

6055
# Install System Packages
61-
#
62-
# These packages are required for building and testing Cloe.
6356
COPY Makefile.setup /cloe/Makefile.setup
6457
RUN apt-get update && \
6558
apt-get install -y make locales && \
@@ -79,12 +72,10 @@ RUN . /etc/profile.d/pyenv.sh && \
7972
install-python-deps
8073

8174
# Install and Setup Conan
82-
#
83-
# You may not want to use the default Conan remote (conan-center), so we use
84-
# whatever is stored in the build arguments CONAN_REMOTE. Currently, only
85-
# anonymous access is possible in this Dockerfile.
8675
ARG CONAN_REMOTE=https://conan.bintray.com
8776
ARG CONAN_REMOTE_VERIFY_SSL=true
77+
ARG CONAN_LOGIN_USERNAME
78+
ARG CONAN_PASSWORD
8879
RUN . /etc/profile.d/pyenv.sh && \
8980
conan profile new --detect default && \
9081
conan profile update settings.compiler.libcxx=libstdc++11 default && \
@@ -93,45 +84,28 @@ RUN . /etc/profile.d/pyenv.sh && \
9384
conan remote add default ${CONAN_REMOTE} ${CONAN_REMOTE_VERIFY_SSL}
9485

9586
# Build and Install Cloe
96-
#
97-
# All common processes are made easy to apply by writing target recipes in the
98-
# Makefile at the root of the repository. This also acts as a form of
99-
# documentation.
10087
WORKDIR /cloe
10188
COPY . /cloe
10289
ARG WITH_VTD=0
10390
ARG PACKAGE_TARGET=package-select
10491
RUN . /etc/profile.d/pyenv.sh && \
105-
# Export our own Conan recipes, in case they are not available in the
106-
# CONAN_REMOTE specified above.
92+
export CONAN_NON_INTERACTIVE=yes && \
93+
if [ ${CONAN_LOGIN_USERNAME} != "" ]; then \
94+
CONAN_LOGIN_USERNAME="${CONAN_LOGIN_USERNAME}" CONAN_PASSWORD="${CONAN_PASSWORD}" conan user --remote=default -p || exit 1; \
95+
fi && \
10796
make export-vendor export && \
108-
# Build all the packages, except for vtd, because that currently requires
109-
# dependencies we don't have in the Docker container.
110-
# You can specify more than one package here, see the Makefile for more
111-
# information on the WITH_*, PACKAGES, NOBUILD_PKGS, and BUILD_PKGS variables.
11297
make WITH_VTD=${WITH_VTD} ${PACKAGE_TARGET} && \
113-
# In the above commands, Conan downloads and creates packages into its
114-
# local cache. We don't need the build directories, since we have deployed
115-
# Cloe, so we should clean up to keep the Docker image down.
116-
conan remove \* -b -f
98+
conan remove \* -b -f && \
99+
conan user --clean
117100

101+
ARG VI_LIC_SERVER
118102
RUN . /etc/profile.d/pyenv.sh && \
119-
# Run smoketests.
120103
export LC_ALL=C.UTF-8 LANG=C.UTF-8 && \
104+
export VI_LIC_SERVER="${VI_LIC_SERVER}" && \
121105
make WITH_VTD=${WITH_VTD} smoketest && \
122-
# Deploy all the Cloe packages to INSTALL_DIR, which is /usr/local by
123-
# default. This will also populate BUILD_DIR, so that should be removed
124-
# afterwards to prevent this image from getting too big.
125106
make WITH_VTD=${WITH_VTD} INSTALL_DIR="/deploy" deploy
126107

127108
# Create Deploy Image
128-
#
129-
# Unfortunately, there are still some issues with cloe-engine not finding
130-
# libcloe-runtime.so, so we need to explicitly set LD_LIBRARY_PATH.
131-
#
132-
# This image can now be used to work with stack files. You should mount in
133-
# whatever directory contains your stack files for best results, otherwise
134-
# the engine might try to read files that it doesn't have in its own filesystem.
135109
FROM ${DEPLOY_FROM}
136110
COPY --from=build /deploy /usr/local/
137111
ENV LD_LIBRARY_PATH=/usr/local/lib

dist/docker/Makefile

+25-6
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ CLOE_VERSION := $(shell cat ${CLOE_ROOT}/VERSION)
77
DOCKER_NETWORK := \
88
$(shell \
99
if [ -n $$https_proxy ]; then \
10+
echo " --network=host"; \
1011
echo " --build-arg https_proxy=\"$$https_proxy\""; \
1112
echo " --build-arg http_proxy=\"$$http_proxy\""; \
1213
echo " --build-arg no_proxy=\"$$no_proxy\""; \
13-
echo " --network=host"; \
1414
fi \
1515
)
1616

@@ -19,20 +19,39 @@ IMAGE_VERSION := ${CLOE_VERSION}
1919
DOCKER_IMAGE := ${IMAGE_BASE}:${IMAGE_VERSION}
2020
DOCKER_CONTEXT := ${CLOE_ROOT}
2121

22-
DOCKER_BUILD_ARGS += ${DOCKER_NETWORK}
22+
# Default build arguments
23+
PACKAGE_TARGET := package-select
24+
BUILD_TYPE := Release
25+
WITH_VTD := 0
26+
VI_LIC_SERVER :=
2327

2428
# Read extra build arguments from the .env file.
2529
# The .env file is in .gitignore so the user can write their overrides there.
2630
# This is currently primarily used so that the user can set their preferred
2731
# Conan remote with the variables CONAN_REMOTE and CONAN_REMOTE_VERIFY_SSL.
2832
-include .env
2933

34+
DOCKER_BUILD_ARGS += ${DOCKER_NETWORK}
35+
3036
ifneq (${CONAN_REMOTE},)
31-
DOCKER_BUILD_ARGS += \
32-
--build-arg CONAN_REMOTE="${CONAN_REMOTE}" \
33-
--build-arg CONAN_REMOTE_VERIFY_SSL="${CONAN_REMOTE_VERIFY_SSL}"
37+
DOCKER_BUILD_ARGS += --build-arg CONAN_REMOTE="${CONAN_REMOTE}"
38+
DOCKER_BUILD_ARGS += --build-arg CONAN_REMOTE_VERIFY_SSL="${CONAN_REMOTE_VERIFY_SSL}"
3439
endif
35-
DOCKER_ARGS = $(shell echo "${DOCKER_BUILD_ARGS}" | sed -r 's/\s+/ /g')
40+
41+
ifneq (${CONAN_LOGIN_USERNAME},)
42+
DOCKER_BUILD_ARGS += --build-arg CONAN_LOGIN_USERNAME="${CONAN_LOGIN_USERNAME}"
43+
DOCKER_BUILD_ARGS += --build-arg CONAN_PASSWORD="${CONAN_PASSWORD}"
44+
endif
45+
46+
DOCKER_BUILD_ARGS += --build-arg PACKAGE_TARGET=${PACKAGE_TARGET}
47+
48+
ifeq (${WITH_VTD},1)
49+
DOCKER_IMAGE := ${DOCKER_IMAGE}-vtd
50+
DOCKER_BUILD_ARGS += --build-arg WITH_VTD=${WITH_VTD}
51+
DOCKER_BUILD_ARGS += --build-arg VI_LIC_SERVER="${VI_LIC_SERVER}"
52+
endif
53+
54+
DOCKER_ARGS := ${DOCKER_BUILD_ARGS}
3655

3756
.PHONY: help
3857
.DEFAULT: help

dist/docker/README.md

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
Cloe Docker Images
2+
==================
3+
4+
This directory contains Dockerfiles to build Cloe Conan packages in various
5+
environments. We use a Makefile to automate the build process as much as
6+
possible. Run `make help` to see a list of the available targets.
7+
8+
```console
9+
$ make help
10+
Usage: make <target>
11+
12+
Available targets:
13+
all to build all stable docker images
14+
ubuntu-20.04 to build the Ubuntu 20.04 image
15+
ubuntu-18.04 to build the Ubuntu 18.04 image
16+
ubuntu-16.04 to build the Ubuntu 18.04 image
17+
archlinux to build the Archlinux image
18+
alpine to build the Alpine image
19+
20+
Configuration:
21+
IMAGE_BASE: cloe/cloe-engine
22+
IMAGE_VERSION: 0.18.0-nightly
23+
CONAN_REMOTE: https://artifactory.example.com/artifactory/api/conan/cloe
24+
DOCKER_CONTEXT: ../..
25+
DOCKER_ARGS: --network=host
26+
--build-arg https_proxy=http://127.0.0.1:3128/
27+
--build-arg http_proxy=http://127.0.0.1:3128/
28+
--build-arg no_proxy=localhost,127.0.0.1,127.*,172.*,192.168.*,10.*
29+
--build-arg CONAN_REMOTE=https://artifactory.example.com/artifactory/api/conan/cloe
30+
--build-arg CONAN_REMOTE_VERIFY_SSL=True
31+
--build-arg CONAN_LOGIN_USERNAME=cloebuilder
32+
--build-arg CONAN_PASSWORD=secret
33+
--build-arg WITH_VTD=0
34+
--build-arg VI_LIC_SERVER=license-server.example.com
35+
--build-arg PACKAGE_TARGET=package-select
36+
```
37+
38+
The output has been slightly formatted to make the Docker build arguments a
39+
little more obvious. The following build arguments are available:
40+
41+
- `CONAN_REMOTE`: optional string; defaults to conan-center URL.
42+
- `CONAN_REMOTE_VERIFY_SSL`: optional, one of `True` and `False`; defaults to `True`.
43+
- `CONAN_LOGIN_USERNAME`: optional username for authenticating with remote.
44+
- `CONAN_PASSWORD`: optional password, required if username specified.
45+
- `WITH_VTD`: optional, one of `0` and `1`; defaults to `0`.
46+
- `VI_LIC_SERVER`: optional hostname of VTD license server.
47+
- `PACKAGE_TARGET`: optional, one of `package`, `package-select`, and `package-all`;
48+
defaults to `package-select`.
49+
50+
You can specify these arguments on the command line when calling make, or you
51+
can specify them in a `.env` file, which is exempt from version control.
52+
It is recommended to specify the Conan build arguments in the `.env` file, and
53+
the other arguments on the command line. Because of the way the .env file is
54+
read by Make, it is important to not use any quotation marks around the values.
55+
56+
Because Docker images may be built in environments that have a proxy running,
57+
the Makefile will automatically add the proxy variables if they are are
58+
detected in the host environment.

0 commit comments

Comments
 (0)