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
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package.json and package-lock.json
|
||||
COPY package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm ci
|
||||
|
||||
# Copy the rest of the application code
|
||||
COPY . .
|
||||
|
||||
# Build the Next.js application and compile TypeScript
|
||||
RUN npm run build
|
||||
|
||||
# Stage 2: Run the application
|
||||
FROM node:18-alpine AS runner
|
||||
|
||||
RUN apk add --no-cache curl
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package.json and package-lock.json
|
||||
COPY package*.json ./
|
||||
|
||||
# Install only production dependencies
|
||||
RUN npm ci --only=production
|
||||
|
||||
# Copy built application from the builder stage
|
||||
COPY --from=builder /app/.next ./.next
|
||||
COPY --from=builder /app/dist ./dist
|
||||
|
||||
# Start the application
|
||||
CMD ["npm", "start"]
|
||||
|
|
|
@ -4,8 +4,8 @@ import path from "path";
|
|||
|
||||
export default defineConfig({
|
||||
dialect: "sqlite",
|
||||
schema: path.join(__dirname, "server", "db", "schema.ts"),
|
||||
out: path.join(__dirname, "server", "migrations"),
|
||||
schema: path.join("server", "db", "schema.ts"),
|
||||
out: path.join("server", "migrations"),
|
||||
verbose: true,
|
||||
dbCredentials: {
|
||||
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 path from "path";
|
||||
|
||||
const migrationsFolder = path.join(__dirname, "../server/migrations");
|
||||
console.log(migrationsFolder);
|
||||
|
||||
const migrationsFolder = path.join("server/migrations");
|
||||
|
||||
const runMigrations = async () => {
|
||||
console.log("Running migrations...");
|
||||
|
|
|
@ -4,8 +4,6 @@ import * as schema from "@server/db/schema";
|
|||
import environment from "@server/environment";
|
||||
import path from "path";
|
||||
|
||||
console.log("DB PATH IS:", path.join(environment.CONFIG_PATH, "db", "db.sqlite"))
|
||||
|
||||
const sqlite = new Database(
|
||||
path.join(environment.CONFIG_PATH, "db", "db.sqlite"),
|
||||
);
|
||||
|
|
|
@ -13,14 +13,23 @@ const environmentSchema = z.object({
|
|||
? resolvedPath.slice(0, -1)
|
||||
: 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 = {
|
||||
ENVIRONMENT: (process.env.ENVIRONMENT as string) || "dev",
|
||||
LOG_LEVEL: (process.env.LOG_LEVEL as string) || "debug",
|
||||
SAVE_LOGS: (process.env.SAVE_LOGS as string) || "false",
|
||||
CONFIG_PATH:
|
||||
(process.env.CONFIG_PATH as string) || path.join(__dirname, "config"),
|
||||
CONFIG_PATH: (process.env.CONFIG_PATH as string) || path.join("config"),
|
||||
EXTERNAL_PORT: (process.env.EXTERNAL_PORT as string) || "3000",
|
||||
INTERNAL_PORT: (process.env.INTERNAL_PORT as string) || "3001",
|
||||
};
|
||||
|
||||
const parsedConfig = environmentSchema.safeParse(environment);
|
||||
|
|
|
@ -11,8 +11,8 @@ import external from "@server/routers/external";
|
|||
const dev = environment.ENVIRONMENT !== "prod";
|
||||
const app = next({ dev });
|
||||
const handle = app.getRequestHandler();
|
||||
const mainPort = 3000;
|
||||
const internalPort = 3001;
|
||||
const mainPort = environment.EXTERNAL_PORT;
|
||||
const internalPort = environment.INTERNAL_PORT;
|
||||
|
||||
app.prepare().then(() => {
|
||||
// Main server
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue