From 9fe9c82a1f94ef9e88d9ea51491e6e28f9bb95e2 Mon Sep 17 00:00:00 2001 From: Brendan Early Date: May 22 2021 00:53:10 +0000 Subject: Create docker compose file --- diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4734767 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +public_html +repositories +pagure_owner_alias.json +product_version_mapping.json +container_folder diff --git a/.gitignore b/.gitignore index 73a290f..1e98dcf 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ vue/dist .vscode bin/__pycache__ product_version_mapping.json +container_folder diff --git a/Dockerfile b/Dockerfile index 5842150..8020045 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,6 +38,7 @@ COPY container/supervisord.conf /etc/supervisord.conf # one container that manages static files # and just serve from the rest with read-only mounts VOLUME /srv/packages +VOLUME /etc/packages EXPOSE 8080 ENTRYPOINT [ "./container/entrypoint.sh" ] diff --git a/README.md b/README.md index c1d1f4a..405e555 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,19 @@ # fedora-packages-static -This project intends to replace the current Fedora [packages +This project replaces the former Fedora [packages app](https://apps.fedoraproject.org/packages/) which is built atop now dead librairies and a pain to maintain. See *[The packages app has a short runway](https://lists.fedoraproject.org/archives/list/infrastructure@lists.fedoraproject.org/thread/WWQG4RE5PSR5I2GND5SVWGMZRJNVRRPS/)* for context. -The idea here is to generate a static page for every package and index it using -an independent tool such as [Yacy](https://yacy.net/). +This project generates a static page for each package, which is then indexed by Solr. With the exception of the MIT `assets/css/bootstrap.min.css`, the content of this repository is licensed under the GPLv3. -## TODO - -* Clean code, make pylint and humans happy. -* Display dependencies in package detail page. -* Add support for modular and flatpak repositories. - ## Dependencies -The scripts contained in this repository depend +The scripts contained in this repository depend on: * `make` * `curl` @@ -38,3 +31,14 @@ The scripts contained in this repository depend * All at once: `make all` * Help message: `make help` * Clean artefacts (generated and downloaded): `make clean` + +## Running with Solr + +To run fedora-packages-static with functioning search: + +```bash +mkdir container_folder public_html +docker-compose up +``` + +Solr will be availible at http://localhost:8983/ and fedora-packages-static will be at http://localhost:8080/ diff --git a/container/solr-start.sh b/container/solr-start.sh new file mode 100755 index 0000000..45a2725 --- /dev/null +++ b/container/solr-start.sh @@ -0,0 +1,81 @@ +#!/bin/bash +# +# Taken from https://github.com/docker-solr/docker-solr/blob/master/scripts/solr-precreate +# Chnaged so that Solr itself is called with -p 8983 (otherwise it will crash). +set -e + +if [[ "${VERBOSE:-}" == "yes" ]]; then + set -x +fi + +# init script for handling an empty /var/solr +/opt/docker-solr/scripts/init-var-solr + +. /opt/docker-solr/scripts/run-initdb + +# Manually arrange config files into directory structure solr needs because openshift just won't let this be simple +mkdir -p /var/solr/openshift/packages +cp /opt/solr/server/solr/configsets/packages/schema.xml /var/solr/openshift/packages + +mkdir -p /var/solr/openshift/packages/conf +cp /opt/solr/server/solr/configsets/packages/solrconfig.xml /var/solr/openshift/packages/conf + +# Create the core +/opt/docker-solr/scripts/precreate-core "packages" /var/solr/openshift/packages + +#!/bin/bash +# +# start solr in the foreground +set -e + +if [[ "$VERBOSE" == "yes" ]]; then + set -x +fi + +EXTRA_ARGS=() +EXTRA_ARGS+=(-p 8983) + +# Start of https://github.com/docker-solr/docker-solr/blob/master/scripts/solr-fg +if [[ -z "${OOM:-}" ]]; then + OOM='none' +fi +case "$OOM" in + 'script') + EXTRA_ARGS+=(-a '-XX:OnOutOfMemoryError=/opt/docker-solr/scripts/oom_solr.sh') + ;; + 'exit') + # recommended + EXTRA_ARGS+=(-a '-XX:+ExitOnOutOfMemoryError') + ;; + 'crash') + EXTRA_ARGS+=(-a '-XX:+CrashOnOutOfMemoryError') + ;; + 'none'|'') + ;; + *) + echo "Unsupported value in OOM=$OOM" + exit 1 +esac + +echo "Starting Solr $SOLR_VERSION" +# determine TINI default. If it is already set, assume the user knows what they want +if [[ -z "${TINI:-}" ]]; then + if [[ "$$" == 1 ]]; then + # Default to running tini, so we can run with an OOM script and have 'kill -9' work + TINI=yes + else + # Presumably we're already running under tini through 'docker --init', in which case we + # don't need to run it twice. + # It's also possible that we're run from a wrapper script without exec, + # in which case running tini would not be ideal either. + TINI=no + fi +fi +if [[ "$TINI" == yes ]]; then + exec /usr/bin/tini -- solr -f "${EXTRA_ARGS[@]}" +elif [[ "$TINI" == no ]]; then + exec solr -f "${EXTRA_ARGS[@]}" +else + echo "invalid value TINI=$TINI" + exit 1 +fi diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..71d17b2 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,31 @@ +version: "3.9" +services: + packages: + build: . + ports: + - "8080:8080" + volumes: + - type: bind + source: ./public_html + target: /srv/packages + - type: bind + source: ./container_folder + target: /etc/packages + links: + - solr + environment: + SOLR_URL: "http://solr:8983/" + solr: + image: solr:8 + ports: + - "8983:8983" + volumes: + - type: bind + source: ./solr + target: /opt/solr/server/solr/configsets/packages + read_only: true + - type: bind + source: ./container + target: /opt/solr-start + read_only: true + command: bash /opt/solr-start/solr-start.sh diff --git a/solr/schema.xml b/solr/schema.xml index 42c8660..e5db77d 100644 --- a/solr/schema.xml +++ b/solr/schema.xml @@ -5,7 +5,6 @@ -