-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.buildcache
61 lines (45 loc) · 1.87 KB
/
Dockerfile.buildcache
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
# syntax=docker/dockerfile:latest
# Pick one from [gcc485, gcc11]
ARG compiler=gcc485
# Pick one from [os, bc]
ARG baseimg=bc
ARG baseimg_os=scientificlinux/sl:7
ARG baseimg_bc=ghcr.io/star-bnl/star-spack:buildcache
FROM ${baseimg_os} AS baseimg_os-stage
FROM ${baseimg_bc} AS baseimg_bc-stage
# Install common packages
FROM baseimg_${baseimg}-stage AS base-stage
RUN yum install -y git unzip make patch perl perl-Data-Dumper libX11-devel libXext-devel libXpm-devel
# Install gcc485 (default)
FROM base-stage AS gcc485-prep-stage
RUN yum install -y gcc gcc-c++ gcc-gfortran
# Install gcc11
FROM base-stage AS gcc11-prep-stage
RUN curl -O http://mirror.centos.org/centos/7/extras/x86_64/Packages/centos-release-scl-rh-2-3.el7.centos.noarch.rpm \
&& rpm -ivh centos-release-scl-rh-2-3.el7.centos.noarch.rpm \
&& yum install -y devtoolset-11 \
&& echo "source /opt/rh/devtoolset-11/enable" >> /etc/bashrc
FROM ${compiler}-prep-stage AS build-stage
COPY . /star-spack
RUN mkdir -p /star-spack/spack && curl -sL https://github.com/spack/spack/archive/v0.18.1.tar.gz | tar -xz --strip-components 1 -C /star-spack/spack
# Create or add packages to /opt/buildcache
COPY --chmod=0755 <<-"EOF" dostarenv.sh
#!/bin/bash -l
set -e
source /star-spack/setup.sh
rm -f $HOME/.spack/mirrors.yaml
spack compiler add $(dirname $(which gcc))
spack mirror add buildcache /opt/buildcache
spack buildcache update-index -d /opt/buildcache
spack env create ${1} /star-spack/environments/${1}.yaml
spack env activate ${1}
spack --insecure install --no-check-signature
spack buildcache create -d /opt/buildcache --unsigned --allow-root $(spack find --no-groups --format "/{hash}")
spack env deactivate
EOF
RUN ./dostarenv.sh star-x86_64-loose
RUN ./dostarenv.sh root5
RUN ./dostarenv.sh root6
RUN ./dostarenv.sh root624
FROM ${baseimg_os} AS buildcache-stage
COPY --from=build-stage /opt/buildcache /opt/buildcache