mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-27 07:16:40 +00:00
16
Dockerfile
16
Dockerfile
@@ -43,23 +43,25 @@ RUN test -f dist/server.mjs
|
|||||||
|
|
||||||
RUN npm run build:cli
|
RUN npm run build:cli
|
||||||
|
|
||||||
|
# Prune dev dependencies and clean up to prepare for copy to runner
|
||||||
|
RUN npm prune --omit=dev && npm cache clean --force
|
||||||
|
|
||||||
FROM node:24-alpine AS runner
|
FROM node:24-alpine AS runner
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Curl used for the health checks
|
# Only curl and tzdata needed at runtime - no build tools!
|
||||||
# Python and build tools needed for better-sqlite3 native compilation
|
RUN apk add --no-cache curl tzdata
|
||||||
RUN apk add --no-cache curl tzdata python3 make g++
|
|
||||||
|
|
||||||
# COPY package.json package-lock.json ./
|
# Copy pre-built node_modules from builder (already pruned to production only)
|
||||||
COPY package*.json ./
|
# This includes the compiled native modules like better-sqlite3
|
||||||
|
COPY --from=builder /app/node_modules ./node_modules
|
||||||
RUN npm ci --omit=dev && npm cache clean --force
|
|
||||||
|
|
||||||
COPY --from=builder /app/.next/standalone ./
|
COPY --from=builder /app/.next/standalone ./
|
||||||
COPY --from=builder /app/.next/static ./.next/static
|
COPY --from=builder /app/.next/static ./.next/static
|
||||||
COPY --from=builder /app/dist ./dist
|
COPY --from=builder /app/dist ./dist
|
||||||
COPY --from=builder /app/init ./dist/init
|
COPY --from=builder /app/init ./dist/init
|
||||||
|
COPY --from=builder /app/package.json ./package.json
|
||||||
|
|
||||||
COPY ./cli/wrapper.sh /usr/local/bin/pangctl
|
COPY ./cli/wrapper.sh /usr/local/bin/pangctl
|
||||||
RUN chmod +x /usr/local/bin/pangctl ./dist/cli.mjs
|
RUN chmod +x /usr/local/bin/pangctl ./dist/cli.mjs
|
||||||
|
|||||||
@@ -6,28 +6,28 @@ import { withReplicas } from "drizzle-orm/pg-core";
|
|||||||
function createDb() {
|
function createDb() {
|
||||||
const config = readConfigFile();
|
const config = readConfigFile();
|
||||||
|
|
||||||
if (!config.postgres) {
|
// check the environment variables for postgres config first before the config file
|
||||||
// check the environment variables for postgres config
|
if (process.env.POSTGRES_CONNECTION_STRING) {
|
||||||
if (process.env.POSTGRES_CONNECTION_STRING) {
|
config.postgres = {
|
||||||
config.postgres = {
|
connection_string: process.env.POSTGRES_CONNECTION_STRING
|
||||||
connection_string: process.env.POSTGRES_CONNECTION_STRING
|
};
|
||||||
};
|
if (process.env.POSTGRES_REPLICA_CONNECTION_STRINGS) {
|
||||||
if (process.env.POSTGRES_REPLICA_CONNECTION_STRINGS) {
|
const replicas =
|
||||||
const replicas =
|
process.env.POSTGRES_REPLICA_CONNECTION_STRINGS.split(",").map(
|
||||||
process.env.POSTGRES_REPLICA_CONNECTION_STRINGS.split(
|
(conn) => ({
|
||||||
","
|
|
||||||
).map((conn) => ({
|
|
||||||
connection_string: conn.trim()
|
connection_string: conn.trim()
|
||||||
}));
|
})
|
||||||
config.postgres.replicas = replicas;
|
);
|
||||||
}
|
config.postgres.replicas = replicas;
|
||||||
} else {
|
|
||||||
throw new Error(
|
|
||||||
"Postgres configuration is missing in the configuration file."
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!config.postgres) {
|
||||||
|
throw new Error(
|
||||||
|
"Postgres configuration is missing in the configuration file."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const connectionString = config.postgres?.connection_string;
|
const connectionString = config.postgres?.connection_string;
|
||||||
const replicaConnections = config.postgres?.replicas || [];
|
const replicaConnections = config.postgres?.replicas || [];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user