diff --git a/Dockerfile b/Dockerfile index 3438f16..dc71338 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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" ] \ No newline at end of file +CMD [ "bun", "run", ".output/server/index.mjs" ] diff --git a/hono/db.ts b/hono/db.ts index d908bc0..5c9ed22 100644 --- a/hono/db.ts +++ b/hono/db.ts @@ -1,5 +1,6 @@ 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, @@ -7,7 +8,10 @@ export const pool = new Pool({ 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);