Added and updated config for CD with portainer and GitOps
This commit is contained in:
1 parent
3743d17705
commit
35a6863745
4 files changed
+50
-24
No files matched your search
+13
-23
@@ -1,33 +1,23 @@
|
||||
image: oven/bun:alpine
|
||||
|
||||
stages:
|
||||
- build
|
||||
- deploy
|
||||
|
||||
cache:
|
||||
key:
|
||||
files:
|
||||
- bun.lock
|
||||
paths:
|
||||
- .next/cache/
|
||||
- node_modules/
|
||||
|
||||
# Your existing Bun build job goes here...
|
||||
build_job:
|
||||
stage: build
|
||||
# Target the specific runner we just created
|
||||
# ... (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"
|
||||
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||
# This job only runs if the build_job passes successfully
|
||||
needs: ["build_job"]
|
||||
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
|
||||
- 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"
|
||||
+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";
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
/* config options here */
|
||||
output: "standalone",
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
Reference in new issue
Block a user