htmls-to-datasette icon indicating copy to clipboard operation
htmls-to-datasette copied to clipboard

Docker

Open poblabs opened this issue 3 years ago • 7 comments

Hey there, I wanted to test this out from the Dockerfile, but I'm having a problem with the database. When I touch htmlstore.db the container doesn't populate the tables. It doesn't seem like the cli.py initialize_db process is being called. Any thoughts?

poblabs avatar Sep 30 '21 14:09 poblabs

Here's my docker-compose.yml that I created where you can see my database mapping. It's present, and the container tries to open it, but says there's no table called files. So it's not being initialized.

version: "3"
services:
  htmls_to_datasette:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: htmls_to_datasette
    volumes:
      - ./htmlstore.db:/app/htmlstore.db
      - ./volumes/config:/app/config
      - ./htmls:/app/htmls
    ports:
      - 82:8001
    restart: unless-stopped

poblabs avatar Sep 30 '21 14:09 poblabs

Hi Pat,

This is a super early work on this. You'll need to create the database the first time to share it on docker afterwards. I guess a "touch" file with zero bytes is not recognized. Do out of the container:

pipx install htmls-to-datasette
cd <your docker data dir, where htmls and config dirs are>
# Move your HTML files to htmls directory
html-to-datasette index htmls
# All files will be indexed

After that run the docker-compose.yml file that you created, it should workd this time.

Things that I need to to do in this regard:

  • Better documentation on how to use docker, add docker-compose.yml
  • Make indexing work inside the docker container (maybe a docker exec while the container is running triggered by cron, or something inside the container that happens after a period of time)

pjamar avatar Sep 30 '21 19:09 pjamar

I 100% appreciate this is early work, and I'm happy to help get it going 😄

I ran a 2nd docker container of ubuntu to create the empty database. Upon starting the htmls-to-datasette container it didn't index the htmls folder, so I had to manually run html-to-datasette index htmls inside the container.

So far so good! Happy to test any updates you create in future

poblabs avatar Oct 01 '21 16:10 poblabs

That is the problem, that the indexing is not done in the container. The container is just launching Datasette with a specific configuration. You'll have to perform the indexing as I described (in the host system). Install this app with pip/pipx/pipsi and run it. Once that is done you can start the container and you should be able to search and view them.

On Fri, 1 Oct 2021 at 09:42, poblabs @.***> wrote:

I 100% appreciate this is early work, and I'm happy to help get it going 😄

I ran a 2nd docker container of ubuntu, and have the empty database. Upon starting the container it didn't index the htmls folder, so I had to manually run html-to-datasette index htmls inside the container.

So far so good! Happy to test any updates you create in future

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/pjamar/htmls-to-datasette/issues/1#issuecomment-932384373, or unsubscribe https://github.com/notifications/unsubscribe-auth/AATRWDMIJUAE6DLIRVKCUFDUEXQF5ANCNFSM5FCNHOWA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Best regards, Pablo

--- I do not fear computers. I fear the lack of them. Isaac Asimov.

pjamar avatar Oct 01 '21 18:10 pjamar

I just saw how to do it inside the container, just keep it running and do the following

docker exec -it <your container name> htmls-to-datasette index htmls

As you see is not super complicated, I just need to add this to the docs...

pjamar avatar Oct 01 '21 19:10 pjamar

I've found a little bit of an easier way.

Run touch htmlstore.db to create the 0 byte file.

Change your Dockerfile to add a copy and change the entrypoint:

COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT /entrypoint.sh

Then create a new file entrypoint.sh and add this:

#!/bin/bash

htmls-to-datasette index htmls

datasette serve /app/htmlstore.db --create -m /app/config/metadata.json --plugins-dir=plugins -h 0.0.0.0

This creates the database on initial start, and then scans on container restarts.

So far this is working good for me. I can do a pull request if you'd like, but it's pretty simple to implement.

poblabs avatar Oct 01 '21 19:10 poblabs

Yes, Pat, that will be great!

pjamar avatar Oct 04 '21 17:10 pjamar