tursodatabase / turso-cli

Command line interface to Turso.
https://turso.tech
MIT License
215 stars 35 forks source link

Docker image for easier development? #645

Open glommer opened 1 year ago

glommer commented 1 year ago

Reference, thread on discord: https://discord.com/channels/933071162680958986/933071163184283651/1154540600293609652

User suggests - and I agree - that it would be helpful to provide a docker image that includes the turso cli, the libsql-server, and ways to mount existing SQLite files into the libsql-server directories. This could be helpful for some CI pipelines

tvandinther commented 1 year ago

The way I would use it is with a docker-compose.yaml file like the following:

version: "3.8"
services:
  sqld:
    image: ghcr.io/libsql/sqld:v0.20.3
    ports:
      - "8080:8080"

  bootstrap-db:
    image: turso
    volumes:
      - ./database:/bootstrap
    working_dir: /bootstrap
    command: ["db", "shell", "$SQLD_URL", "<", "init.sql"]
    environment:
      SQLD_URL: http://sqld:8080
    depends_on:
      - sqld

  my-astro-app:
    image: node:18.14.1
    ports:
      - "4321:4321"
    volumes:
      - ./:/app
    working_dir: /app
    command: npm run dev -- --host
    environment:
      SQLD_URL: http://sqld:8080
    depends_on:
      - sqld
      - bootstrap-db

Alternatively, instead of running a bootstrapping sql script you could mount an sqlite file:

services:
  sqld:
    image: ghcr.io/libsql/sqld:v0.20.3
    ports:
      - "8080:8080"
    volumes:
      - ./db.sqlite:/var/lib/sqld

Another thing that I see often is adding tooling helpers into a docker compose file. For example:

services:
  turso:
    image: turso
    working_dir: /app
    volumes:
      - ./:/app

Paired with alias dcr = "docker compose run --rm" allowing for dcr turso [COMMAND] when in the project directory. This prevents bespoke tooling installs if you're constantly dealing with different technologies and it also means the whole development team is running the same version of the tooling in the same way.

Just some ways in which I might use this. Hope it helps!

tvandinther commented 7 months ago

Hi, any update on the status of this? In the interim I have published my own image so that I can be unblocked but it would be great to have this officially be a part of your pipeline.

Here's the Dockerfile I used. Mostly a copy + paste of your libsql-server image with some extra stages.

LucioFranco commented 7 months ago

Yeah I think this makes a lot of sense to add, will make sure it gets added to the roadmap.

GustavoOS commented 4 months ago

@LucioFranco do we have any updates about it?

ANorseDude commented 1 week ago

Any updates?