From b270cbaba4224a33bb912e00497485cbf53475ab Mon Sep 17 00:00:00 2001 From: ismail Date: Mon, 2 Feb 2026 19:35:49 +0100 Subject: [PATCH] fix permissions and db --- Dockerfile.prod | 13 +++++++------ schemas/init.sql | 4 +++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Dockerfile.prod b/Dockerfile.prod index 5743964..a1fc427 100644 --- a/Dockerfile.prod +++ b/Dockerfile.prod @@ -35,20 +35,21 @@ WORKDIR /app ENV NODE_ENV=production ENV NEXT_TELEMETRY_DISABLED=1 -RUN addgroup --system --gid 1001 nodejs -RUN adduser --system --uid 1001 nextjs +# Use existing node user (UID 1000) to match host permissions +# RUN addgroup --system --gid 1001 nodejs +# RUN adduser --system --uid 1001 nextjs COPY --from=builder /app/public ./public # Set the correct permission for prerender cache RUN mkdir .next -RUN chown nextjs:nodejs .next +RUN chown node:node .next # Automatically leverage output traces to reduce image size -COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ -COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static +COPY --from=builder --chown=node:node /app/.next/standalone ./ +COPY --from=builder --chown=node:node /app/.next/static ./.next/static -USER nextjs +USER node EXPOSE 3000 diff --git a/schemas/init.sql b/schemas/init.sql index 4a4d4e6..d2c3ea2 100644 --- a/schemas/init.sql +++ b/schemas/init.sql @@ -46,9 +46,11 @@ CREATE TABLE IF NOT EXISTS categories ( description TEXT, image_url VARCHAR(500), show_on_homepage BOOLEAN DEFAULT FALSE, + parent_id INT DEFAULT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - INDEX idx_name (name) + INDEX idx_name (name), + FOREIGN KEY (parent_id) REFERENCES categories(id) ON DELETE SET NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- 6. Create products table (Full version)