-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
100 lines (84 loc) · 2.65 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
################################################################################
# Build stage 1
################################################################################
ARG BASE_IMG=ubuntu
ARG BASE_TAG=latest
FROM ${BASE_IMG}:${BASE_TAG} as builder
USER root
ENV HOME /root
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US
ENV LC_ALL C
ENV SHELL /bin/bash
ENV BASH_ENV /etc/bash.bashrc
ENV DEBIAN_FRONTEND noninteractive
WORKDIR /tmp
# build and env args used by package-manager
ARG COMPILER_TYPE
ARG COMPILER_VERSION
ENV COMPILER_TYPE ${COMPILER_TYPE}
ENV COMPILER_VERSION ${COMPILER_VERSION}
# package-manager configuration
COPY ./config/apt.sh /tmp/apt.sh
RUN ./apt.sh
# build arguments
ARG SHARED=ON
ARG STATIC=OFF
ARG CXXSTD=11
ARG TIMEMORY=OFF
ARG BUILD_TYPE=Release
ARG SOFTWARE=geant4
# environment settings
ENV BUILD_TYPE ${BUILD_TYPE}
ENV SHARED ${SHARED}
ENV STATIC ${STATIC}
ENV CXXSTD ${CXXSTD}
ENV TIMEMORY ${TIMEMORY}
ENV SOFTWARE ${SOFTWARE}
# cmake script for generating templates
COPY ./config/configure-file.cmake /tmp/configure-file.cmake
# copy over all the "-config", "-depend", and "-build" scripts
COPY ./config/*-depend.sh /tmp/
COPY ./config/*-build.sh /tmp/
COPY ./config/*-config.cmake.in /tmp/
# build the common dependencies
RUN ./common-depend.sh
# build the software specific dependencies
RUN ./${SOFTWARE}-depend.sh
# build the software
RUN ./${SOFTWARE}-build.sh
# clean up
RUN rm -rf /tmp/*
################################################################################
# Build stage 2 - compress to 1 layer
################################################################################
FROM scratch
COPY --from=builder / /
ENV HOME /root
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US
ENV LC_ALL C
ENV SHELL /bin/bash
ENV BASH_ENV /etc/bash.bashrc
ENV DEBIAN_FRONTEND noninteractive
ARG REQUIRE_CUDA_VERSION=10.0
ENV CUDA_HOME "/usr/local/cuda"
ENV NVIDIA_REQUIRE_CUDA "cuda>=${REQUIRE_CUDA_VERSION}"
ENV NVIDIA_VISIBLE_DEVICES "all"
ENV NVIDIA_DRIVER_CAPABILITIES "compute,utility"
ENV CC /usr/bin/cc
ENV CXX /usr/bin/c++
ENV CUDACC /usr/local/cuda/bin/nvcc
ENV CUDACXX /usr/local/cuda/bin/nvcc
#------------------------------------------------------------------------------#
# interactive settings and startup
#------------------------------------------------------------------------------#
COPY ./config/etc/profile.d/*.sh /etc/profile.d/
COPY ./config/etc/bash.bashrc /etc/
COPY ./config/etc/compute-dir-size.py /etc/
COPY ./config/root/* /root/
COPY ./config/runtime-entrypoint.sh /runtime-entrypoint.sh
USER root
WORKDIR /home
SHELL [ "/bin/bash", "--login", "-c" ]
ENTRYPOINT [ "/runtime-entrypoint.sh" ]