Package Index: Build in Dockerhub (#13810)
* Package Index: Build in Dockerhub Prepare to build the package index service, packages.spack.io, on Dockerhub. Local build (in spack root dir): ``` docker build -t spack/packages.spack.io:latest -f share/spack/docker/package-index/Dockerfile . ``` Local test: ``` docker run -p 8080:80 spack/packages.spack.io:latest ``` * Travis-CI: Remove Docker Remove leftover docker stages from Travis-CI. * Simplify Split Call
This commit is contained in:
30
share/spack/docker/package-index/Dockerfile
Normal file
30
share/spack/docker/package-index/Dockerfile
Normal file
@@ -0,0 +1,30 @@
|
||||
# prepare the package index in form of JSON files
|
||||
FROM ubuntu:18.04 AS build-env
|
||||
|
||||
ENV SPACK_ROOT=/opt/spack \
|
||||
DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
COPY bin $SPACK_ROOT/bin
|
||||
COPY etc $SPACK_ROOT/etc
|
||||
COPY lib $SPACK_ROOT/lib
|
||||
COPY share $SPACK_ROOT/share
|
||||
COPY var $SPACK_ROOT/var
|
||||
|
||||
RUN apt-get -yqq update \
|
||||
&& apt-get -yqq install \
|
||||
bash jq python \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /build
|
||||
# single, large index file
|
||||
RUN $SPACK_ROOT/bin/spack list --format version_json > packages.json
|
||||
# individual packages split into a tree of :firstLetter/:packageName.json
|
||||
RUN $SPACK_ROOT/share/spack/docker/package-index/split.sh
|
||||
|
||||
# nginx web service
|
||||
FROM nginx:mainline-alpine
|
||||
MAINTAINER Spack Maintainers <maintainers@spack.io>
|
||||
COPY --from=build-env --chown=nginx:nginx /build/packages /build/packages.json /usr/share/nginx/html/api/
|
||||
COPY share/spack/docker/package-index/cors-header.conf /etc/nginx/conf.d/
|
||||
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
45
share/spack/docker/package-index/README.rst
Normal file
45
share/spack/docker/package-index/README.rst
Normal file
@@ -0,0 +1,45 @@
|
||||
============================================
|
||||
The packages.spack.io Package Index REST API
|
||||
============================================
|
||||
|
||||
This directory provides the docker recipe for the Spack package index on https://packages.spack.io
|
||||
|
||||
On each merge to ``develop``, DockerHub builds a new image ``spack/packages.spack.io`` which is configured in:
|
||||
https://cloud.docker.com/u/spack/repository/docker/spack/packages.spack.io/builds/edit
|
||||
|
||||
------------
|
||||
The REST API
|
||||
------------
|
||||
|
||||
The API is a simple, file-based JSON index.
|
||||
A specific package can be queried via the URI syntax:
|
||||
``https://packages.spack.io/api/:firstLetter/:packageName.json``
|
||||
which will return a HTTP status code ``200`` with a JSON file for all valid packages (content from ``spack list --format version_json``) and HTTP status code ``404`` for all other package names.
|
||||
|
||||
Examples:
|
||||
|
||||
- https://packages.spack.io/api/a/adios2.json
|
||||
- https://packages.spack.io/api/p/py-pandas.json
|
||||
|
||||
There is also the full index available at once under https://packages.spack.io/api/packages.json
|
||||
|
||||
Current down-stream dependencies are, e.g. the https://shields.io service:
|
||||
|
||||
- https://shields.io/category/version
|
||||
- https://github.com/badges/shields/pull/3536
|
||||
|
||||
--------------------
|
||||
Local Build and Test
|
||||
--------------------
|
||||
|
||||
Execute in your local Spack source root directory:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
docker build -t spack/packages.spack.io:latest -f share/spack/docker/package-index/Dockerfile .
|
||||
|
||||
Startup a local HTTP server on http://localhost:8080 via:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
docker run -p 8080:80 spack/packages.spack.io:latest
|
3
share/spack/docker/package-index/cors-header.conf
Normal file
3
share/spack/docker/package-index/cors-header.conf
Normal file
@@ -0,0 +1,3 @@
|
||||
# potentially add even more for preflight support
|
||||
# https://enable-cors.org/server_nginx.html
|
||||
add_header 'Access-Control-Allow-Origin' '*';
|
20
share/spack/docker/package-index/split.sh
Executable file
20
share/spack/docker/package-index/split.sh
Executable 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
|
Reference in New Issue
Block a user