Added and updated config for CD with portainer and GitOps
This commit is contained in:
1 parent
3743d17705
commit
35a6863745
4 files changed
+57
-31
No files matched your search
+20
-30
@@ -1,33 +1,23 @@
|
|||||||
image: oven/bun:alpine
|
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- build
|
- build
|
||||||
|
- deploy
|
||||||
cache:
|
|
||||||
key:
|
|
||||||
files:
|
|
||||||
- bun.lock
|
|
||||||
paths:
|
|
||||||
- .next/cache/
|
|
||||||
- node_modules/
|
|
||||||
|
|
||||||
|
# Your existing Bun build job goes here...
|
||||||
build_job:
|
build_job:
|
||||||
stage: build
|
stage: build
|
||||||
# Target the specific runner we just created
|
# ... (keep your existing build job settings here)
|
||||||
tags:
|
|
||||||
- nextjs
|
# The new simplified deployment job
|
||||||
rules:
|
deploy_production:
|
||||||
- if: $CI_COMMIT_BRANCH == "main"
|
stage: deploy
|
||||||
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
image: curlimages/curl:latest # A tiny image just to send the webhook
|
||||||
script:
|
tags:
|
||||||
- echo "Installing dependencies..."
|
- nextjs
|
||||||
- bun ci # 'npm ci' is faster and safer for CI/CD than 'npm install'
|
rules:
|
||||||
- echo "Building the Next.js application..."
|
- if: $CI_COMMIT_BRANCH == "main"
|
||||||
- bun run build
|
# This job only runs if the build_job passes successfully
|
||||||
# Save the build output so it can be used in later deployment stages
|
needs: ["build_job"]
|
||||||
artifacts:
|
script:
|
||||||
paths:
|
- echo "Triggering Portainer GitOps Webhook..."
|
||||||
- .next/
|
# Replace the URL below with your actual Portainer webhook URL
|
||||||
- public/
|
- curl -X POST "https://portainer.vpn.pascalyazid.com/api/stacks/webhooks/e73812d9-cf5e-4ac4-8648-53f7611b41c8"
|
||||||
- package.json
|
|
||||||
expire_in: 1 week
|
|
||||||
+27
@@ -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"]
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
services:
|
||||||
|
web:
|
||||||
|
build: .
|
||||||
|
image: nextjs-portfolio:latest
|
||||||
|
container_name: nextjs-portfolio
|
||||||
|
pull_policy: build
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
import type { NextConfig } from "next";
|
import type { NextConfig } from "next";
|
||||||
|
|
||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
/* config options here */
|
output: "standalone",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default nextConfig;
|
export default nextConfig;
|
||||||
Reference in new issue
Block a user