Skip to content

Commit

Permalink
CD: Package Index (spack#11665)
Browse files Browse the repository at this point in the history
Build the docker image for the new package index REST API on each
merge/push to develop and master.
  • Loading branch information
ax3l authored Jun 10, 2019
1 parent 0953cd3 commit d4008db
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 0 deletions.
11 changes: 11 additions & 0 deletions share/spack/packages/Dockerfile
Original file line number Diff line number Diff line change
@@ -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;"]
17 changes: 17 additions & 0 deletions share/spack/packages/build-image.sh
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions share/spack/packages/push-image.sh
20 changes: 20 additions & 0 deletions share/spack/packages/split.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions share/spack/qa/run-docker-tests
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d4008db

Please sign in to comment.