mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-09 21:44:51 +02:00
clean up environment and paths
This commit is contained in:
parent
327175a799
commit
db76769fb7
7 changed files with 16 additions and 25 deletions
|
@ -1,4 +0,0 @@
|
||||||
ENVIRONMENT=dev
|
|
||||||
LOG_LEVEL=debug
|
|
||||||
SAVE_LOGS=false
|
|
||||||
CONFIG_PATH=./config
|
|
10
Dockerfile
10
Dockerfile
|
@ -1,36 +1,26 @@
|
||||||
# Stage 1: Build the application
|
|
||||||
FROM node:18-alpine AS builder
|
FROM node:18-alpine AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy package.json and package-lock.json
|
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|
||||||
# Install dependencies
|
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
|
|
||||||
# Copy the rest of the application code
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Build the Next.js application and compile TypeScript
|
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Stage 2: Run the application
|
|
||||||
FROM node:18-alpine AS runner
|
FROM node:18-alpine AS runner
|
||||||
|
|
||||||
RUN apk add --no-cache curl
|
RUN apk add --no-cache curl
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy package.json and package-lock.json
|
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|
||||||
# Install only production dependencies
|
|
||||||
RUN npm ci --only=production
|
RUN npm ci --only=production
|
||||||
|
|
||||||
# Copy built application from the builder stage
|
|
||||||
COPY --from=builder /app/.next ./.next
|
COPY --from=builder /app/.next ./.next
|
||||||
COPY --from=builder /app/dist ./dist
|
COPY --from=builder /app/dist ./dist
|
||||||
|
|
||||||
# Start the application
|
|
||||||
CMD ["npm", "start"]
|
CMD ["npm", "start"]
|
||||||
|
|
|
@ -4,8 +4,8 @@ import path from "path";
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
dialect: "sqlite",
|
dialect: "sqlite",
|
||||||
schema: path.join(__dirname, "server", "db", "schema.ts"),
|
schema: path.join("server", "db", "schema.ts"),
|
||||||
out: path.join(__dirname, "server", "migrations"),
|
out: path.join("server", "migrations"),
|
||||||
verbose: true,
|
verbose: true,
|
||||||
dbCredentials: {
|
dbCredentials: {
|
||||||
url: path.join(environment.CONFIG_PATH, "db", "db.sqlite"),
|
url: path.join(environment.CONFIG_PATH, "db", "db.sqlite"),
|
||||||
|
|
|
@ -2,9 +2,7 @@ import { migrate } from "drizzle-orm/better-sqlite3/migrator";
|
||||||
import db from "@server/db";
|
import db from "@server/db";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
|
||||||
const migrationsFolder = path.join(__dirname, "../server/migrations");
|
const migrationsFolder = path.join("server/migrations");
|
||||||
console.log(migrationsFolder);
|
|
||||||
|
|
||||||
|
|
||||||
const runMigrations = async () => {
|
const runMigrations = async () => {
|
||||||
console.log("Running migrations...");
|
console.log("Running migrations...");
|
||||||
|
|
|
@ -4,8 +4,6 @@ import * as schema from "@server/db/schema";
|
||||||
import environment from "@server/environment";
|
import environment from "@server/environment";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
|
||||||
console.log("DB PATH IS:", path.join(environment.CONFIG_PATH, "db", "db.sqlite"))
|
|
||||||
|
|
||||||
const sqlite = new Database(
|
const sqlite = new Database(
|
||||||
path.join(environment.CONFIG_PATH, "db", "db.sqlite"),
|
path.join(environment.CONFIG_PATH, "db", "db.sqlite"),
|
||||||
);
|
);
|
||||||
|
|
|
@ -13,14 +13,23 @@ const environmentSchema = z.object({
|
||||||
? resolvedPath.slice(0, -1)
|
? resolvedPath.slice(0, -1)
|
||||||
: resolvedPath;
|
: resolvedPath;
|
||||||
}),
|
}),
|
||||||
|
EXTERNAL_PORT: z
|
||||||
|
.string()
|
||||||
|
.transform((val) => parseInt(val, 10))
|
||||||
|
.pipe(z.number()),
|
||||||
|
INTERNAL_PORT: z
|
||||||
|
.string()
|
||||||
|
.transform((val) => parseInt(val, 10))
|
||||||
|
.pipe(z.number()),
|
||||||
});
|
});
|
||||||
|
|
||||||
const environment = {
|
const environment = {
|
||||||
ENVIRONMENT: (process.env.ENVIRONMENT as string) || "dev",
|
ENVIRONMENT: (process.env.ENVIRONMENT as string) || "dev",
|
||||||
LOG_LEVEL: (process.env.LOG_LEVEL as string) || "debug",
|
LOG_LEVEL: (process.env.LOG_LEVEL as string) || "debug",
|
||||||
SAVE_LOGS: (process.env.SAVE_LOGS as string) || "false",
|
SAVE_LOGS: (process.env.SAVE_LOGS as string) || "false",
|
||||||
CONFIG_PATH:
|
CONFIG_PATH: (process.env.CONFIG_PATH as string) || path.join("config"),
|
||||||
(process.env.CONFIG_PATH as string) || path.join(__dirname, "config"),
|
EXTERNAL_PORT: (process.env.EXTERNAL_PORT as string) || "3000",
|
||||||
|
INTERNAL_PORT: (process.env.INTERNAL_PORT as string) || "3001",
|
||||||
};
|
};
|
||||||
|
|
||||||
const parsedConfig = environmentSchema.safeParse(environment);
|
const parsedConfig = environmentSchema.safeParse(environment);
|
||||||
|
|
|
@ -11,8 +11,8 @@ import external from "@server/routers/external";
|
||||||
const dev = environment.ENVIRONMENT !== "prod";
|
const dev = environment.ENVIRONMENT !== "prod";
|
||||||
const app = next({ dev });
|
const app = next({ dev });
|
||||||
const handle = app.getRequestHandler();
|
const handle = app.getRequestHandler();
|
||||||
const mainPort = 3000;
|
const mainPort = environment.EXTERNAL_PORT;
|
||||||
const internalPort = 3001;
|
const internalPort = environment.INTERNAL_PORT;
|
||||||
|
|
||||||
app.prepare().then(() => {
|
app.prepare().then(() => {
|
||||||
// Main server
|
// Main server
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue