Skip to content

Instantly share code, notes, and snippets.

@hden
Last active November 10, 2020 13:28
Show Gist options
  • Save hden/942c19d3e2367fd2e5d757759ae62c4a to your computer and use it in GitHub Desktop.
Save hden/942c19d3e2367fd2e5d757759ae62c4a to your computer and use it in GitHub Desktop.
Dockerized Datomic development environment
AWS_ACCESS_KEY_ID=
AWS_DEFAULT_REGION=
AWS_SECRET_ACCESS_KEY=
AWS_SESSION_TOKEN=
DATOMIC_SYSTEM=

Known Issues

The datomic CLI acts as a proxy to the bastion (a.k.a. access gateway). You might need to restart the process when the local internet connection is not stable (your machine goes to sleep, for example).

See the discussion here: https://forum.datomic.com/t/broken-pipe/1391/3

---
version: '2.4'
services:
clojure:
image: clojure:openjdk-8-tools-deps
working_dir: /workspace
env_file:
- ".env"
volumes:
- ".:/workspace"
- "mvn_cache:/root/.m2"
- "ssh_keys:/root/.ssh"
datomic-access-gateway:
extends:
service: clojure
command: /workspace/bin/datomic client access ${DATOMIC_SYSTEM} --region ${AWS_DEFAULT_REGION}
# Using healthcheck as keep-alive for the TCP connection.
healthcheck:
test: ["CMD", "curl", "-x", "socks5h://localhost:8182", "http://entry.${DATOMIC_SYSTEM}.${AWS_DEFAULT_REGION}.datomic.net:8182/"]
ports:
- "8182:8182"
repl:
extends:
service: clojure
command: clojure -Arebel:dev:test
tty: true
depends_on:
datomic-access-gateway:
condition: service_healthy
# Bridge mode won't work because datomic CLI binds to 127.0.0.1:8182 instead of 0.0.0.0:8182.
# As a workaround, we can force containers to share a network namespace.
# See https://blog.mikesir87.io/2019/03/sharing-network-namespaces-in-docker/
network_mode: service:datomic-access-gateway
bash:
extends:
service: clojure
# Test access gateway connection by the following command:
# `curl -x socks5h://localhost:8182 http://entry.${DATOMIC_SYSTEM}.${AWS_DEFAULT_REGION}.datomic.net:8182/`
# See https://docs.datomic.com/cloud/getting-started/get-connected.html#test-access-gateway
command: bash
tty: true
depends_on:
datomic-access-gateway:
condition: service_healthy
network_mode: service:datomic-access-gateway
volumes:
mvn_cache: {}
ssh_keys: {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment