Add pure Node.js deployment without Docker

This commit is contained in:
Unchained
2026-03-06 19:10:56 +02:00
parent cac26e73ce
commit ced136fb4d

View File

@@ -1,25 +1,19 @@
apiVersion: v1 apiVersion: v1
kind: Secret kind: Secret
metadata: metadata:
name: git-credentials name: woocommerce-credentials
namespace: manoonoils namespace: manoonoilstype: Opaque
type: Opaque
stringData: stringData:
# Gitea SSH private key (for cloning) WOOCOMMERCE_URL: "https://manoonoils.com"
# Generate with: ssh-keygen -t ed25519 -f gitea-deploy-key # You'll need to update these with actual credentials
# Add public key to Gitea repo deploy keys WOOCOMMERCE_CONSUMER_KEY: "PLACEHOLDER_KEY"
SSH_KEY: | WOOCOMMERCE_CONSUMER_SECRET: "PLACEHOLDER_SECRET"
-----BEGIN OPENSSH PRIVATE KEY-----
# REPLACE WITH ACTUAL PRIVATE KEY
-----END OPENSSH PRIVATE KEY-----
GIT_HOST: "100.74.155.73"
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: storefront name: storefront
namespace: manoonoils namespace: manoonoilsspec:
spec:
replicas: 1 replicas: 1
selector: selector:
matchLabels: matchLabels:
@@ -30,37 +24,55 @@ spec:
app: storefront app: storefront
spec: spec:
initContainers: initContainers:
- name: build - name: clone
image: node:20-alpine image: alpine/git:latest
command: command:
- sh - sh
- -c - -c
- | - |
set -e set -e
apk add --no-cache git
# Install git and ssh # Clone from Gitea (using HTTP with ssl verify disabled for self-signed cert)
apk add --no-cache git openssh-client git config --global http.sslVerify false
git clone --depth 1 --branch master \
https://100.74.155.73:3000/unchained/manoon-headless.git \
/workspace
# Setup SSH for Gitea echo "Clone complete. Files:"
mkdir -p /root/.ssh ls -la /workspace
cp /secrets/SSH_KEY /root/.ssh/id_ed25519 volumeMounts:
chmod 600 /root/.ssh/id_ed25519 - name: workspace
ssh-keyscan -p 222 -H $(cat /secrets/GIT_HOST) > /root/.ssh/known_hosts 2>/dev/null || \ mountPath: /workspace
ssh-keyscan -p 222 -H 100.74.155.73 > /root/.ssh/known_hosts 2>/dev/null || true securityContext:
runAsUser: 0
# Clone repository - name: install
echo "Cloning from Gitea..." image: node:20-alpine
git clone --depth 1 --branch master ssh://git@100.74.155.73:222/unchained/manoon-headless.git /workspace workingDir: /workspace
command:
cd /workspace - sh
- -c
- |
set -e
echo "Installing dependencies..." echo "Installing dependencies..."
npm ci --prefer-offline --no-audit --silent npm ci --prefer-offline --no-audit --silent
echo "Dependencies installed."
echo "Building Next.js..." volumeMounts:
- name: workspace
mountPath: /workspace
securityContext:
runAsUser: 0
- name: build
image: node:20-alpine
workingDir: /workspace
command:
- sh
- -c
- |
set -e
echo "Building Next.js app..."
npm run build npm run build
echo "Build complete!" echo "Build complete!"
ls -la /workspace/.next/
env: env:
- name: NODE_ENV - name: NODE_ENV
value: "production" value: "production"
@@ -84,9 +96,6 @@ spec:
volumeMounts: volumeMounts:
- name: workspace - name: workspace
mountPath: /workspace mountPath: /workspace
- name: git-secret
mountPath: /secrets
readOnly: true
securityContext: securityContext:
runAsUser: 0 runAsUser: 0
resources: resources:
@@ -99,13 +108,10 @@ spec:
containers: containers:
- name: storefront - name: storefront
image: node:20-alpine image: node:20-alpine
workingDir: /workspace
command: command:
- sh - npm
- -c - start
- |
cd /workspace
echo "Starting Next.js production server..."
exec npm start
ports: ports:
- containerPort: 3000 - containerPort: 3000
env: env:
@@ -147,7 +153,7 @@ spec:
path: / path: /
port: 3000 port: 3000
periodSeconds: 10 periodSeconds: 10
failureThreshold: 60 failureThreshold: 30
livenessProbe: livenessProbe:
httpGet: httpGet:
path: / path: /
@@ -164,7 +170,3 @@ spec:
- name: workspace - name: workspace
emptyDir: emptyDir:
sizeLimit: 2Gi sizeLimit: 2Gi
- name: git-secret
secret:
secretName: git-credentials
defaultMode: 0400