mirror of
https://github.com/fosrl/pangolin.git
synced 2026-10-14 16:49:05 +02:00
Reduce image size by pruning stuff and things
Ref https://github.com/orgs/fosrl/discussions/2069
This commit is contained in:
+22
-1
@@ -1,5 +1,7 @@
|
||||
import next from "next";
|
||||
import express from "express";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { parse } from "url";
|
||||
import logger from "@server/logger";
|
||||
import config from "@server/lib/config";
|
||||
@@ -8,9 +10,28 @@ import { stripDuplicateSesions } from "./middlewares/stripDuplicateSessions";
|
||||
const nextPort = config.getRawConfig().server.next_port;
|
||||
|
||||
export async function createNextServer() {
|
||||
const dev = process.env.ENVIRONMENT !== "prod";
|
||||
|
||||
// The image only ships the files Next traced for its standalone output,
|
||||
// which leaves out what is needed to load next.config at runtime. Hand
|
||||
// Next the config resolved at build time instead, the same way the
|
||||
// generated .next/standalone/server.js does.
|
||||
const requiredServerFilesPath = path.join(
|
||||
process.cwd(),
|
||||
".next",
|
||||
"required-server-files.json"
|
||||
);
|
||||
if (!dev && fs.existsSync(requiredServerFilesPath)) {
|
||||
const { config: nextConfig } = JSON.parse(
|
||||
fs.readFileSync(requiredServerFilesPath, "utf8")
|
||||
);
|
||||
process.env.__NEXT_PRIVATE_STANDALONE_CONFIG =
|
||||
JSON.stringify(nextConfig);
|
||||
}
|
||||
|
||||
// const app = next({ dev });
|
||||
const app = next({
|
||||
dev: process.env.ENVIRONMENT !== "prod",
|
||||
dev,
|
||||
turbopack: false
|
||||
});
|
||||
const handle = app.getRequestHandler();
|
||||
|
||||
Reference in New Issue
Block a user