Skip to content

Commit

Permalink
fix: docker image requires postgres cert
Browse files Browse the repository at this point in the history
  • Loading branch information
cybercoder-naj committed Sep 21, 2024
1 parent 421db52 commit 40ca0b4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
FROM oven/bun:1.1.29

RUN mkdir -p /etc/ssl/certs/
RUN echo "$PGCERT" > /etc/ssl/certs/postgres.crt
RUN chmod 600 /etc/ssl/certs/postgres.crt
ENV PGCERT_PATH=/etc/ssl/certs/postgres.crt

WORKDIR /app
COPY package.json bun.lockb ./
RUN bun install --production
COPY . .
RUN bun --bun run build
CMD [ "bun", "run", ".output/server/index.mjs" ]
CMD [ "bun", "run", ".output/server/index.mjs" ]
6 changes: 5 additions & 1 deletion hono/db.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { drizzle } from 'drizzle-orm/node-postgres';
import { Pool } from 'pg';
import fs from 'node:fs';

export const pool = new Pool({
user: process.env.PGUSER,
host: process.env.PGHOST,
database: process.env.PGDB,
password: process.env.PGPASSWORD,
port: +(process.env.PGPORT || 5432),
ssl: true
ssl: {
rejectUnauthorized: true,
ca: fs.readFileSync(process.env.PGCERT_PATH || '').toString()
}
});

export const db = drizzle(pool);

0 comments on commit 40ca0b4

Please sign in to comment.