diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 13b4497..438d859 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,33 +1,23 @@ -image: oven/bun:alpine - stages: - - build - -cache: - key: - files: - - bun.lock - paths: - - .next/cache/ - - node_modules/ + - build + - deploy +# Your existing Bun build job goes here... build_job: - stage: build - # Target the specific runner we just created - tags: - - nextjs - rules: - - if: $CI_COMMIT_BRANCH == "main" - - if: $CI_PIPELINE_SOURCE == "merge_request_event" - script: - - echo "Installing dependencies..." - - bun ci # 'npm ci' is faster and safer for CI/CD than 'npm install' - - echo "Building the Next.js application..." - - bun run build - # Save the build output so it can be used in later deployment stages - artifacts: - paths: - - .next/ - - public/ - - package.json - expire_in: 1 week + stage: build + # ... (keep your existing build job settings here) + +# The new simplified deployment job +deploy_production: + stage: deploy + image: curlimages/curl:latest # A tiny image just to send the webhook + tags: + - nextjs + rules: + - if: $CI_COMMIT_BRANCH == "main" + # This job only runs if the build_job passes successfully + needs: ["build_job"] + script: + - echo "Triggering Portainer GitOps Webhook..." + # Replace the URL below with your actual Portainer webhook URL + - curl -X POST "https://portainer.vpn.pascalyazid.com/api/stacks/webhooks/e73812d9-cf5e-4ac4-8648-53f7611b41c8" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a95d2b5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM oven/bun:alpine AS base + +# Step 1. Install dependencies +FROM base AS deps +WORKDIR /app +COPY package.json bun.lock* ./ +RUN bun install --frozen-lockfile + +# Step 2. Rebuild the source code +FROM base AS builder +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . +RUN bun run build + +# Step 3. Production image +FROM base AS runner +WORKDIR /app +ENV NODE_ENV=production + +COPY --from=builder /app/public ./public +COPY --from=builder /app/.next/standalone ./ +COPY --from=builder /app/.next/static ./.next/static + +EXPOSE 3000 +ENV PORT=3000 +CMD ["bun", "server.js"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..e5f588a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +services: + web: + build: . + image: nextjs-portfolio:latest + container_name: nextjs-portfolio + pull_policy: build + restart: always + ports: + - "3000:3000" diff --git a/next.config.ts b/next.config.ts index e9ffa30..12cecbe 100644 --- a/next.config.ts +++ b/next.config.ts @@ -1,7 +1,7 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { - /* config options here */ + output: "standalone", }; export default nextConfig;