Skip to content

Instantly share code, notes, and snippets.

@MikeAmputer
Last active May 28, 2024 06:19
Show Gist options
  • Save MikeAmputer/5674e12c3e10103afdfee79974d06429 to your computer and use it in GitHub Desktop.
Save MikeAmputer/5674e12c3e10103afdfee79974d06429 to your computer and use it in GitHub Desktop.
ClickHouse + Postgres + SchemaSpy + Nginx - docker compose example
version: "3.9"
name: clickhouse-postgres-schemaspy-nginx
services:
clickhouse:
image: clickhouse/clickhouse-server:latest
container_name: clickhouse-example
restart: unless-stopped
environment:
- CLICKHOUSE_USER=ch_user
- CLICKHOUSE_PASSWORD=ch_password
- CLICKHOUSE_DB=example_database
expose:
- "8123"
postgres:
image: postgres:latest
container_name: postgres-example
restart: unless-stopped
environment:
- POSTGRES_USER=user_pg
- POSTGRES_PASSWORD=pg_password
- POSTGRES_DB=example_database
expose:
- "5432"
# http://localhost:38080/
# or directly
# http://localhost:38080/clickhouse/index.html
# to recreate schema visualization run this:
# docker start clickhouse-schemaspy-example
clickhouse-schemaspy:
image: schemaspy/schemaspy:snapshot
container_name: clickhouse-schemaspy-example
volumes:
- clickhouse-schema:/output
- ./schemaspy.clickhouse.properties:/config/schemaspy.properties
# download jdbc driver - https://github.com/ClickHouse/clickhouse-java/releases
- ./clickhouse-jdbc-0.6.0-patch5-http.jar:/drivers/clickhouse-jdbc.jar
command: [
"-configFile",
"/config/schemaspy.properties"
]
depends_on:
- clickhouse
# http://localhost:38080/
# or directly
# http://localhost:38080/postgres/index.html
# to recreate schema visualization run this:
# docker start postgres-schemaspy-example
postgres-schemaspy:
image: schemaspy/schemaspy:snapshot
container_name: postgres-schemaspy-example
volumes:
- postgres-schema:/output
- ./schemaspy.postgres.properties:/config/schemaspy.properties
command: [
"-configFile",
"/config/schemaspy.properties"
]
depends_on:
- postgres
# http://localhost:38080/
nginx:
image: nginx:latest
container_name: nginx-example
ports:
- "38080:80"
volumes:
- postgres-schema:/usr/share/nginx/html/postgres:ro
- clickhouse-schema:/usr/share/nginx/html/clickhouse:ro
- ./nginx.html:/usr/share/nginx/html/index.html
- ./nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- clickhouse-schemaspy
- postgres-schemaspy
volumes:
clickhouse-schema:
driver: local
postgres-schema:
driver: local
worker_processes 1;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
server {
listen 80;
location / {
root /usr/share/nginx/html;
index index.html;
}
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Menu</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
table {
width: 35%;
border-collapse: collapse;
margin: 20px 0;
}
th, td {
padding: 10px;
border: 1px solid #ccc;
text-align: left;
}
th {
background-color: #f4f4f4;
}
a {
text-decoration: none;
color: #007BFF;
}
</style>
</head>
<body>
<h1>Databases</h1>
<table>
<thead>
<tr>
<th>Database</th>
<th>Schema</th>
</tr>
</thead>
<tbody>
<tr>
<td>Postgres</td>
<td><a href="/postgres/index.html">Link</a></td>
</tr>
<tr>
<td>Clickhouse</td>
<td><a href="/clickhouse/index.html">Link</a></td>
</tr>
</tbody>
</table>
</body>
</html>
schemaspy.t=clickhouse
schemaspy.host=clickhouse-example
schemaspy.port=8123
schemaspy.db=example_database
schemaspy.u=ch_user
schemaspy.p=ch_password
schemaspy.s=example_database
schemaspy.dp=./drivers/clickhouse-jdbc.jar
schemaspy.t=pgsql11
schemaspy.host=postgres-example
schemaspy.port=5432
schemaspy.db=example_database
schemaspy.u=user_pg
schemaspy.p=pg_password
schemaspy.s=public
@MikeAmputer
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment