Skip to content

Commit

Permalink
Initial
Browse files Browse the repository at this point in the history
  • Loading branch information
n2o committed Aug 15, 2024
0 parents commit d2947c4
Show file tree
Hide file tree
Showing 5 changed files with 257 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
HOST=0.0.0.0
ALT_HOST=datomic.datomic
PORT=4334

POSTGRES_HOST=postgres
POSTGRES_PORT=5432
POSTGRES_DB=datomic
POSTGRES_USER=datomic
POSTGRES_PASSWORD=datomic
54 changes: 54 additions & 0 deletions .github/workflows/build-docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "Docker: Build Image"

on:
push:
branches:
- main
tags:
- v*

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
# Push image to GitHub Packages.
docker:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: "arm64"

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha
- name: Build and push Docker images
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
pull: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM openjdk:17-slim

WORKDIR /opt

RUN apt-get update && \
apt-get install -y wget unzip

ENV VERSION 1.0.7075
ENV POSTGRES_VERSION 42.7.3

RUN wget https://datomic-pro-downloads.s3.amazonaws.com/$VERSION/datomic-pro-$VERSION.zip -O datomic-pro-$VERSION.zip

RUN unzip datomic-pro-${VERSION}.zip
RUN mv datomic-pro-${VERSION} datomic
RUN rm datomic-pro-${VERSION}.zip

WORKDIR /opt/datomic

# Remove old postgres dependency and replace it
RUN rm lib/postgresql-*.jar
RUN wget https://repo1.maven.org/maven2/org/postgresql/postgresql/$POSTGRES_VERSION/postgresql-$POSTGRES_VERSION.jar -O lib/postgresql-$POSTGRES_VERSION.jar

COPY postgres-transactor.properties .

EXPOSE 4334

CMD ["bin/transactor", "-Xms4g", "-Xmx4g", "-XX:+UseG1GC", "-XX:MaxGCPauseMillis=50", "postgres-transactor.properties"]
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Dockerized Datomic

This repository contains a Dockerfile for running Datomic in a Docker container.

## Usage

Pass your configuration options to [postgres-transactor.properties](postgres-transactor.properties), which connects to the postgres backend to store the data from the datomic instance.

Then, build the image:

```bash
docker build -t datomic .
```

## Example Scenarios

We use this image as a backend of https://app.schnaq.com. It is installed on a Kubernetes cluster and is used to store the data of the application.

## License
Copyright © 2024 – today schnaq GmbH and Contributors

Distributed under the [MIT](LICENSE) License.
145 changes: 145 additions & 0 deletions postgres-transactor.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
###################################################################

protocol=sql
host=0.0.0.0
alt-host=datomic.datomic
port=8443

###################################################################
# See https://docs.datomic.com/on-prem/storage.html

sql-url=jdbc:postgresql://<host>:5423/datomic
sql-user=<user>
sql-password=<password>

## The Postgres driver is included with Datomic. For other SQL
## databases, you will need to install the driver on the
## transactor classpath, by copying the file into lib/,
## and place the driver on your peer's classpath.
sql-driver-class=org.postgresql.Driver

## Driver specified params, as semicolon-separated pairs.
# Optional
# sql-driver-params=<param1=val1&param2=val2...>

## The query used to validate JDBC connection.
# Optional
# sql-validation-query=select 1



###################################################################
# See https://docs.datomic.com/on-prem/capacity.html


## Recommended settings for -Xmx4g production usage.
memory-index-threshold=32m
memory-index-max=512m
object-cache-max=1g

## Recommended settings for -Xmx1g usage, e.g. dev laptops.
# memory-index-threshold=32m
# memory-index-max=256m
# object-cache-max=128m



## OPTIONAL #######################################################


## Set to false to disable SSL between the peers and the transactor.
# Default: true
# encrypt-channel=true

## Data directory is used for dev: and free: storage, and
## as a temporary directory for all storages.
# data-dir=data

## Transactor will log here, see bin/logback.xml to configure logging.
# log-dir=log

## Transactor will write process pid here on startup
# pid-file=transactor.pid



## OPTIONAL #######################################################
# See https://docs.datomic.com/on-prem/valcache.html
## Valcache configuration.
## Set these valcache properties to a directory on an SSD to enable valcache

# valcache-path=
# valcache-max-gb=



## OPTIONAL #######################################################
# See https://docs.datomic.com/on-prem/storage.html
## Memcached configuration.

# memcached=host:port,host:port,...
# memcached-username=datomic
# memcached-password=datomic



## OPTIONAL #######################################################
# See https://docs.datomic.com/on-prem/capacity.html


## Soft limit on the number of concurrent writes to storage.
# Default: 4, Miniumum: 2
# write-concurrency=4

## Soft limit on the number of concurrent reads to storage.
# Default: 2 times write-concurrency, Miniumum: 2
# read-concurrency=8

## Parallelism in index jobs.
# Default: 1, Maximum: 8
# index-parallelism=1



## OPTIONAL #######################################################
# See https://docs.datomic.com/on-prem/aws.html
## Optional settings for rotating logs to S3
# (Can be auto-generated by bin/datomic ensure-transactor.)

# aws-s3-log-bucket-id=



## OPTIONAL #######################################################
# See https://docs.datomic.com/on-prem/aws.html
## Optional settings for Cloudwatch metrics.
# (Can be auto-generated by bin/datomic ensure-transactor.)

# aws-cloudwatch-region=

## Pick a unique name to distinguish transactor metrics from different systems.
# aws-cloudwatch-dimension-value=your-system-name



## OPTIONAL #######################################################
# See https://docs.datomic.com/on-prem/ha.html


## The transactor will write a heartbeat into storage on this interval.
## A standby transactor will take over if it sees the heartbeat go
## unwritten for 2x this interval. If your transactor load leads to
## long gc pauses, you can increase this number to prevent the standby
## transactor from unnecessarily taking over during a long gc pause.
# Default: 5000, Miniumum: 5000
# heartbeat-interval-msec=5000



## OPTIONAL #######################################################


## The transactor will use this partition for new entities that
## do not explicitly specify a partition.
# Default: :db.part/user
# default-partition=:db.part/user

0 comments on commit d2947c4

Please sign in to comment.