diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml new file mode 100644 index 0000000..f2fa685 --- /dev/null +++ b/.gitea/workflows/build.yaml @@ -0,0 +1,60 @@ +name: Build and Push to GHCR + +on: + push: + branches: [master, main] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=sha,prefix=,suffix=,format=short + type=raw,value=latest,enable={{is_default_branch}} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Update kustomization.yaml + run: | + COMMIT_SHA=${{ github.sha }} + SHORT_SHA=${COMMIT_SHA:0:7} + sed -i "s|newTag: .*|newTag: ${SHORT_SHA}|" k8s/kustomization.yaml + + - name: Commit and push changes + run: | + git config --local user.email "gitea-actions[bot]@users.noreply.gitea.io" + git config --local user.name "gitea-actions[bot]" + git add k8s/kustomization.yaml + git diff --quiet && git diff --staged --quiet || git commit -m "deploy: update image to ${SHORT_SHA} [skip ci]" + git push diff --git a/README.md b/README.md index c2607ae..8cb5b6c 100644 --- a/README.md +++ b/README.md @@ -39,3 +39,4 @@ Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/bui // Auto-deploy test: 2026-03-07T09:02:49Z // Auto-deploy test: 2026-03-07T10:33:23Z // Auto-deploy test 2: 2026-03-07T10:37:05Z +# Trigger build Sun Apr 5 06:32:05 AM EET 2026 diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml index e3e82ad..5d7c1e0 100644 --- a/k8s/deployment.yaml +++ b/k8s/deployment.yaml @@ -13,112 +13,16 @@ spec: labels: app: storefront spec: - initContainers: - - name: clone - image: alpine/git:latest - command: - - sh - - -c - - | - set -e - apk add --no-cache git - # Clean workspace if it exists (handles pod restarts) - if [ -d /workspace/.git ]; then - echo "Workspace exists, pulling latest changes..." - cd /workspace - git fetch origin master - git reset --hard origin/master - else - echo "Cloning fresh repository..." - rm -rf /workspace/* - git clone --depth 1 --branch master \ - http://gitea.gitea.svc.cluster.local:3000/unchained/manoon-headless.git \ - /workspace - fi - echo "Clone/update complete." - volumeMounts: - - name: workspace - mountPath: /workspace - securityContext: - runAsUser: 0 - resources: - limits: - cpu: 500m - memory: 256Mi - - name: install - image: node:20-slim - workingDir: /workspace - command: - - sh - - -c - - | - set -e - echo "Installing dependencies..." - npm install --prefer-offline --no-audit 2>&1 - echo "Dependencies installed." - volumeMounts: - - name: workspace - mountPath: /workspace - securityContext: - runAsUser: 0 - resources: - limits: - cpu: 2000m - memory: 3Gi - requests: - cpu: 100m - memory: 1Gi - - name: build - image: node:20-slim - workingDir: /workspace - command: - - sh - - -c - - | - set -e - echo "Building Next.js app..." - npm run build - echo "Build complete!" - env: - - name: NODE_ENV - value: "production" - - name: NEXT_PUBLIC_SALEOR_API_URL - value: "https://api.manoonoils.com/graphql/" - - name: NEXT_PUBLIC_SITE_URL - value: "https://manoonoils.com" - - name: DASHBOARD_URL - value: "https://dashboard.manoonoils.com" - - name: NEXT_PUBLIC_OPENPANEL_CLIENT_ID - value: "fa61f8ae-0b5d-4187-a9b1-5a04b0025674" - - name: OPENPANEL_CLIENT_SECRET - value: "91126be0d1e78e657e0427df82733832.c6d30edf6ee673da9650a883604169a13ab8579a0dde70cb39b477f4cf441f90" - - name: OPENPANEL_API_URL - value: "https://op.nodecrew.me/api" - - name: MAUTIC_CLIENT_ID - value: "2_23cgmaqef8kgg8oo4kggc0w4wccwoss8o8w48o8sc40cowgkkg" - - name: MAUTIC_CLIENT_SECRET - value: "4k8367ab306co48c4c8g8sco8cgcwwww044gwccs0o0c8w4gco" - - name: MAUTIC_API_URL - value: "https://mautic.nodecrew.me" - volumeMounts: - - name: workspace - mountPath: /workspace - securityContext: - runAsUser: 0 - resources: - limits: - cpu: 2000m - memory: 2Gi - requests: - cpu: 100m - memory: 512Mi + imagePullSecrets: + - name: ghcr-pull-secret containers: - name: storefront - image: node:20-slim - workingDir: /workspace + image: ghcr.io/unchainedio/manoon-headless:latest # {"": "flux-system:manoon-headless"} + imagePullPolicy: Always command: - - npm - - start + - node + - server.js + workingDir: /app ports: - containerPort: 3000 env: @@ -179,10 +83,3 @@ spec: port: 3000 periodSeconds: 5 failureThreshold: 3 - volumeMounts: - - name: workspace - mountPath: /workspace - volumes: - - name: workspace - emptyDir: - sizeLimit: 2Gi diff --git a/k8s/kustomization.yaml b/k8s/kustomization.yaml index 54dedf0..34d0502 100644 --- a/k8s/kustomization.yaml +++ b/k8s/kustomization.yaml @@ -5,6 +5,3 @@ resources: - service.yaml - middleware.yaml - ingress.yaml -images: - - name: ghcr.io/unchainedio/manoon-headless - newTag: 2c27fc6 # Updated by GitHub Actions