Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ea8bd46973 | |||
| ff269b1f84 | |||
| afa586c833 | |||
| 9b55c42f35 | |||
| 554f958ba2 | |||
| c9f174e828 | |||
| 8dce4890c4 |
@@ -41,8 +41,14 @@ COPY . .
|
|||||||
# Build application
|
# Build application
|
||||||
RUN pnpm build
|
RUN pnpm build
|
||||||
|
|
||||||
|
# Transpile migrations to JS for production compatibility (ESM requires extensions)
|
||||||
|
RUN npx tsc migrations/*.ts --outDir migrations --module esnext --target esnext --moduleResolution node --esModuleInterop --skipLibCheck || true && \
|
||||||
|
sed -i 's/from "\.\/\([^"]*\)";/from ".\/\1.js";/g' migrations/index.js && \
|
||||||
|
rm migrations/*.ts
|
||||||
|
|
||||||
# Stage 2: Runner
|
# Stage 2: Runner
|
||||||
FROM node:20-alpine AS runner
|
FROM node:20-alpine AS runner
|
||||||
|
# ... [skipping middle part as I'm replacing lines 45-64 in a single block] ...
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install curl for health checks
|
# Install curl for health checks
|
||||||
@@ -61,6 +67,8 @@ ENV NEXT_TELEMETRY_DISABLED=1
|
|||||||
# Copy standalone output and static files
|
# Copy standalone output and static files
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
|
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||||
|
COPY --from=builder --chown=nextjs:nodejs /app/migrations_built ./migrations
|
||||||
|
COPY --from=builder --chown=nextjs:nodejs /app/migrations/*.json ./migrations/
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/cache ./.next/cache
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/cache ./.next/cache
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ CI (Woodpecker)
|
|||||||
https://ci.infra.mintel.me
|
https://ci.infra.mintel.me
|
||||||
|
|
||||||
Container Registry
|
Container Registry
|
||||||
https://registry.infra.mintel.me
|
https://git.infra.mintel.me
|
||||||
|
|
||||||
Errors (GlitchTip)
|
Errors (GlitchTip)
|
||||||
https://errors.infra.mintel.me
|
https://errors.infra.mintel.me
|
||||||
@@ -76,13 +76,13 @@ This directory contains:
|
|||||||
All production images must be built by CI and pushed to the Mintel Registry.
|
All production images must be built by CI and pushed to the Mintel Registry.
|
||||||
|
|
||||||
Registry:
|
Registry:
|
||||||
registry.infra.mintel.me
|
git.infra.mintel.me
|
||||||
|
|
||||||
Image naming:
|
Image naming:
|
||||||
registry.infra.mintel.me/ORG/APP_NAME:TAG
|
git.infra.mintel.me/mmintel/APP_NAME:TAG
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
registry.infra.mintel.me/mintel/mb-grid-solutions:latest
|
git.infra.mintel.me/mmintel/mb-grid-solutions:latest
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -204,8 +204,8 @@ steps:
|
|||||||
build:
|
build:
|
||||||
image: woodpeckerci/plugin-docker
|
image: woodpeckerci/plugin-docker
|
||||||
settings:
|
settings:
|
||||||
registry: registry.infra.mintel.me
|
registry: git.infra.mintel.me
|
||||||
repo: registry.infra.mintel.me/mintel/mb-grid-solutions
|
repo: git.infra.mintel.me/mmintel/mb-grid-solutions
|
||||||
username:
|
username:
|
||||||
from_secret: REGISTRY_USER
|
from_secret: REGISTRY_USER
|
||||||
password:
|
password:
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export const config = {
|
|||||||
// Matcher for all pages and internationalized pathnames
|
// Matcher for all pages and internationalized pathnames
|
||||||
// excluding api, _next, static files, etc.
|
// excluding api, _next, static files, etc.
|
||||||
matcher: [
|
matcher: [
|
||||||
"/((?!api|stats|errors|_next|_vercel|.*\\..*).*)",
|
"/((?!api|admin|stats|errors|_next|_vercel|.*\\..*).*)",
|
||||||
"/",
|
"/",
|
||||||
"/(de)/:path*",
|
"/(de)/:path*",
|
||||||
],
|
],
|
||||||
|
|||||||
1278
migrations/20260227_113637_v1_initial.json
Normal file
1278
migrations/20260227_113637_v1_initial.json
Normal file
File diff suppressed because it is too large
Load Diff
183
migrations/20260227_113637_v1_initial.ts
Normal file
183
migrations/20260227_113637_v1_initial.ts
Normal file
@@ -0,0 +1,183 @@
|
|||||||
|
import { MigrateUpArgs, MigrateDownArgs, sql } from "@payloadcms/db-postgres";
|
||||||
|
|
||||||
|
export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
|
||||||
|
await db.execute(sql`
|
||||||
|
CREATE TABLE "users_sessions" (
|
||||||
|
"_order" integer NOT NULL,
|
||||||
|
"_parent_id" integer NOT NULL,
|
||||||
|
"id" varchar PRIMARY KEY NOT NULL,
|
||||||
|
"created_at" timestamp(3) with time zone,
|
||||||
|
"expires_at" timestamp(3) with time zone NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE "users" (
|
||||||
|
"id" serial PRIMARY KEY NOT NULL,
|
||||||
|
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
||||||
|
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
||||||
|
"email" varchar NOT NULL,
|
||||||
|
"reset_password_token" varchar,
|
||||||
|
"reset_password_expiration" timestamp(3) with time zone,
|
||||||
|
"salt" varchar,
|
||||||
|
"hash" varchar,
|
||||||
|
"login_attempts" numeric DEFAULT 0,
|
||||||
|
"lock_until" timestamp(3) with time zone
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE "media" (
|
||||||
|
"id" serial PRIMARY KEY NOT NULL,
|
||||||
|
"alt" varchar NOT NULL,
|
||||||
|
"prefix" varchar DEFAULT 'mb-grid-solutions/media',
|
||||||
|
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
||||||
|
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
||||||
|
"url" varchar,
|
||||||
|
"thumbnail_u_r_l" varchar,
|
||||||
|
"filename" varchar,
|
||||||
|
"mime_type" varchar,
|
||||||
|
"filesize" numeric,
|
||||||
|
"width" numeric,
|
||||||
|
"height" numeric,
|
||||||
|
"focal_x" numeric,
|
||||||
|
"focal_y" numeric,
|
||||||
|
"sizes_thumbnail_url" varchar,
|
||||||
|
"sizes_thumbnail_width" numeric,
|
||||||
|
"sizes_thumbnail_height" numeric,
|
||||||
|
"sizes_thumbnail_mime_type" varchar,
|
||||||
|
"sizes_thumbnail_filesize" numeric,
|
||||||
|
"sizes_thumbnail_filename" varchar,
|
||||||
|
"sizes_card_url" varchar,
|
||||||
|
"sizes_card_width" numeric,
|
||||||
|
"sizes_card_height" numeric,
|
||||||
|
"sizes_card_mime_type" varchar,
|
||||||
|
"sizes_card_filesize" numeric,
|
||||||
|
"sizes_card_filename" varchar
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE "form_submissions" (
|
||||||
|
"id" serial PRIMARY KEY NOT NULL,
|
||||||
|
"name" varchar NOT NULL,
|
||||||
|
"email" varchar NOT NULL,
|
||||||
|
"company" varchar,
|
||||||
|
"message" varchar NOT NULL,
|
||||||
|
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
||||||
|
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE "pages" (
|
||||||
|
"id" serial PRIMARY KEY NOT NULL,
|
||||||
|
"title" varchar NOT NULL,
|
||||||
|
"slug" varchar NOT NULL,
|
||||||
|
"content" jsonb NOT NULL,
|
||||||
|
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
||||||
|
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE "payload_kv" (
|
||||||
|
"id" serial PRIMARY KEY NOT NULL,
|
||||||
|
"key" varchar NOT NULL,
|
||||||
|
"data" jsonb NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE "payload_locked_documents" (
|
||||||
|
"id" serial PRIMARY KEY NOT NULL,
|
||||||
|
"global_slug" varchar,
|
||||||
|
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
||||||
|
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE "payload_locked_documents_rels" (
|
||||||
|
"id" serial PRIMARY KEY NOT NULL,
|
||||||
|
"order" integer,
|
||||||
|
"parent_id" integer NOT NULL,
|
||||||
|
"path" varchar NOT NULL,
|
||||||
|
"users_id" integer,
|
||||||
|
"media_id" integer,
|
||||||
|
"form_submissions_id" integer,
|
||||||
|
"pages_id" integer
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE "payload_preferences" (
|
||||||
|
"id" serial PRIMARY KEY NOT NULL,
|
||||||
|
"key" varchar,
|
||||||
|
"value" jsonb,
|
||||||
|
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
||||||
|
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE "payload_preferences_rels" (
|
||||||
|
"id" serial PRIMARY KEY NOT NULL,
|
||||||
|
"order" integer,
|
||||||
|
"parent_id" integer NOT NULL,
|
||||||
|
"path" varchar NOT NULL,
|
||||||
|
"users_id" integer
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE "payload_migrations" (
|
||||||
|
"id" serial PRIMARY KEY NOT NULL,
|
||||||
|
"name" varchar,
|
||||||
|
"batch" numeric,
|
||||||
|
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
||||||
|
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
ALTER TABLE "users_sessions" ADD CONSTRAINT "users_sessions_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
|
||||||
|
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_parent_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."payload_locked_documents"("id") ON DELETE cascade ON UPDATE no action;
|
||||||
|
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_users_fk" FOREIGN KEY ("users_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
|
||||||
|
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_media_fk" FOREIGN KEY ("media_id") REFERENCES "public"."media"("id") ON DELETE cascade ON UPDATE no action;
|
||||||
|
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_form_submissions_fk" FOREIGN KEY ("form_submissions_id") REFERENCES "public"."form_submissions"("id") ON DELETE cascade ON UPDATE no action;
|
||||||
|
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_pages_fk" FOREIGN KEY ("pages_id") REFERENCES "public"."pages"("id") ON DELETE cascade ON UPDATE no action;
|
||||||
|
ALTER TABLE "payload_preferences_rels" ADD CONSTRAINT "payload_preferences_rels_parent_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."payload_preferences"("id") ON DELETE cascade ON UPDATE no action;
|
||||||
|
ALTER TABLE "payload_preferences_rels" ADD CONSTRAINT "payload_preferences_rels_users_fk" FOREIGN KEY ("users_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
|
||||||
|
CREATE INDEX "users_sessions_order_idx" ON "users_sessions" USING btree ("_order");
|
||||||
|
CREATE INDEX "users_sessions_parent_id_idx" ON "users_sessions" USING btree ("_parent_id");
|
||||||
|
CREATE INDEX "users_updated_at_idx" ON "users" USING btree ("updated_at");
|
||||||
|
CREATE INDEX "users_created_at_idx" ON "users" USING btree ("created_at");
|
||||||
|
CREATE UNIQUE INDEX "users_email_idx" ON "users" USING btree ("email");
|
||||||
|
CREATE INDEX "media_updated_at_idx" ON "media" USING btree ("updated_at");
|
||||||
|
CREATE INDEX "media_created_at_idx" ON "media" USING btree ("created_at");
|
||||||
|
CREATE UNIQUE INDEX "media_filename_idx" ON "media" USING btree ("filename");
|
||||||
|
CREATE INDEX "media_sizes_thumbnail_sizes_thumbnail_filename_idx" ON "media" USING btree ("sizes_thumbnail_filename");
|
||||||
|
CREATE INDEX "media_sizes_card_sizes_card_filename_idx" ON "media" USING btree ("sizes_card_filename");
|
||||||
|
CREATE INDEX "form_submissions_updated_at_idx" ON "form_submissions" USING btree ("updated_at");
|
||||||
|
CREATE INDEX "form_submissions_created_at_idx" ON "form_submissions" USING btree ("created_at");
|
||||||
|
CREATE INDEX "pages_updated_at_idx" ON "pages" USING btree ("updated_at");
|
||||||
|
CREATE INDEX "pages_created_at_idx" ON "pages" USING btree ("created_at");
|
||||||
|
CREATE UNIQUE INDEX "payload_kv_key_idx" ON "payload_kv" USING btree ("key");
|
||||||
|
CREATE INDEX "payload_locked_documents_global_slug_idx" ON "payload_locked_documents" USING btree ("global_slug");
|
||||||
|
CREATE INDEX "payload_locked_documents_updated_at_idx" ON "payload_locked_documents" USING btree ("updated_at");
|
||||||
|
CREATE INDEX "payload_locked_documents_created_at_idx" ON "payload_locked_documents" USING btree ("created_at");
|
||||||
|
CREATE INDEX "payload_locked_documents_rels_order_idx" ON "payload_locked_documents_rels" USING btree ("order");
|
||||||
|
CREATE INDEX "payload_locked_documents_rels_parent_idx" ON "payload_locked_documents_rels" USING btree ("parent_id");
|
||||||
|
CREATE INDEX "payload_locked_documents_rels_path_idx" ON "payload_locked_documents_rels" USING btree ("path");
|
||||||
|
CREATE INDEX "payload_locked_documents_rels_users_id_idx" ON "payload_locked_documents_rels" USING btree ("users_id");
|
||||||
|
CREATE INDEX "payload_locked_documents_rels_media_id_idx" ON "payload_locked_documents_rels" USING btree ("media_id");
|
||||||
|
CREATE INDEX "payload_locked_documents_rels_form_submissions_id_idx" ON "payload_locked_documents_rels" USING btree ("form_submissions_id");
|
||||||
|
CREATE INDEX "payload_locked_documents_rels_pages_id_idx" ON "payload_locked_documents_rels" USING btree ("pages_id");
|
||||||
|
CREATE INDEX "payload_preferences_key_idx" ON "payload_preferences" USING btree ("key");
|
||||||
|
CREATE INDEX "payload_preferences_updated_at_idx" ON "payload_preferences" USING btree ("updated_at");
|
||||||
|
CREATE INDEX "payload_preferences_created_at_idx" ON "payload_preferences" USING btree ("created_at");
|
||||||
|
CREATE INDEX "payload_preferences_rels_order_idx" ON "payload_preferences_rels" USING btree ("order");
|
||||||
|
CREATE INDEX "payload_preferences_rels_parent_idx" ON "payload_preferences_rels" USING btree ("parent_id");
|
||||||
|
CREATE INDEX "payload_preferences_rels_path_idx" ON "payload_preferences_rels" USING btree ("path");
|
||||||
|
CREATE INDEX "payload_preferences_rels_users_id_idx" ON "payload_preferences_rels" USING btree ("users_id");
|
||||||
|
CREATE INDEX "payload_migrations_updated_at_idx" ON "payload_migrations" USING btree ("updated_at");
|
||||||
|
CREATE INDEX "payload_migrations_created_at_idx" ON "payload_migrations" USING btree ("created_at");`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function down({
|
||||||
|
db,
|
||||||
|
payload,
|
||||||
|
req,
|
||||||
|
}: MigrateDownArgs): Promise<void> {
|
||||||
|
await db.execute(sql`
|
||||||
|
DROP TABLE "users_sessions" CASCADE;
|
||||||
|
DROP TABLE "users" CASCADE;
|
||||||
|
DROP TABLE "media" CASCADE;
|
||||||
|
DROP TABLE "form_submissions" CASCADE;
|
||||||
|
DROP TABLE "pages" CASCADE;
|
||||||
|
DROP TABLE "payload_kv" CASCADE;
|
||||||
|
DROP TABLE "payload_locked_documents" CASCADE;
|
||||||
|
DROP TABLE "payload_locked_documents_rels" CASCADE;
|
||||||
|
DROP TABLE "payload_preferences" CASCADE;
|
||||||
|
DROP TABLE "payload_preferences_rels" CASCADE;
|
||||||
|
DROP TABLE "payload_migrations" CASCADE;`);
|
||||||
|
}
|
||||||
9
migrations/index.ts
Normal file
9
migrations/index.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import * as migration_20260227_113637_v1_initial from "./20260227_113637_v1_initial";
|
||||||
|
|
||||||
|
export const migrations = [
|
||||||
|
{
|
||||||
|
up: migration_20260227_113637_v1_initial.up,
|
||||||
|
down: migration_20260227_113637_v1_initial.down,
|
||||||
|
name: "20260227_113637_v1_initial",
|
||||||
|
},
|
||||||
|
];
|
||||||
Reference in New Issue
Block a user