Skip to content

Commit 497b861

Browse files
committed
initial commit
0 parents  commit 497b861

File tree

17 files changed

+2571
-0
lines changed

17 files changed

+2571
-0
lines changed

.github/workflows/custom.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/SchemaStore/schemastore/refs/heads/master/src/schemas/json/github-workflow.json
2+
name: Run with Postgres
3+
4+
on:
5+
workflow_dispatch:
6+
7+
jobs:
8+
run:
9+
runs-on: ubuntu-latest
10+
11+
services:
12+
postgres:
13+
image: postgres:18beta1-alpine
14+
env:
15+
POSTGRES_PASSWORD: 123
16+
POSTGRES_DB: testing
17+
ports:
18+
- 5432:5432
19+
options: >-
20+
--health-cmd="pg_isready"
21+
--health-interval=10s
22+
--health-timeout=5s
23+
--health-retries=5
24+
--name postgres
25+
--entrypoint postgres
26+
volumes:
27+
- /tmp/postgres_logs:/var/log/postgresql
28+
command: >
29+
-c shared_preload_libraries=auto_explain
30+
-c auto_explain.log_min_duration=0
31+
-c auto_explain.log_analyze=true
32+
-c auto_explain.log_verbose=true
33+
-c auto_explain.log_buffers=true
34+
-c auto_explain.log_format=json
35+
-c logging_collector=on
36+
-c log_directory='/var/log/postgresql'
37+
-c log_filename='postgres.log'
38+
39+
steps:
40+
- uses: actions/checkout@v3
41+
42+
- name: Wait for Postgres
43+
run: |
44+
until pg_isready -h localhost -U postgres; do sleep 1; done
45+
46+
- name: Apply SQL file
47+
run: |
48+
psql -h localhost -U postgres -d testing -f bootstrap.sql
49+
env:
50+
PGPASSWORD: 123
51+
52+
- name: Copy Postgres logs
53+
run: |
54+
docker cp postgres:/var/log/postgresql/postgres.log /tmp/postgres.log
55+
56+
- name: Run local GitHub Action
57+
uses: .
58+
with:
59+
POSTGRES_URL: http://postgres:123@postgres:5432/testing
60+
log-path: /tmp/postgres.log

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
out.html
2+
postgres.log

Dockerfile

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Development stage
2+
FROM denoland/deno:alpine AS development
3+
4+
# Install pgbadger dependencies
5+
RUN apk add --no-cache \
6+
perl \
7+
perl-text-csv-xs \
8+
wget \
9+
make \
10+
git
11+
12+
# Download, build, and install pgBadger
13+
ARG PGBADGER_VERSION=12.3
14+
WORKDIR /tmp
15+
RUN wget https://github.com/darold/pgbadger/archive/v${PGBADGER_VERSION}.tar.gz && \
16+
tar -xzf v${PGBADGER_VERSION}.tar.gz && \
17+
cd pgbadger-${PGBADGER_VERSION} && \
18+
perl Makefile.PL && \
19+
make && \
20+
make install && \
21+
rm -rf /tmp/pgbadger*
22+
23+
# Set working directory
24+
WORKDIR /app
25+
26+
# Copy dependency files
27+
COPY deno.json deno.lock* ./
28+
29+
# Cache dependencies
30+
RUN deno cache main.ts
31+
32+
# Copy source code
33+
COPY . .
34+
35+
# Expose port for development server (if needed)
36+
EXPOSE 8000
37+
38+
# Development command with hot reload
39+
CMD ["deno", "task", "dev"]
40+
41+
# Production stage
42+
FROM denoland/deno:alpine AS production
43+
44+
# Install pgbadger dependencies
45+
RUN apk add --no-cache \
46+
perl \
47+
wget \
48+
make \
49+
git
50+
51+
# Download, build, and install pgBadger
52+
ARG PGBADGER_VERSION=12.3
53+
WORKDIR /tmp
54+
RUN wget https://github.com/darold/pgbadger/archive/v${PGBADGER_VERSION}.tar.gz && \
55+
tar -xzf v${PGBADGER_VERSION}.tar.gz && \
56+
cd pgbadger-${PGBADGER_VERSION} && \
57+
perl Makefile.PL && \
58+
make && \
59+
make install && \
60+
rm -rf /tmp/pgbadger*
61+
62+
RUN /usr/bin/perl -MCPAN -e'install Text::CSV_XS'
63+
# Set working directory
64+
WORKDIR /app
65+
66+
# Copy dependency files
67+
COPY deno.json deno.lock* ./
68+
69+
# Cache dependencies
70+
RUN deno cache main.ts
71+
72+
# Copy source code
73+
COPY . .
74+
75+
# Compile the application
76+
RUN deno compile --allow-run --allow-read --allow-write --allow-env --allow-net main.ts -o analyzer
77+
78+
# Production command
79+
CMD ["/app/analyzer"]

Dockerfile.dev

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FROM denoland/deno:alpine
2+
3+
# Install pgbadger dependencies
4+
RUN apk add --no-cache \
5+
perl \
6+
wget \
7+
make \
8+
git
9+
10+
# Download, build, and install pgBadger
11+
ARG PGBADGER_VERSION=13.1
12+
WORKDIR /tmp
13+
RUN wget https://github.com/darold/pgbadger/archive/v${PGBADGER_VERSION}.tar.gz && \
14+
tar -xzf v${PGBADGER_VERSION}.tar.gz && \
15+
cd pgbadger-${PGBADGER_VERSION} && \
16+
perl Makefile.PL && \
17+
make && \
18+
make install && \
19+
rm -rf /tmp/pgbadger*
20+
21+
# RUN curl -L https://github.com/supabase-community/postgres-language-server/releases/download/<version>/postgrestools_aarch64-apple-darwin -o postgrestools
22+
# RUN chmod +x postgrestools
23+
24+
WORKDIR /app
25+
26+
# Copy dependency files
27+
COPY deno.json deno.lock* ./
28+
29+
RUN deno install --frozen-lockfile
30+
# Cache dependencies
31+
# RUN deno cache main.ts
32+
33+
# Development command
34+
CMD ["deno", "run", "dev"]

actions.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# code=yaml
2+
# yaml-language-server: $schema=https://raw.githubusercontent.com/SchemaStore/schemastore/refs/heads/master/src/schemas/json/github-action.json
3+
4+
name: "Query Doctor"
5+
description: "Query Doctor"
6+
7+
inputs:
8+
log-path:
9+
description: "Path to the Postgres logs"
10+
required: true
11+
postgres-url:
12+
description: "Postgres URL"
13+
required: true
14+
15+
runs:
16+
using: "docker"
17+
image: "Dockerfile"

0 commit comments

Comments
 (0)