Coder Social home page Coder Social logo

datomic-pro-docker's Introduction

Datomic Pro Docker Compose

As of April 27, 2023, Datomic Pro is free!

This repository contains example Docker and Docker Compose files for running Datomic Pro locally on your computer.

These examples are designed for prototyping and educational purposes; they should not be considered suitable or ready for production use.

This is not an official Datomic project or documentation and is not affiliated with Datomic in any way.

Storage Services and Transactor

Official Documentation: Storage Services

Dev Mode

Official Documentation: Provisioning dev mode

Copy the Docker Compose file:

cp compose/dev-mode.yml docker-compose.yml

Run the Datomic Transactor:

docker compose up datomic-transactor

To restore a backup of the MusicBrainz Sample Database:

docker compose run datomic-tools ./bin/datomic restore-db file:/usr/mbrainz-1968-1973 "datomic:dev://datomic-transactor:4334/my-datomic?password=unsafe"

PostgreSQL

Official Documentation Provisioning a SQL database

Copy the Docker Compose file:

cp compose/postgresql.yml docker-compose.yml

Run the Datomic Storage Service (PostgreSQL):

docker compose up datomic-storage

Create the table for Datomic:

docker compose run datomic-tools psql -f bin/sql/postgres-table.sql -h datomic-storage -U datomic-user -d my-datomic

You will be prompted for a password, which is unsafe.

Run the Datomic Transactor:

docker compose up datomic-transactor

To restore a backup of the MusicBrainz Sample Database:

docker compose run datomic-tools ./bin/datomic restore-db file:/usr/mbrainz-1968-1973 "datomic:sql://?jdbc:postgresql://datomic-storage:5432/my-datomic?user=datomic-user&password=unsafe"

Tools and Utilities

Datomic Console

To run Datomic Console:

docker compose up datomic-console

http://localhost:8080/browse

Screenshot of the Datomic Console interface

REPL

Starting a REPL:

docker compose run datomic-tools clojure -M:repl

Documentation: Getting Started

Require the API and set the appropriate db-uri:

(require '[datomic.api :as d])

; If you are using Dev Mode:
(def db-uri "datomic:dev://datomic-transactor:4334/my-datomic/?password=unsafe")

; If you are using PostgreSQL:
(def db-uri "datomic:sql://?jdbc:postgresql://datomic-storage:5432/my-datomic?user=datomic-user&password=unsafe")

If you have restored a backup of the MusicBrainz sample database:

(def conn (d/connect db-uri))

(def db (d/db conn))

(d/q '[:find ?id ?type ?gender
         :in $ ?name
       :where
         [?e :artist/name ?name]
         [?e :artist/gid ?id]
         [?e :artist/type ?teid]
         [?teid :db/ident ?type]
         [?e :artist/gender ?geid]
         [?geid :db/ident ?gender]]
     db
    "Jimi Hendrix")

If you are creating a new database from scratch:

(d/create-database db-uri)

(def conn (d/connect db-uri))

@(d/transact conn [{:db/doc "Hello world"}])

@(d/transact conn [{:db/ident :movie/title
                    :db/valueType :db.type/string
                    :db/cardinality :db.cardinality/one
                    :db/doc "The title of the movie"}

                   {:db/ident :movie/genre
                    :db/valueType :db.type/string
                    :db/cardinality :db.cardinality/one
                    :db/doc "The genre of the movie"}

                   {:db/ident :movie/release-year
                    :db/valueType :db.type/long
                    :db/cardinality :db.cardinality/one
                    :db/doc "The year the movie was released in theaters"}])

@(d/transact conn [{:movie/title "The Goonies"
                    :movie/genre "action/adventure"
                    :movie/release-year 1985}
                   {:movie/title "Commando"
                    :movie/genre "action/adventure"
                    :movie/release-year 1985}
                   {:movie/title "Repo Man"
                    :movie/genre "punk dystopia"
                    :movie/release-year 1984}])

(def db (d/db conn))

(d/q '[:find ?e ?movie-title
       :where [?e :movie/title ?movie-title]]
     db)

To exit the REPL, press Ctrl+D or type:

:repl/quit

Sometimes the REPL insists on hanging; in that case, you can kill the container:

docker compose kill datomic-tools

Dependencies reference:

datomic-pro-docker's People

Contributors

gbaptista avatar

Stargazers

 avatar Matheus Francisco avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.