mirror of
https://github.com/soconnor0919/beenvoice.git
synced 2026-05-08 09:38:55 -04:00
feat: update Dockerfile and docker-compose.yml to use WEB_PORT variable and streamline migration process
This commit is contained in:
+1
-1
@@ -6,6 +6,7 @@ Dockerfile*
|
|||||||
docker-compose*
|
docker-compose*
|
||||||
README.md
|
README.md
|
||||||
*.log
|
*.log
|
||||||
|
.DS_Store
|
||||||
.env*
|
.env*
|
||||||
!.env.example
|
!.env.example
|
||||||
.vscode
|
.vscode
|
||||||
@@ -14,4 +15,3 @@ coverage
|
|||||||
*.tsbuildinfo
|
*.tsbuildinfo
|
||||||
dist
|
dist
|
||||||
build
|
build
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
# Runtime
|
# Runtime
|
||||||
NODE_ENV=production
|
NODE_ENV=production
|
||||||
|
WEB_PORT=3000
|
||||||
|
|
||||||
# Auth
|
# Auth
|
||||||
# Generate with: openssl rand -base64 32
|
# Generate with: openssl rand -base64 32
|
||||||
|
|||||||
+5
-3
@@ -16,7 +16,7 @@ ENV NODE_ENV=production \
|
|||||||
BETTER_AUTH_URL=http://localhost:3000 \
|
BETTER_AUTH_URL=http://localhost:3000 \
|
||||||
AUTH_SECRET=docker-build-placeholder-secret-do-not-use \
|
AUTH_SECRET=docker-build-placeholder-secret-do-not-use \
|
||||||
DATABASE_URL=postgres://postgres:postgres@localhost:5432/postgres
|
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
|
FROM base AS release
|
||||||
ENV NODE_ENV=production \
|
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/standalone ./
|
||||||
COPY --from=build /usr/src/app/.next/static ./.next/static
|
COPY --from=build /usr/src/app/.next/static ./.next/static
|
||||||
COPY --from=build /usr/src/app/public ./public
|
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
|
COPY --from=build /usr/src/app/drizzle ./drizzle
|
||||||
|
|
||||||
|
RUN chmod -R a+rX drizzle migrate.js public
|
||||||
|
|
||||||
USER bun
|
USER bun
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
CMD ["bun", "server.js"]
|
CMD ["sh", "-c", "bun migrate.js && bun server.js"]
|
||||||
|
|||||||
+1
-7
@@ -19,12 +19,8 @@ services:
|
|||||||
AUTHENTIK_CLIENT_ID: ${AUTHENTIK_CLIENT_ID:-}
|
AUTHENTIK_CLIENT_ID: ${AUTHENTIK_CLIENT_ID:-}
|
||||||
AUTHENTIK_CLIENT_SECRET: ${AUTHENTIK_CLIENT_SECRET:-}
|
AUTHENTIK_CLIENT_SECRET: ${AUTHENTIK_CLIENT_SECRET:-}
|
||||||
AUTHENTIK_ORIGIN: ${AUTHENTIK_ORIGIN:-}
|
AUTHENTIK_ORIGIN: ${AUTHENTIK_ORIGIN:-}
|
||||||
command:
|
|
||||||
- sh
|
|
||||||
- -c
|
|
||||||
- bun src/server/db/migrate.ts && bun server.js
|
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- "${WEB_PORT:-3000}:3000"
|
||||||
depends_on:
|
depends_on:
|
||||||
db:
|
db:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
@@ -38,8 +34,6 @@ services:
|
|||||||
POSTGRES_DB: ${POSTGRES_DB:-postgres}
|
POSTGRES_DB: ${POSTGRES_DB:-postgres}
|
||||||
volumes:
|
volumes:
|
||||||
- beenvoice_pg_data:/var/lib/postgresql/data
|
- beenvoice_pg_data:/var/lib/postgresql/data
|
||||||
ports:
|
|
||||||
- "5432:5432"
|
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD-SHELL", "pg_isready -U \"$${POSTGRES_USER}\" -d \"$${POSTGRES_DB}\""]
|
test: ["CMD-SHELL", "pg_isready -U \"$${POSTGRES_USER}\" -d \"$${POSTGRES_DB}\""]
|
||||||
interval: 5s
|
interval: 5s
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import { migrate } from "drizzle-orm/node-postgres/migrator";
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import crypto from "crypto";
|
import crypto from "crypto";
|
||||||
import { fileURLToPath } from "url";
|
|
||||||
|
|
||||||
const databaseUrl = process.env.DATABASE_URL;
|
const databaseUrl = process.env.DATABASE_URL;
|
||||||
if (!databaseUrl) {
|
if (!databaseUrl) {
|
||||||
@@ -31,8 +30,7 @@ if (!databaseUrl) {
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
const migrationsFolder = path.resolve(process.cwd(), "drizzle");
|
||||||
const migrationsFolder = path.resolve(__dirname, "../../../drizzle");
|
|
||||||
|
|
||||||
const pool = new Pool({
|
const pool = new Pool({
|
||||||
connectionString: databaseUrl,
|
connectionString: databaseUrl,
|
||||||
|
|||||||
Reference in New Issue
Block a user