CD: Package Index (#11665)

Build the docker image for the new package index REST API on each
merge/push to develop and master.
This commit is contained in:
Axel Huebl
2019-06-10 18:21:33 +02:00
committed by GitHub
parent 0953cd3a2e
commit d4008db75d
5 changed files with 53 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
FROM ubuntu:18.04 AS build-env
WORKDIR /build
RUN apt-get update && apt-get install -y jq
COPY packages.json ./
COPY split.sh ./
RUN /build/split.sh
FROM nginx:mainline-alpine
COPY --from=build-env --chown=nginx:nginx /build/packages /build/packages.json /usr/share/nginx/html/api/
CMD ["nginx", "-g", "daemon off;"]

View File

@@ -0,0 +1,17 @@
#!/usr/bin/env bash
#
# Copyright 2013-2019 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
script="$( basename "$0" )"
cd "$( dirname "$0" )"
export IMAGE="spack/packages.spack.io:latest"
if [ "$script" '=' 'push-image.sh' ] ; then
docker push "${IMAGE}"
else
docker build -f -t "${IMAGE}" .
fi

View File

@@ -0,0 +1 @@
build-image.sh

20
share/spack/packages/split.sh Executable file
View File

@@ -0,0 +1,20 @@
#!/usr/bin/env bash
#
# Copyright 2013-2019 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
# split the package index in a small file tree of
# /p/package.json
# files with sub-directories grouped by the initial letter of the packages
base_dir=$(pwd)/packages/
for pkg in $(cat packages.json | jq -c '.[]')
do
name="$(echo ${pkg} | jq -r '.name')";
first_letter=${name::1}
mkdir -p ${base_dir}${first_letter}/
echo ${pkg} > ${base_dir}${first_letter}/${name}.json
done

View File

@@ -37,10 +37,14 @@ for config in share/spack/docker/config/* ; do
./share/spack/docker/build-image.sh;
done
spack list --format version_json > packages.json
./share/spack/packages/build-image.sh
if [ "$TEST_SUITE" '=' "docker" -a \
"$TRAVIS_EVENT_TYPE" != "pull_request" ] && ensure_docker_login ; then
for config in share/spack/docker/config/* ; do
source "$config"
./share/spack/docker/push-image.sh
done
./share/spack/packages/push-image.sh
fi