diff --git a/.env.example b/.env.example deleted file mode 100644 index 50cb0bd1..00000000 --- a/.env.example +++ /dev/null @@ -1,4 +0,0 @@ -ENVIRONMENT=dev -LOG_LEVEL=debug -SAVE_LOGS=false -CONFIG_PATH=./config diff --git a/Dockerfile b/Dockerfile index 6c17c34c..25f00cb8 100644 --- a/Dockerfile +++ b/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"] diff --git a/drizzle.config.ts b/drizzle.config.ts index 782e1c98..911d35af 100644 --- a/drizzle.config.ts +++ b/drizzle.config.ts @@ -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"), diff --git a/scripts/migrate.ts b/scripts/migrate.ts index 4ee436d5..d39f4ae9 100644 --- a/scripts/migrate.ts +++ b/scripts/migrate.ts @@ -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..."); diff --git a/server/db/index.ts b/server/db/index.ts index 2f778ff8..206a4d24 100644 --- a/server/db/index.ts +++ b/server/db/index.ts @@ -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"), ); diff --git a/server/environment.ts b/server/environment.ts index 7001e2f2..09521f18 100644 --- a/server/environment.ts +++ b/server/environment.ts @@ -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); diff --git a/server/index.ts b/server/index.ts index f5a7190e..706e7378 100644 --- a/server/index.ts +++ b/server/index.ts @@ -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