Skip to content

Commit 4fe270d

Browse files
committedFeb 14, 2024
fix the need to redeclare the VULKAN_VERSION in multiple build stages by introducing global build args and reusing them
and reduced number of ENV declarations using line-breaks
·
v1.0.12v1.0.2
1 parent ffec73d commit 4fe270d

File tree

1 file changed

+32
-19
lines changed

1 file changed

+32
-19
lines changed
 

‎.devcontainer/Dockerfile

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@
1515
#
1616
#
1717

18+
# +-----------------------------+
19+
# | GLOBAL ARGS |
20+
# +-----------------------------+
21+
# To use them, redeclare without value inside each FROM.
22+
# For example, VULKAN_VERSION is used in the FROM sections of "downloader" and "cpp-devbox-with-vulkansdk".
23+
ARG DEBIAN_VERSION=12
24+
ARG DEBIAN_VERSION_NAME=bookworm
25+
ARG GCC_VERSION=13
26+
ARG LLVM_VERSION=17
27+
ARG VULKAN_VERSION=1.3.275.0
28+
1829
# +-----------------------------+
1930
# | Downloader |
2031
# +-----------------------------+
@@ -24,7 +35,8 @@
2435

2536
FROM debian:bookworm-slim as downloader
2637

27-
ARG VULKAN_VERSION=1.3.261.1
38+
# reusing global arg
39+
ARG VULKAN_VERSION
2840

2941
#ENV CURL_OPTIONS "--silent --show-error --retry 5 --connect-timeout 20 --max-time 10"
3042
ENV CURL_OPTIONS_BAR "--progress-bar"
@@ -42,13 +54,13 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
4254
FROM debian:bookworm-slim as cpp-devbox-base
4355

4456
# +-----------------------------+
45-
# | ARGS |
57+
# | REUSE GLOBAL ARGS |
4658
# +-----------------------------+
4759

48-
ARG DEBIAN_VERSION=12
49-
ARG DEBIAN_VERSION_NAME=bookworm
50-
ARG GCC_VERSION=13
51-
ARG LLVM_VERSION=17
60+
ARG DEBIAN_VERSION
61+
ARG DEBIAN_VERSION_NAME
62+
ARG GCC_VERSION
63+
ARG LLVM_VERSION
5264

5365
# +-----------------------------+
5466
# | METADATA |
@@ -182,11 +194,11 @@ RUN version="$(curl -s https://api.github.com/repos/Kitware/CMake/releases/lates
182194
# - We use the installed binaries from the system.
183195
# - We do not download latest version of CMake and Ninja during vcpkg bootstrap.
184196

185-
ENV VCPKG_ROOT=/opt/vcpkg
197+
ENV VCPKG_ROOT=/opt/vcpkg \
198+
VCPKG_TRIPLET=x64-linux \
199+
VCPKG_FORCE_SYSTEM_BINARIES=1 \
200+
VCPKG_USE_SYSTEM_BINARIES=1
186201
ENV PATH="${PATH}:${VCPKG_ROOT}"
187-
ENV VCPKG_TRIPLET=x64-linux
188-
ENV VCPKG_FORCE_SYSTEM_BINARIES=1
189-
ENV VCPKG_USE_SYSTEM_BINARIES=1
190202

191203
RUN git clone --depth=1 \
192204
-c core.eol=lf \
@@ -253,8 +265,8 @@ RUN ln -s /usr/bin/clang-${LLVM_VERSION} /usr/bin/clang && \
253265
ln -s /usr/bin/clang-format-${LLVM_VERSION} /usr/bin/clang-format
254266

255267
# update compiler environment vars
256-
ENV CC=/usr/bin/clang
257-
ENV CXX=/usr/bin/clang++
268+
ENV CC=/usr/bin/clang \
269+
CXX=/usr/bin/clang++
258270

259271
# update alternatives
260272
RUN update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100 && \
@@ -281,8 +293,8 @@ RUN tar xf /tmp/gcc.xz && rm /tmp/gcc.xz && \
281293
libmpfr-dev libgmp3-dev libmpc-dev
282294

283295
# set default compiler to gcc
284-
ENV CC=/usr/bin/gcc
285-
ENV CXX=/usr/bin/g++
296+
ENV CC=/usr/bin/gcc \
297+
CXX=/usr/bin/g++
286298

287299
# installing into /usr instead of /usr/local to have consistent paths in CMakePresets:
288300
# /usr/bin/g++-12
@@ -354,8 +366,8 @@ RUN ./configure \
354366
# apt-get autoremove -y libmpfr-dev libgmp3-dev libmpc-dev
355367

356368
# reset default compiler to clang
357-
ENV CC=/usr/bin/clang
358-
ENV CXX=/usr/bin/clang++
369+
ENV CC=/usr/bin/clang \
370+
CXX=/usr/bin/clang++
359371

360372
#
361373
# 8888888888P .d8888b. 888 888
@@ -374,8 +386,8 @@ ENV CXX=/usr/bin/clang++
374386
# setup zsh, omyzsh, powerline fonts
375387
# setup zsh plugins: autosuggestions, autocompletions, history search
376388

377-
ENV TERM=xterm-256color
378-
ENV ZSH_THEME agnoster
389+
ENV TERM=xterm-256color \
390+
ZSH_THEME=agnoster
379391

380392
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
381393
RUN apt-get update && apt-get install -y --no-install-recommends \
@@ -429,7 +441,8 @@ ENV DEBIAN_FRONTEND=dialog
429441

430442
FROM cpp-devbox-base as cpp-devbox-with-vulkansdk
431443

432-
ENV VULKAN_VERSION=1.3.261.1
444+
# reusing global arg
445+
ARG VULKAN_VERSION
433446

434447
# +-----------------------------+
435448
# | METADATA |

0 commit comments

Comments
 (0)
Please sign in to comment.