feat: update Dockerfile and docker-compose.yml to use WEB_PORT variable and streamline migration process

This commit is contained in:
2026-04-27 22:49:13 -04:00
parent 4fd6772f2e
commit ad89ad001d
5 changed files with 9 additions and 14 deletions
+1 -1
View File
@@ -6,6 +6,7 @@ Dockerfile*
docker-compose*
README.md
*.log
.DS_Store
.env*
!.env.example
.vscode
@@ -14,4 +15,3 @@ coverage
*.tsbuildinfo
dist
build
+1
View File
@@ -3,6 +3,7 @@
# Runtime
NODE_ENV=production
WEB_PORT=3000
# Auth
# Generate with: openssl rand -base64 32
+5 -3
View File
@@ -16,7 +16,7 @@ ENV NODE_ENV=production \
BETTER_AUTH_URL=http://localhost:3000 \
AUTH_SECRET=docker-build-placeholder-secret-do-not-use \
DATABASE_URL=postgres://postgres:postgres@localhost:5432/postgres
RUN bun run build
RUN bun run build && bun build src/server/db/migrate.ts --target=bun --outfile=migrate.js
FROM base AS release
ENV NODE_ENV=production \
@@ -26,9 +26,11 @@ ENV NODE_ENV=production \
COPY --from=build /usr/src/app/.next/standalone ./
COPY --from=build /usr/src/app/.next/static ./.next/static
COPY --from=build /usr/src/app/public ./public
COPY --from=build /usr/src/app/src/server/db/migrate.ts ./src/server/db/migrate.ts
COPY --from=build /usr/src/app/migrate.js ./migrate.js
COPY --from=build /usr/src/app/drizzle ./drizzle
RUN chmod -R a+rX drizzle migrate.js public
USER bun
EXPOSE 3000
CMD ["bun", "server.js"]
CMD ["sh", "-c", "bun migrate.js && bun server.js"]
+1 -7
View File
@@ -19,12 +19,8 @@ services:
AUTHENTIK_CLIENT_ID: ${AUTHENTIK_CLIENT_ID:-}
AUTHENTIK_CLIENT_SECRET: ${AUTHENTIK_CLIENT_SECRET:-}
AUTHENTIK_ORIGIN: ${AUTHENTIK_ORIGIN:-}
command:
- sh
- -c
- bun src/server/db/migrate.ts && bun server.js
ports:
- "3000:3000"
- "${WEB_PORT:-3000}:3000"
depends_on:
db:
condition: service_healthy
@@ -38,8 +34,6 @@ services:
POSTGRES_DB: ${POSTGRES_DB:-postgres}
volumes:
- beenvoice_pg_data:/var/lib/postgresql/data
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U \"$${POSTGRES_USER}\" -d \"$${POSTGRES_DB}\""]
interval: 5s
+1 -3
View File
@@ -23,7 +23,6 @@ import { migrate } from "drizzle-orm/node-postgres/migrator";
import path from "path";
import fs from "fs";
import crypto from "crypto";
import { fileURLToPath } from "url";
const databaseUrl = process.env.DATABASE_URL;
if (!databaseUrl) {
@@ -31,8 +30,7 @@ if (!databaseUrl) {
process.exit(1);
}
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const migrationsFolder = path.resolve(__dirname, "../../../drizzle");
const migrationsFolder = path.resolve(process.cwd(), "drizzle");
const pool = new Pool({
connectionString: databaseUrl,