kopia lustrzana https://github.com/simonw/datasette
datasette publish/package --spatialite, closes #243
New command-line argument which causes SpatiaLite to be installed and configured for the published Datasette. datasette publish now --spatialite mydb.dbcustom-router
rodzic
969771770f
commit
b18e451585
|
@ -179,6 +179,7 @@ This will create a docker image containing both the datasette application and th
|
|||
--static STATIC MOUNT mountpoint:path-to-directory for serving static
|
||||
files
|
||||
--install TEXT Additional packages (e.g. plugins) to install
|
||||
--spatialite Enable SpatialLite extension
|
||||
--title TEXT Title for metadata
|
||||
--license TEXT License label for metadata
|
||||
--license_url TEXT License URL for metadata
|
||||
|
@ -206,6 +207,7 @@ If you have docker installed you can use `datasette package` to create a new Doc
|
|||
--static STATIC MOUNT mountpoint:path-to-directory for serving static
|
||||
files
|
||||
--install TEXT Additional packages (e.g. plugins) to install
|
||||
--spatialite Enable SpatialLite extension
|
||||
--title TEXT Title for metadata
|
||||
--license TEXT License label for metadata
|
||||
--license_url TEXT License URL for metadata
|
||||
|
|
|
@ -122,6 +122,9 @@ def inspect(files, inspect_file, sqlite_extensions):
|
|||
help="Additional packages (e.g. plugins) to install",
|
||||
multiple=True,
|
||||
)
|
||||
@click.option(
|
||||
"--spatialite", is_flag=True, help="Enable SpatialLite extension"
|
||||
)
|
||||
@click.option("--title", help="Title for metadata")
|
||||
@click.option("--license", help="License label for metadata")
|
||||
@click.option("--license_url", help="License URL for metadata")
|
||||
|
@ -139,6 +142,7 @@ def publish(
|
|||
plugins_dir,
|
||||
static,
|
||||
install,
|
||||
spatialite,
|
||||
**extra_metadata
|
||||
):
|
||||
"""
|
||||
|
@ -183,6 +187,7 @@ def publish(
|
|||
plugins_dir,
|
||||
static,
|
||||
install,
|
||||
spatialite,
|
||||
extra_metadata,
|
||||
):
|
||||
if force:
|
||||
|
@ -335,6 +340,9 @@ def skeleton(files, metadata, sqlite_extensions):
|
|||
help="Additional packages (e.g. plugins) to install",
|
||||
multiple=True,
|
||||
)
|
||||
@click.option(
|
||||
"--spatialite", is_flag=True, help="Enable SpatialLite extension"
|
||||
)
|
||||
@click.option("--title", help="Title for metadata")
|
||||
@click.option("--license", help="License label for metadata")
|
||||
@click.option("--license_url", help="License URL for metadata")
|
||||
|
@ -350,6 +358,7 @@ def package(
|
|||
plugins_dir,
|
||||
static,
|
||||
install,
|
||||
spatialite,
|
||||
**extra_metadata
|
||||
):
|
||||
"Package specified SQLite files into a new datasette Docker container"
|
||||
|
@ -372,6 +381,7 @@ def package(
|
|||
plugins_dir,
|
||||
static,
|
||||
install,
|
||||
spatialite,
|
||||
extra_metadata,
|
||||
):
|
||||
args = ["docker", "build"]
|
||||
|
|
|
@ -31,6 +31,13 @@ reserved_words = set((
|
|||
'vacuum values view virtual when where with without'
|
||||
).split())
|
||||
|
||||
SPATIALITE_DOCKERFILE_EXTRAS = r'''
|
||||
RUN apt-get update && \
|
||||
apt-get install -y python3-dev gcc libsqlite3-mod-spatialite && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
ENV SQLITE_EXTENSIONS /usr/lib/x86_64-linux-gnu/mod_spatialite.so
|
||||
'''
|
||||
|
||||
|
||||
class InterruptedError(Exception):
|
||||
pass
|
||||
|
@ -241,7 +248,7 @@ def escape_sqlite(s):
|
|||
return '[{}]'.format(s)
|
||||
|
||||
|
||||
def make_dockerfile(files, metadata_file, extra_options, branch, template_dir, plugins_dir, static, install):
|
||||
def make_dockerfile(files, metadata_file, extra_options, branch, template_dir, plugins_dir, static, install, spatialite):
|
||||
cmd = ['"datasette"', '"serve"', '"--host"', '"0.0.0.0"']
|
||||
cmd.append('"' + '", "'.join(files) + '"')
|
||||
cmd.extend(['"--cors"', '"--port"', '"8001"', '"--inspect-file"', '"inspect-data.json"'])
|
||||
|
@ -266,9 +273,10 @@ def make_dockerfile(files, metadata_file, extra_options, branch, template_dir, p
|
|||
install = ['datasette'] + list(install)
|
||||
|
||||
return '''
|
||||
FROM python:3
|
||||
FROM python:3.6-slim-stretch
|
||||
COPY . /app
|
||||
WORKDIR /app
|
||||
{spatialite_extras}
|
||||
RUN pip install {install_from}
|
||||
RUN datasette inspect {files} --inspect-file inspect-data.json
|
||||
EXPOSE 8001
|
||||
|
@ -276,6 +284,7 @@ CMD [{cmd}]'''.format(
|
|||
files=' '.join(files),
|
||||
cmd=', '.join(cmd),
|
||||
install_from=' '.join(install),
|
||||
spatialite_extras=SPATIALITE_DOCKERFILE_EXTRAS if spatialite else '',
|
||||
).strip()
|
||||
|
||||
|
||||
|
@ -290,6 +299,7 @@ def temporary_docker_directory(
|
|||
plugins_dir,
|
||||
static,
|
||||
install,
|
||||
spatialite,
|
||||
extra_metadata=None
|
||||
):
|
||||
extra_metadata = extra_metadata or {}
|
||||
|
@ -320,6 +330,7 @@ def temporary_docker_directory(
|
|||
plugins_dir,
|
||||
static,
|
||||
install,
|
||||
spatialite,
|
||||
)
|
||||
os.chdir(datasette_dir)
|
||||
if metadata_content:
|
||||
|
|
Ładowanie…
Reference in New Issue