simonw / datasette

@@ -47,11 +47,10 @@
Loading
47 47
    ).split()
48 48
)
49 49
50 -
SPATIALITE_DOCKERFILE_EXTRAS = r"""
50 +
APT_GET_DOCKERFILE_EXTRAS = r"""
51 51
RUN apt-get update && \
52 -
    apt-get install -y python3-dev gcc libsqlite3-mod-spatialite && \
52 +
    apt-get install -y {} && \
53 53
    rm -rf /var/lib/apt/lists/*
54 -
ENV SQLITE_EXTENSIONS /usr/lib/x86_64-linux-gnu/mod_spatialite.so
55 54
"""
56 55
57 56
# Can replace with sqlite-utils when I add that dependency
@@ -308,10 +307,12 @@
Loading
308 307
    secret,
309 308
    environment_variables=None,
310 309
    port=8001,
310 +
    apt_get_extras=None,
311 311
):
312 312
    cmd = ["datasette", "serve", "--host", "0.0.0.0"]
313 313
    environment_variables = environment_variables or {}
314 314
    environment_variables["DATASETTE_SECRET"] = secret
315 +
    apt_get_extras = apt_get_extras or []
315 316
    for filename in files:
316 317
        cmd.extend(["-i", filename])
317 318
    cmd.extend(["--cors", "--inspect-file", "inspect-data.json"])
@@ -340,28 +341,38 @@
Loading
340 341
    else:
341 342
        install = ["datasette"] + list(install)
342 343
344 +
    apt_get_extras_ = []
345 +
    apt_get_extras_.extend(apt_get_extras)
346 +
    apt_get_extras = apt_get_extras_
347 +
    if spatialite:
348 +
        apt_get_extras.extend(["python3-dev", "gcc", "libsqlite3-mod-spatialite"])
349 +
        environment_variables[
350 +
            "SQLITE_EXTENSIONS"
351 +
        ] = "/usr/lib/x86_64-linux-gnu/mod_spatialite.so"
343 352
    return """
344 353
FROM python:3.8
345 354
COPY . /app
346 355
WORKDIR /app
347 -
{spatialite_extras}
356 +
{apt_get_extras}
348 357
{environment_variables}
349 358
RUN pip install -U {install_from}
350 359
RUN datasette inspect {files} --inspect-file inspect-data.json
351 360
ENV PORT {port}
352 361
EXPOSE {port}
353 362
CMD {cmd}""".format(
363 +
        apt_get_extras=APT_GET_DOCKERFILE_EXTRAS.format(" ".join(apt_get_extras))
364 +
        if apt_get_extras
365 +
        else "",
354 366
        environment_variables="\n".join(
355 367
            [
356 368
                "ENV {} '{}'".format(key, value)
357 369
                for key, value in environment_variables.items()
358 370
            ]
359 371
        ),
360 -
        files=" ".join(files),
361 -
        cmd=cmd,
362 372
        install_from=" ".join(install),
363 -
        spatialite_extras=SPATIALITE_DOCKERFILE_EXTRAS if spatialite else "",
373 +
        files=" ".join(files),
364 374
        port=port,
375 +
        cmd=cmd,
365 376
    ).strip()
366 377
367 378
@@ -382,6 +393,7 @@
Loading
382 393
    extra_metadata=None,
383 394
    environment_variables=None,
384 395
    port=8001,
396 +
    apt_get_extras=None,
385 397
):
386 398
    extra_metadata = extra_metadata or {}
387 399
    tmp = tempfile.TemporaryDirectory()
@@ -415,6 +427,7 @@
Loading
415 427
            secret,
416 428
            environment_variables,
417 429
            port=port,
430 +
            apt_get_extras=apt_get_extras,
418 431
        )
419 432
        os.chdir(datasette_dir)
420 433
        if metadata_content:

@@ -36,6 +36,12 @@
Loading
36 36
        callback=_validate_memory,
37 37
        help="Memory to allocate in Cloud Run, e.g. 1Gi",
38 38
    )
39 +
    @click.option(
40 +
        "--apt-get-install",
41 +
        "apt_get_extras",
42 +
        multiple=True,
43 +
        help="Additional packages to apt-get install",
44 +
    )
39 45
    def cloudrun(
40 46
        files,
41 47
        metadata,
@@ -60,6 +66,7 @@
Loading
60 66
        spatialite,
61 67
        show_files,
62 68
        memory,
69 +
        apt_get_extras,
63 70
    ):
64 71
        fail_if_publish_binary_not_installed(
65 72
            "gcloud", "Google Cloud", "https://cloud.google.com/sdk/"
@@ -122,6 +129,7 @@
Loading
122 129
            secret,
123 130
            extra_metadata,
124 131
            environment_variables,
132 +
            apt_get_extras=apt_get_extras,
125 133
        ):
126 134
            if show_files:
127 135
                if os.path.exists("metadata.json"):
Files Coverage
datasette 91.44%
Project Totals (30 files) 91.44%
1
coverage:
2
  status:
3
    project:
4
      default:
5
        informational: true
6
    patch:
7
      default:
8
        informational: true
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading