REFACTOR(repo): simplify project structure
- Move services/nextjs/ to nextjs/ - Move Dockerfile.prod to Dockerfile at root - Remove deploy/ folder (K8s manifests moved to K3S-HOME/web-apps) - Remove .gitea/ workflows - Update GitHub Actions for new structure - Remove develop branch triggers
@@ -1,191 +0,0 @@
|
||||
name: Build Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, develop]
|
||||
tags:
|
||||
- 'v*'
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
REGISTRY: gitea0213.kro.kr
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
DOCKER_HOST: tcp://172.17.0.1:2375
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-24.04-arm
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
|
||||
outputs:
|
||||
image-tag: ${{ steps.meta.outputs.tags }}
|
||||
image-digest: ${{ steps.build.outputs.digest }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Log in to Gitea Container Registry
|
||||
run: |
|
||||
echo "${{ secrets.GITEAREGISTRY }}" | docker login ${{ env.REGISTRY }} -u bluemayne --password-stdin
|
||||
|
||||
- name: Lowercase repository name
|
||||
id: lowercase
|
||||
run: |
|
||||
echo "repo=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Extract metadata (tags, labels)
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ steps.lowercase.outputs.repo }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=sha,prefix={{branch}}-sha-,format=long
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
|
||||
- name: Build and push Docker image
|
||||
id: build
|
||||
run: |
|
||||
TAGS="${{ steps.meta.outputs.tags }}"
|
||||
|
||||
# Build the image
|
||||
docker build \
|
||||
-t $(echo "$TAGS" | head -n 1) \
|
||||
-f ./deploy/docker/Dockerfile.prod \
|
||||
./services/nextjs
|
||||
|
||||
# Tag all versions
|
||||
FIRST_TAG=$(echo "$TAGS" | head -n 1)
|
||||
echo "$TAGS" | while read tag; do
|
||||
if [ "$tag" != "$FIRST_TAG" ]; then
|
||||
docker tag "$FIRST_TAG" "$tag"
|
||||
fi
|
||||
done
|
||||
|
||||
# Push all tags
|
||||
echo "$TAGS" | while read tag; do
|
||||
docker push "$tag"
|
||||
done
|
||||
|
||||
# Get digest
|
||||
DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}' "$FIRST_TAG" | cut -d'@' -f2)
|
||||
echo "digest=$DIGEST" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Extract SHA tag
|
||||
id: extract-tag
|
||||
run: |
|
||||
# Extract the SHA-based tag from the tags list
|
||||
TAGS="${{ steps.meta.outputs.tags }}"
|
||||
echo "All tags:"
|
||||
echo "$TAGS"
|
||||
echo "---"
|
||||
|
||||
# Get commit SHA (full 40 characters)
|
||||
COMMIT_SHA="${{ github.sha }}"
|
||||
|
||||
# Get current branch name
|
||||
BRANCH_NAME="${{ github.ref_name }}"
|
||||
echo "Branch: $BRANCH_NAME"
|
||||
|
||||
# Method 1: Extract the full SHA tag from docker/metadata-action output
|
||||
# docker/metadata-action creates: <branch>-sha-<full-40-char-sha>
|
||||
SHA_TAG=$(echo "$TAGS" | grep -oE "${BRANCH_NAME}-sha-[a-f0-9]{40}" | head -n 1)
|
||||
|
||||
# Method 2: If not found, try to extract any branch-sha- tag (fallback)
|
||||
if [ -z "$SHA_TAG" ]; then
|
||||
SHA_TAG=$(echo "$TAGS" | grep -oE "${BRANCH_NAME}-sha-[a-f0-9]+" | head -n 1)
|
||||
if [ -n "$SHA_TAG" ]; then
|
||||
echo "⚠️ Found SHA tag (may not be full 40 chars): $SHA_TAG"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Method 3: Fallback to commit SHA directly (construct the tag)
|
||||
if [ -z "$SHA_TAG" ]; then
|
||||
SHA_TAG="${BRANCH_NAME}-sha-$COMMIT_SHA"
|
||||
echo "⚠️ Could not extract from tags, using commit SHA: $SHA_TAG"
|
||||
fi
|
||||
|
||||
if [ -z "$SHA_TAG" ]; then
|
||||
echo "❌ ERROR: Failed to extract SHA tag"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "sha-tag=$SHA_TAG" >> $GITHUB_OUTPUT
|
||||
echo "✅ Extracted SHA tag: $SHA_TAG"
|
||||
|
||||
- name: Update kustomization with new image tag
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEAREGISTRYTOKEN }}
|
||||
run: |
|
||||
git config --global user.name "gitea-actions[bot]"
|
||||
git config --global user.email "gitea-actions[bot]@users.noreply.gitea.com"
|
||||
|
||||
# Validate that SHA_TAG is not empty
|
||||
SHA_TAG="${{ steps.extract-tag.outputs.sha-tag }}"
|
||||
if [ -z "$SHA_TAG" ]; then
|
||||
echo "❌ ERROR: SHA_TAG is empty, cannot update kustomization"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Determine overlay based on branch
|
||||
BRANCH_NAME="${{ github.ref_name }}"
|
||||
if [ "$BRANCH_NAME" = "main" ]; then
|
||||
OVERLAY="prod"
|
||||
elif [ "$BRANCH_NAME" = "develop" ]; then
|
||||
OVERLAY="dev"
|
||||
else
|
||||
echo "⚠️ Unknown branch: $BRANCH_NAME, skipping kustomization update"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
KUSTOMIZATION_FILE="deploy/k8s/overlays/$OVERLAY/kustomization.yaml"
|
||||
|
||||
# Check if kustomization file has images section
|
||||
if grep -q "images:" "$KUSTOMIZATION_FILE"; then
|
||||
echo "📝 Updating $KUSTOMIZATION_FILE with tag: $SHA_TAG"
|
||||
|
||||
# Update kustomization.yaml with new image tag
|
||||
# Handle both cases: newTag: (with value) and newTag: (empty)
|
||||
sed -i.bak "s|newTag:.*|newTag: $SHA_TAG|" "$KUSTOMIZATION_FILE"
|
||||
|
||||
# Verify the update was successful
|
||||
if grep -q "newTag: $SHA_TAG" "$KUSTOMIZATION_FILE"; then
|
||||
echo "✅ Successfully updated kustomization.yaml"
|
||||
rm -f "$KUSTOMIZATION_FILE.bak"
|
||||
else
|
||||
echo "❌ ERROR: Failed to update kustomization.yaml"
|
||||
cat "$KUSTOMIZATION_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Commit and push if there are changes
|
||||
if git diff --quiet; then
|
||||
echo "No changes to commit"
|
||||
else
|
||||
git add "$KUSTOMIZATION_FILE"
|
||||
git commit -m "Update $OVERLAY image to $SHA_TAG"
|
||||
git push
|
||||
echo "✅ Kustomization updated with new image tag: $SHA_TAG"
|
||||
fi
|
||||
else
|
||||
echo "ℹ️ $OVERLAY overlay uses base image (latest tag), skipping kustomization update"
|
||||
echo " Image built with tag: $SHA_TAG"
|
||||
fi
|
||||
|
||||
- name: Display image information
|
||||
run: |
|
||||
echo "✅ Image built and pushed successfully!"
|
||||
echo "📦 Image tags:"
|
||||
echo "${{ steps.meta.outputs.tags }}"
|
||||
echo "🔖 SHA tag: ${{ steps.extract-tag.outputs.sha-tag }}"
|
||||
echo "🔖 Digest: ${{ steps.build.outputs.digest }}"
|
||||
echo ""
|
||||
echo "🚀 Kustomization updated with new image tag"
|
||||
echo " ArgoCD will automatically detect and deploy this new image"
|
||||
echo " Monitor deployment at your ArgoCD dashboard"
|
||||
@@ -1,45 +0,0 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, develop]
|
||||
pull_request:
|
||||
branches: [main, develop]
|
||||
|
||||
jobs:
|
||||
lint-and-build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
cache-dependency-path: services/nextjs/package-lock.json
|
||||
|
||||
- name: Install dependencies
|
||||
working-directory: services/nextjs
|
||||
run: npm ci
|
||||
|
||||
- name: Run ESLint
|
||||
working-directory: services/nextjs
|
||||
run: npm run lint
|
||||
|
||||
- name: Build Next.js application
|
||||
working-directory: services/nextjs
|
||||
run: npm run build
|
||||
env:
|
||||
NEXT_TELEMETRY_DISABLED: 1
|
||||
|
||||
- name: Check build output
|
||||
working-directory: services/nextjs
|
||||
run: |
|
||||
if [ ! -d ".next" ]; then
|
||||
echo "Build failed: .next directory not found"
|
||||
exit 1
|
||||
fi
|
||||
echo "✅ Build completed successfully"
|
||||
126
.github/workflows/build.yml
vendored
@@ -2,7 +2,7 @@ name: Build Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, develop]
|
||||
branches: [main]
|
||||
tags:
|
||||
- 'v*'
|
||||
workflow_dispatch:
|
||||
@@ -15,7 +15,7 @@ jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-24.04-arm
|
||||
permissions:
|
||||
contents: write
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
outputs:
|
||||
@@ -47,19 +47,17 @@ jobs:
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ steps.lowercase.outputs.repo }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=sha,prefix=sha-,format=long
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=sha,prefix={{branch}}-sha-,format=long
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
|
||||
- name: Build and push Docker image
|
||||
id: build
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./services/nextjs
|
||||
file: ./deploy/docker/Dockerfile.prod
|
||||
context: ./nextjs
|
||||
file: ./Dockerfile
|
||||
push: true
|
||||
platforms: linux/arm64
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
@@ -67,115 +65,9 @@ jobs:
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
- name: Extract SHA tag
|
||||
id: extract-tag
|
||||
run: |
|
||||
# Extract the SHA-based tag from the tags list
|
||||
TAGS="${{ steps.meta.outputs.tags }}"
|
||||
echo "All tags:"
|
||||
echo "$TAGS"
|
||||
echo "---"
|
||||
|
||||
# Get commit SHA (full 40 characters)
|
||||
COMMIT_SHA="${{ github.sha }}"
|
||||
|
||||
# Get current branch name
|
||||
BRANCH_NAME="${{ github.ref_name }}"
|
||||
echo "Branch: $BRANCH_NAME"
|
||||
|
||||
# Method 1: Extract the full SHA tag from docker/metadata-action output
|
||||
# docker/metadata-action creates: <branch>-sha-<full-40-char-sha>
|
||||
SHA_TAG=$(echo "$TAGS" | grep -oE "${BRANCH_NAME}-sha-[a-f0-9]{40}" | head -n 1)
|
||||
|
||||
# Method 2: If not found, try to extract any branch-sha- tag (fallback)
|
||||
if [ -z "$SHA_TAG" ]; then
|
||||
SHA_TAG=$(echo "$TAGS" | grep -oE "${BRANCH_NAME}-sha-[a-f0-9]+" | head -n 1)
|
||||
if [ -n "$SHA_TAG" ]; then
|
||||
echo "⚠️ Found SHA tag (may not be full 40 chars): $SHA_TAG"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Method 3: Fallback to commit SHA directly (construct the tag)
|
||||
if [ -z "$SHA_TAG" ]; then
|
||||
SHA_TAG="${BRANCH_NAME}-sha-$COMMIT_SHA"
|
||||
echo "⚠️ Could not extract from tags, using commit SHA: $SHA_TAG"
|
||||
fi
|
||||
|
||||
if [ -z "$SHA_TAG" ]; then
|
||||
echo "❌ ERROR: Failed to extract SHA tag"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "sha-tag=$SHA_TAG" >> $GITHUB_OUTPUT
|
||||
echo "✅ Extracted SHA tag: $SHA_TAG"
|
||||
|
||||
- name: Update kustomization with new image tag
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
git config --global user.name "github-actions[bot]"
|
||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
# Validate that SHA_TAG is not empty
|
||||
SHA_TAG="${{ steps.extract-tag.outputs.sha-tag }}"
|
||||
if [ -z "$SHA_TAG" ]; then
|
||||
echo "❌ ERROR: SHA_TAG is empty, cannot update kustomization"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Determine overlay based on branch
|
||||
BRANCH_NAME="${{ github.ref_name }}"
|
||||
if [ "$BRANCH_NAME" = "main" ]; then
|
||||
OVERLAY="prod"
|
||||
elif [ "$BRANCH_NAME" = "develop" ]; then
|
||||
OVERLAY="dev"
|
||||
else
|
||||
echo "⚠️ Unknown branch: $BRANCH_NAME, skipping kustomization update"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
KUSTOMIZATION_FILE="deploy/k8s/overlays/$OVERLAY/kustomization.yaml"
|
||||
|
||||
# Check if kustomization file has images section
|
||||
if grep -q "images:" "$KUSTOMIZATION_FILE"; then
|
||||
echo "📝 Updating $KUSTOMIZATION_FILE with tag: $SHA_TAG"
|
||||
|
||||
# Update kustomization.yaml with new image tag
|
||||
# Handle both cases: newTag: (with value) and newTag: (empty)
|
||||
sed -i.bak "s|newTag:.*|newTag: $SHA_TAG|" "$KUSTOMIZATION_FILE"
|
||||
|
||||
# Verify the update was successful
|
||||
if grep -q "newTag: $SHA_TAG" "$KUSTOMIZATION_FILE"; then
|
||||
echo "✅ Successfully updated kustomization.yaml"
|
||||
rm -f "$KUSTOMIZATION_FILE.bak"
|
||||
else
|
||||
echo "❌ ERROR: Failed to update kustomization.yaml"
|
||||
cat "$KUSTOMIZATION_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Commit and push if there are changes
|
||||
if git diff --quiet; then
|
||||
echo "No changes to commit"
|
||||
else
|
||||
git add "$KUSTOMIZATION_FILE"
|
||||
git commit -m "Update $OVERLAY image to $SHA_TAG"
|
||||
git push
|
||||
echo "✅ Kustomization updated with new image tag: $SHA_TAG"
|
||||
fi
|
||||
else
|
||||
echo "ℹ️ $OVERLAY overlay uses base image (latest tag), skipping kustomization update"
|
||||
echo " Image built with tag: $SHA_TAG"
|
||||
fi
|
||||
|
||||
- name: Display image information
|
||||
run: |
|
||||
echo "✅ Image built and pushed successfully!"
|
||||
echo "📦 Image tags:"
|
||||
echo "Image built and pushed successfully!"
|
||||
echo "Image tags:"
|
||||
echo "${{ steps.meta.outputs.tags }}"
|
||||
echo "🔖 SHA tag: ${{ steps.extract-tag.outputs.sha-tag }}"
|
||||
echo "🔖 Digest: ${{ steps.build.outputs.digest }}"
|
||||
echo ""
|
||||
echo "🚀 Kustomization updated with new image tag"
|
||||
echo " ArgoCD will automatically detect and deploy this new image"
|
||||
echo " Monitor deployment at your ArgoCD dashboard"
|
||||
echo "Digest: ${{ steps.build.outputs.digest }}"
|
||||
|
||||
16
.github/workflows/ci.yml
vendored
@@ -2,9 +2,9 @@ name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, develop]
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main, develop]
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
lint-and-build:
|
||||
@@ -19,27 +19,27 @@ jobs:
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
cache-dependency-path: services/nextjs/package-lock.json
|
||||
cache-dependency-path: nextjs/package-lock.json
|
||||
|
||||
- name: Install dependencies
|
||||
working-directory: services/nextjs
|
||||
working-directory: nextjs
|
||||
run: npm ci
|
||||
|
||||
- name: Run ESLint
|
||||
working-directory: services/nextjs
|
||||
working-directory: nextjs
|
||||
run: npm run lint
|
||||
|
||||
- name: Build Next.js application
|
||||
working-directory: services/nextjs
|
||||
working-directory: nextjs
|
||||
run: npm run build
|
||||
env:
|
||||
NEXT_TELEMETRY_DISABLED: 1
|
||||
|
||||
- name: Check build output
|
||||
working-directory: services/nextjs
|
||||
working-directory: nextjs
|
||||
run: |
|
||||
if [ ! -d ".next" ]; then
|
||||
echo "Build failed: .next directory not found"
|
||||
exit 1
|
||||
fi
|
||||
echo "✅ Build completed successfully"
|
||||
echo "Build completed successfully"
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: portfolio-dev
|
||||
namespace: argocd
|
||||
spec:
|
||||
project: default
|
||||
source:
|
||||
repoURL: https://github.com/Mayne0213/portfolio.git
|
||||
targetRevision: develop
|
||||
path: deploy/k8s/overlays/dev
|
||||
destination:
|
||||
server: https://kubernetes.default.svc
|
||||
namespace: portfolio-dev
|
||||
syncPolicy:
|
||||
automated:
|
||||
prune: true
|
||||
selfHeal: true
|
||||
syncOptions:
|
||||
- CreateNamespace=true
|
||||
@@ -1,20 +0,0 @@
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: portfolio-prod
|
||||
namespace: argocd
|
||||
spec:
|
||||
project: default
|
||||
source:
|
||||
repoURL: https://github.com/Mayne0213/portfolio.git
|
||||
targetRevision: main
|
||||
path: deploy/k8s/overlays/prod
|
||||
destination:
|
||||
server: https://kubernetes.default.svc
|
||||
namespace: portfolio
|
||||
syncPolicy:
|
||||
automated:
|
||||
prune: true
|
||||
selfHeal: true
|
||||
syncOptions:
|
||||
- CreateNamespace=true
|
||||
@@ -1,36 +0,0 @@
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: portfolio
|
||||
namespace: argocd
|
||||
finalizers:
|
||||
- resources-finalizer.argocd.argoproj.io
|
||||
spec:
|
||||
project: default
|
||||
|
||||
source:
|
||||
repoURL: https://github.com/Mayne0213/portfolio.git
|
||||
targetRevision: main
|
||||
path: deploy/argocd
|
||||
|
||||
destination:
|
||||
server: https://kubernetes.default.svc
|
||||
namespace: argocd
|
||||
|
||||
syncPolicy:
|
||||
automated:
|
||||
prune: true
|
||||
selfHeal: true
|
||||
allowEmpty: false
|
||||
|
||||
syncOptions:
|
||||
- CreateNamespace=true
|
||||
|
||||
retry:
|
||||
limit: 5
|
||||
backoff:
|
||||
duration: 5s
|
||||
factor: 2
|
||||
maxDuration: 3m
|
||||
|
||||
revisionHistoryLimit: 10
|
||||
@@ -1,10 +0,0 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
# App of Apps Application (self-managing)
|
||||
- application.yaml
|
||||
|
||||
# Application deployments (prod and dev)
|
||||
- application-prod.yaml
|
||||
- application-dev.yaml
|
||||
@@ -1,26 +0,0 @@
|
||||
# Development Dockerfile for Portfolio Next.js application
|
||||
FROM node:20-alpine AS base
|
||||
|
||||
# Install dependencies for development
|
||||
RUN apk add --no-cache libc6-compat curl
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY package.json package-lock.json* ./
|
||||
|
||||
# Install all dependencies (including dev dependencies)
|
||||
RUN npm ci
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Expose port
|
||||
EXPOSE 3000
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost:3000 || exit 1
|
||||
|
||||
# Default command (can be overridden in docker-compose)
|
||||
CMD ["npm", "run", "dev"]
|
||||
@@ -1,27 +0,0 @@
|
||||
services:
|
||||
# Development Portfolio Next.js Application
|
||||
app:
|
||||
build:
|
||||
context: ../../services/nextjs
|
||||
dockerfile: ../../deploy/docker/Dockerfile.dev
|
||||
container_name: portfolio-app-dev
|
||||
restart: unless-stopped
|
||||
labels:
|
||||
kompose.namespace: portfolio
|
||||
ports:
|
||||
- 3005:3000
|
||||
environment:
|
||||
- NODE_ENV=development
|
||||
- WATCHPACK_POLLING=true
|
||||
networks:
|
||||
- portfolio-network
|
||||
volumes:
|
||||
- ../../services/nextjs:/app
|
||||
- /app/node_modules
|
||||
- /app/.next
|
||||
command: npm run dev
|
||||
|
||||
networks:
|
||||
portfolio-network:
|
||||
driver: bridge
|
||||
name: portfolio-network-dev
|
||||
@@ -1,22 +0,0 @@
|
||||
services:
|
||||
# Production Portfolio Next.js Application
|
||||
app:
|
||||
image: portfolio-app
|
||||
build:
|
||||
context: ../../services/nextjs
|
||||
dockerfile: ../../deploy/docker/Dockerfile.prod
|
||||
container_name: portfolio-app-prod
|
||||
restart: unless-stopped
|
||||
labels:
|
||||
kompose.namespace: portfolio
|
||||
ports:
|
||||
- 3005:3000
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
networks:
|
||||
- portfolio-network
|
||||
|
||||
networks:
|
||||
portfolio-network:
|
||||
driver: bridge
|
||||
name: portfolio-network-prod
|
||||
@@ -1,21 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: argocd-token
|
||||
namespace: portfolio
|
||||
type: Opaque
|
||||
stringData:
|
||||
token: "" # ArgoCD 토큰을 여기에 설정하거나, kubectl create secret로 생성
|
||||
---
|
||||
# 사용 방법:
|
||||
# 1. ArgoCD 토큰 생성:
|
||||
# argocd account generate-token
|
||||
#
|
||||
# 2. Secret 생성:
|
||||
# kubectl create secret generic argocd-token \
|
||||
# --from-literal=token='YOUR_TOKEN_HERE' \
|
||||
# -n portfolio
|
||||
#
|
||||
# 또는 이 파일을 수정하고:
|
||||
# kubectl apply -f argocd-secret.yaml
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: portfolio-app
|
||||
labels:
|
||||
app: portfolio-app
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: portfolio-app
|
||||
strategy:
|
||||
type: RollingUpdate
|
||||
rollingUpdate:
|
||||
maxUnavailable: 1
|
||||
maxSurge: 1
|
||||
revisionHistoryLimit: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: portfolio-app
|
||||
spec:
|
||||
containers:
|
||||
- name: portfolio-app
|
||||
image: ghcr.io/mayne0213/portfolio:latest
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 3000
|
||||
protocol: TCP
|
||||
env:
|
||||
- name: NODE_ENV
|
||||
value: production
|
||||
- name: PROMETHEUS_URL
|
||||
value: "http://prometheus.monitoring.svc.cluster.local:9090"
|
||||
resources:
|
||||
requests:
|
||||
memory: "100Mi"
|
||||
cpu: "50m"
|
||||
limits:
|
||||
memory: "200Mi"
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 3000
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 3000
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 5
|
||||
restartPolicy: Always
|
||||
@@ -1,15 +0,0 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
# SealedSecret은 각 overlay에서 관리
|
||||
|
||||
commonLabels:
|
||||
app.kubernetes.io/name: portfolio
|
||||
app.kubernetes.io/component: web
|
||||
|
||||
images:
|
||||
- name: gitea0213.kro.kr/bluemayne/portfolio
|
||||
newTag: latest
|
||||
@@ -1,15 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: portfolio-service
|
||||
labels:
|
||||
app: portfolio-app
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- name: http
|
||||
port: 80
|
||||
targetPort: 3000
|
||||
protocol: TCP
|
||||
selector:
|
||||
app: portfolio-app
|
||||
@@ -1,18 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: portfolio-app
|
||||
labels:
|
||||
environment: development
|
||||
spec:
|
||||
replicas: 1
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: portfolio-app
|
||||
resources:
|
||||
requests:
|
||||
memory: "50Mi"
|
||||
cpu: "30m"
|
||||
limits:
|
||||
memory: "120Mi"
|
||||
@@ -1,25 +0,0 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: portfolio-dev-ingress
|
||||
annotations:
|
||||
nginx.ingress.kubernetes.io/rewrite-target: /
|
||||
nginx.ingress.kubernetes.io/ssl-redirect: "true"
|
||||
cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
||||
spec:
|
||||
ingressClassName: traefik
|
||||
tls:
|
||||
- hosts:
|
||||
- dev.minjo0213.kro.kr
|
||||
secretName: portfolio-dev-tls
|
||||
rules:
|
||||
- host: dev.minjo0213.kro.kr
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: portfolio-service
|
||||
port:
|
||||
number: 80
|
||||
@@ -1,21 +0,0 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
namespace: portfolio-dev
|
||||
|
||||
resources:
|
||||
- ../../base
|
||||
- resourcequota.yaml
|
||||
- namespace.yaml
|
||||
- ingress.yaml
|
||||
|
||||
commonLabels:
|
||||
environment: development
|
||||
|
||||
# 이미지 태그 설정
|
||||
images:
|
||||
- name: gitea0213.kro.kr/bluemayne/portfolio
|
||||
newTag: develop-sha-59417db99e01138c0e756e7b425e6a6c328377a1
|
||||
|
||||
patchesStrategicMerge:
|
||||
- deployment-patch.yaml
|
||||
@@ -1,7 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: portfolio-dev
|
||||
labels:
|
||||
environment: development
|
||||
app: portfolio
|
||||
@@ -1,11 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: ResourceQuota
|
||||
metadata:
|
||||
name: portfolio-dev-quota
|
||||
namespace: portfolio-dev
|
||||
spec:
|
||||
hard:
|
||||
requests.memory: "200Mi"
|
||||
requests.cpu: "100m"
|
||||
limits.memory: "400Mi"
|
||||
pods: "6"
|
||||
@@ -1,18 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: portfolio-app
|
||||
labels:
|
||||
environment: production
|
||||
spec:
|
||||
replicas: 2
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: portfolio-app
|
||||
resources:
|
||||
requests:
|
||||
memory: "80Mi"
|
||||
cpu: "20m" # Reduced from 50m based on actual usage (12m)
|
||||
limits:
|
||||
memory: "150Mi"
|
||||
@@ -1,38 +0,0 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: portfolio-ingress
|
||||
annotations:
|
||||
# HTTP를 HTTPS로 자동 리다이렉트
|
||||
nginx.ingress.kubernetes.io/ssl-redirect: "true"
|
||||
# cert-manager가 인증서를 자동으로 발급하도록 설정
|
||||
cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
||||
spec:
|
||||
ingressClassName: traefik
|
||||
# TLS 설정
|
||||
tls:
|
||||
- hosts:
|
||||
- minjo0213.kro.kr
|
||||
- www.minjo0213.kro.kr
|
||||
secretName: portfolio-tls
|
||||
rules:
|
||||
- host: minjo0213.kro.kr
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: portfolio-service
|
||||
port:
|
||||
number: 80
|
||||
- host: www.minjo0213.kro.kr
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: portfolio-service
|
||||
port:
|
||||
number: 80
|
||||
@@ -1,20 +0,0 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
namespace: portfolio
|
||||
|
||||
resources:
|
||||
- ../../base
|
||||
- resourcequota.yaml
|
||||
- ingress.yaml
|
||||
|
||||
commonLabels:
|
||||
environment: production
|
||||
|
||||
# 이미지 태그 설정
|
||||
images:
|
||||
- name: ghcr.io/mayne0213/portfolio
|
||||
newTag: main-sha-7937ec4e7abb9d514f27a058c92636a809d607a4
|
||||
|
||||
patchesStrategicMerge:
|
||||
- deployment-patch.yaml
|
||||
@@ -1,11 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: ResourceQuota
|
||||
metadata:
|
||||
name: portfolio-quota
|
||||
namespace: portfolio
|
||||
spec:
|
||||
hard:
|
||||
requests.memory: "400Mi"
|
||||
requests.cpu: "250m"
|
||||
limits.memory: "600Mi"
|
||||
pods: "9"
|
||||
|
Before Width: | Height: | Size: 152 KiB After Width: | Height: | Size: 152 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 325 KiB After Width: | Height: | Size: 325 KiB |
|
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 98 KiB |
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 340 KiB After Width: | Height: | Size: 340 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 385 B After Width: | Height: | Size: 385 B |