-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
105 lines (93 loc) · 3.76 KB
/
Dockerfile
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
FROM solr:5.5.3
MAINTAINER Christian Mahnke ([email protected])
#Partly taken from the pub_dev Dockerfile
USER root
ENV REQ_BUILD tidy xmlstarlet jq xsltproc python
ENV CITIES_FILE cities1000
# Prepare to install
# OS
RUN apt update \
&& apt upgrade -y \
&& apt dist-upgrade -y \
&& apt install --assume-yes --no-install-recommends ${REQ_BUILD}
USER $SOLR_USER
RUN wget -O - http:$(wget -O - https://grid.ac/downloads | tidy -asxml -q --clean true \
--add-xml-decl yes --force-output yes --show-errors 0 --show-warnings no \
--numeric-entities yes --doctype omit | xmlstarlet --no-doc-namespace \
sel -N x=http://www.w3.org/1999/xhtml -t -v \
"//x:a[contains(., 'latest')]/@href") | tidy -asxml -q --clean true \
--add-xml-decl yes --force-output yes --show-errors 0 --show-warnings no \
--numeric-entities yes --doctype omit | xmlstarlet --no-doc-namespace \
sel -N x=http://www.w3.org/1999/xhtml -t -v \
"//x:script[@type = 'application/ld+json']" | jq ".distribution[0].contentUrl" | \
xargs wget -O grid.zip && unzip grid.zip
#Clear the input file. Fixes a literal \t
RUN sed -i -e 's/\\t//g' grid.json
# Setup Solr
COPY schema.json .
COPY schema-patch.xsl .
COPY config-patch.xsl .
RUN bin/solr start && bin/solr create -c grid && curl -X POST 'http://0.0.0.0:8983/solr/grid/schema' \
-H 'Content-type:application/json' --data-binary @schema.json && \
xsltproc schema-patch.xsl server/solr/grid/conf/managed-schema > server/solr/grid/conf/schema.xml && \
xsltproc config-patch.xsl server/solr/grid/conf/solrconfig.xml > server/solr/grid/conf/solrconfig.xml.patched && \
mv server/solr/grid/conf/solrconfig.xml.patched server/solr/grid/conf/solrconfig.xml
## Populate index "grid"
RUN bin/solr start && \
curl 'http://0.0.0.0:8983/solr/grid/update/json/docs\
?split=/institutes\
&f=id:/institutes/id\
&f=name:/institutes/name\
&f=wikipedia_url:/institutes/wikipedia_url\
&f=links:/institutes/links\
&f=types:/institutes/types\
&f=aliases:/institutes/aliases\
&f=acronyms:/institutes/acronyms\
&f=types:/institutes/type\
&f=ip_addresses:/institutes/ip_addresses\
&f=established:/institutes/established\
&f=ISNI:/institutes/external_ids/ISNI/all\
&f=FundRef:/institutes/external_ids/FundRef/all\
&f=OrgRef:/institutes/external_ids/OrgRef/all\
&f=Wikidata:/institutes/external_ids/Wikidata/all\
&f=city:/institutes/addresses/city\
&f=state:/institutes/addresses/state\
&f=state_code:/institutes/addresses/state_code\
&f=country:/institutes/addresses/country\
&f=country_code:/institutes/addresses/country_code\
&f=relationship:/institutes/relationships/label\
&f=relationship_id:/institutes/relationships/id\
&f=geonames_id:/institutes/addresses/geonames_city/id\
&f=status:/institutes/status\
&f=lat:/institutes/addresses/lat\
&f=lng:/institutes/addresses/lng\
&commit=true'\
-H 'Content-type:application/json' \
--data-binary @grid.json -X POST
#Get some GeoNames
COPY jsonify.py .
RUN wget http://download.geonames.org/export/dump/$CITIES_FILE.zip && unzip $CITIES_FILE.zip && \
python jsonify.py -g $CITIES_FILE.txt > $CITIES_FILE.json && \
bin/solr start && bin/solr create -c geonames && \
curl 'http://0.0.0.0:8983/solr/geonames/update/json/docs\
?split=/\
&f=id:/id\
&f=name:/name\
&f=alternate_names:/alternate_names\
&f=coordinates:/coordinates\
&f=country:/country\
&f=population:/population\
&f=timezone:/timezone\
&commit=true'\
-H 'Content-type:application/json' \
--data-binary @$CITIES_FILE.json -X POST
# Clean up a bit
USER root
RUN rm -rf schema.json schema-patch.xsl config-patch.xsl full_tables grid.* $CITIES_FILE*
RUN apt-get --purge remove -y ${REQ_BUILD} && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
USER $SOLR_USER
EXPOSE 8983
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["solr-foreground"]