Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a Dockerfile to pycsw repo #534

Merged
23 changes: 23 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# build artifacts
*.pyc
*.egg-info
build
dist
docs/_build
MANIFEST

# testing artifacts
tests/index.html
tests/results
**.cache
.coverage
.tox

# test configurations
/default.cfg

# git stuff
.git

# pycharm ide
.idea
99 changes: 99 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# =================================================================
#
# Authors: Ricardo Garcia Silva <ricardo.garcia.silva@gmail.com>
#
# Copyright (c) 2017 Ricardo Garcia Silva
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# =================================================================
FROM alpine:3.4

# There's bug in libxml2 v2.9.4 that prevents using an XMLParser with a schema
# file.
#
# https://bugzilla.gnome.org/show_bug.cgi?id=766834
#
# It seems to have been fixed upstream, but the fix has not been released into
# a new libxml2 version. As a workaround, we are sticking with the previous
# version, which works fine.
# This means that we need to use alpine's archives for version 3.1, which are
# the ones that contain the previous version of libxml2
#
# Also, for some unkwnon reason, alpine 3.1 version of libxml2 depends on
# python2. We'd rather use python3 for pycsw, so we install it too.
RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.1/main' >> /etc/apk/repositories \
&& apk add --no-cache \
build-base \
ca-certificates \
postgresql-dev \
python3 \
python3-dev \
libpq \
libxslt-dev \
'libxml2<2.9.4' \
'libxml2-dev<2.9.4' \
wget \
&& apk add --no-cache \
--repository http://dl-3.alpinelinux.org/alpine/edge/testing/ \
--allow-untrusted \
geos \
geos-dev

RUN adduser -D -u 1000 pycsw

WORKDIR /tmp/pycsw

COPY . .

ENV PYCSW_CONFIG=/etc/pycsw/pycsw.cfg

RUN pip3 install --upgrade pip setuptools \
&& pip3 install --requirement requirements-standalone.txt \
&& pip3 install --requirement requirements-pg.txt \
&& pip3 install gunicorn \
&& pip3 install . \
&& mkdir /etc/pycsw \
&& mv docker/pycsw.cfg ${PYCSW_CONFIG} \
&& mkdir /var/lib/pycsw \
&& chown pycsw:pycsw /var/lib/pycsw \
&& cp docker/entrypoint.py /usr/local/bin/entrypoint.py \
&& chmod a+x /usr/local/bin/entrypoint.py \
&& cp -r tests /home/pycsw \
&& cp requirements.txt /home/pycsw \
&& cp requirements-standalone.txt /home/pycsw \
&& cp requirements-pg.txt /home/pycsw \
&& cp requirements-dev.txt /home/pycsw \
&& chown -R pycsw:pycsw /home/pycsw/* \
&& rm -rf *

WORKDIR /home/pycsw

USER pycsw


EXPOSE 8000

ENTRYPOINT [\
"python3", \
"/usr/local/bin/entrypoint.py" \
]
100 changes: 100 additions & 0 deletions docker/docker-stack-pycsw.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# =================================================================
#
# Authors: Tom Kralidis <tomkralidis@gmail.com>
# Ricardo Garcia Silva <ricardo.garcia.silva@gmail.com>
#
# Copyright (c) 2015 Tom Kralidis
# Copyright (c) 2017 Ricardo Garcia Silva
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# =================================================================

[server]
home=/home/pycsw
url=http://localhost/pycsw/csw.py
mimetype=application/xml; charset=UTF-8
encoding=UTF-8
language=en-US
maxrecords=10
loglevel=DEBUG
logfile=
#ogc_schemas_base=http://foo
#federatedcatalogues=http://catalog.data.gov/csw
#pretty_print=true
#gzip_compresslevel=8
#domainquerytype=range
#domaincounts=true
#spatial_ranking=true
profiles=apiso

[manager]
transactions=false
allowed_ips=127.0.0.1
#csw_harvest_pagesize=10

[metadata:main]
identification_title=pycsw Geospatial Catalogue
identification_abstract=pycsw is an OGC CSW server implementation written in Python
identification_keywords=catalogue,discovery,metadata
identification_keywords_type=theme
identification_fees=None
identification_accessconstraints=None
provider_name=Organization Name
provider_url=http://pycsw.org/
contact_name=Lastname, Firstname
contact_position=Position Title
contact_address=Mailing Address
contact_city=City
contact_stateorprovince=Administrative Area
contact_postalcode=Zip or Postal Code
contact_country=Country
contact_phone=+xx-xxx-xxx-xxxx
contact_fax=+xx-xxx-xxx-xxxx
contact_email=Email Address
contact_url=Contact URL
contact_hours=Hours of Service
contact_instructions=During hours of service. Off on weekends.
contact_role=pointOfContact

[repository]
# sqlite
#database=sqlite:////home/pycsw/tests/functionaltests/suites/cite/data/cite.db
# postgres
database=postgresql://postgres:mypass@db/pycsw
# mysql
#database=mysql://username:password@localhost/pycsw?charset=utf8
#mappings=path/to/mappings.py
table=records
#filter=type = 'http://purl.org/dc/dcmitype/Dataset'

[metadata:inspire]
enabled=true
languages_supported=eng,gre
default_language=eng
date=YYYY-MM-DD
gemet_keywords=Utility and governmental services
conformity_service=notEvaluated
contact_name=Organization Name
contact_email=Email Address
temp_extent=YYYY-MM-DD/YYYY-MM-DD

63 changes: 63 additions & 0 deletions docker/docker-stack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# =================================================================
#
# Authors: Ricardo Garcia Silva <ricardo.garcia.silva@gmail.com>
#
# Copyright (c) 2017 Ricardo Garcia Silva
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# =================================================================
#
#
# This docker-stack file demos how to use the pycsw docker image with a
# postgis database
#
# Use it with docker-compose or in a docker swarm:
#
# docker-compose --file docker-stack.yml --project pycsw up
#
# PYCSW_DOCKER_IMAGE=2.1-dev docker stack deploy --compose-file docker-stack.yml pycsw
#

version: "3"

services:

db:
image: mdillon/postgis:9.6-alpine
environment:
POSTGRES_PASSWORD: mypass
POSTGRES_DB: pycsw
PGDATA: /var/lib/postgresql/data/pgdata
volumes:
- db-data:/var/lib/postgresql/data/pgdata

pycsw:
image: geopython/pycsw:${PYCSW_DOCKER_VERSION}
ports:
- "8000:8000"
volumes:
- ./docker-stack-pycsw.cfg:/etc/pycsw/pycsw.cfg


volumes:
db-data:
Loading