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

introduce new option for datasette package to use a slim base image #1574

Closed
wants to merge 2 commits into from

Conversation

fs111
Copy link

@fs111 fs111 commented Dec 19, 2021

The official python images on docker hub come with a slim variant that is significantly smaller than the default. The diff does not change the default, but allows to switch to the slim variant with commandline switch (--slim-base-image)

Size comparison:

$ datasette package some.db -t fat --install "datasette-basemap datasette-cluster-map"

$ datasette  package some.db -t slim --slim-base-image --install "datasette-basemap datasette-cluster-map"

$ docker images
REPOSITORY   TAG       IMAGE ID       CREATED          SIZE
fat          latest    807b393ace0d   9 seconds ago    978MB
slim         latest    31bc5e63505c   8 minutes ago    191MB

The official python images on docker hub come with a slim variant that
is significantly smaller than the default. The diff does not change the
default, but allows to switch to the `slim` variant with commandline
switch (`--slim-base-image`)

Size comparison:

```
$ datasette package some.db -t fat --install "datasette-basemap datasette-cluster-map"

$ datasette  package some.db -t slim --slim-base-image --install "datasette-basemap datasette-cluster-map"

$ docker images
REPOSITORY   TAG       IMAGE ID       CREATED          SIZE
fat          latest    807b393ace0d   9 seconds ago    978MB
slim         latest    31bc5e63505c   8 minutes ago    191MB

```
@fgregg
Copy link
Contributor

fgregg commented Jan 8, 2022

is there a reason to not always use the slim option?

@fs111
Copy link
Author

fs111 commented Jan 9, 2022

@fgregg my thinking was backwards compatibility. I don't know what people do to their builds, I just wanted a smaller image for my use case.

@simonw any chance to take a look at this? If there is no interest, feel free to close the PR

@simonw
Copy link
Owner

simonw commented Mar 23, 2022

I'd actually like to switch to slim as the default - I think Datasette should ship the smallest possible container that can still support extra packages being installed using apt-get install.

@fs111
Copy link
Author

fs111 commented Mar 31, 2022

@simonw I like that you want to go "slim by default". Do you want another PR for that or should I just wait?

@dholth
Copy link

dholth commented Apr 21, 2022

tfw you have more ephemeral storage than upstream bandwidth

FROM python:3.10-slim AS base

RUN apt update && apt -y install zstd

ENV DATASETTE_SECRET 'sosecret'
RUN --mount=type=cache,target=/root/.cache/pip
    pip install -U datasette datasette-pretty-json datasette-graphql

ENV PORT 8080
EXPOSE 8080

FROM base AS pack

COPY . /app
WORKDIR /app

RUN datasette inspect --inspect-file inspect-data.json
RUN zstd --rm *.db

FROM base AS unpack

COPY --from=pack /app /app
WORKDIR /app

CMD ["/bin/bash", "-c", "shopt -s nullglob && zstd --rm -d *.db.zst && datasette serve --host 0.0.0.0 --cors --inspect-file inspect-data.json --metadata metadata.json --create --port $PORT *.db"]

@fs111
Copy link
Author

fs111 commented Aug 15, 2022

closing as this is now the default

@fs111 fs111 closed this Aug 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants