Files
paprika-api/DEPLOYMENT.md
T

78 lines
2.0 KiB
Markdown

# Deployment Instructions for k3s (VPS)
This document provides instructions on how to deploy the **Paprika API** to a VPS running k3s.
## 1. Prepare the Container Image
AdonisJS needs to be built and containerized. If you don't have a Dockerfile, you can use the one provided below.
### Create a `Dockerfile`
```dockerfile
FROM node:22-alpine AS base
# All dependencies stage
FROM base AS deps
WORKDIR /app
ADD package.json package-lock.json ./
RUN npm ci
# Production dependencies stage
FROM base AS production-deps
WORKDIR /app
ADD package.json package-lock.json ./
RUN npm ci --omit=dev
# Build stage
FROM base AS build
WORKDIR /app
COPY --from=deps /app/node_modules /app/node_modules
ADD . .
RUN node ace build
# Production stage
FROM base AS production
ENV NODE_ENV=production
WORKDIR /app
COPY --from=production-deps /app/node_modules /app/node_modules
COPY --from=build /app/build /app
EXPOSE 3333
CMD ["node", "bin/server.js"]
```
### Build and Push the image
Replace `<your-registry>` and `<image-name>` with your actual registry (e.g., Docker Hub, GitHub Packages).
```bash
docker build -t <your-registry>/<image-name>:latest .
docker push <your-registry>/<image-name>:latest
```
## 2. Configure the Kubernetes Manifest
1. Open `k3s-deployment.yaml`.
2. Update the `APP_KEY` in the `Secret` section (you can use the one from your `.env`).
3. Update the `image` field in the `paprika-api` Deployment with your pushed image.
4. Update the `host` in the `Ingress` section to your VPS domain name.
## 3. Deploy to k3s
Connect to your VPS and run:
```bash
kubectl apply -f k3s-deployment.yaml
```
## 4. Run Database Migrations
After the pods are running, you need to run migrations inside the API container:
```bash
kubectl exec -it deployment/paprika-api -- node ace migration:run --force
```
## 5. Verification
- Check pods: `kubectl get pods`
- Check logs: `kubectl logs -f deployment/paprika-api`
- Access the API via your domain or VPS IP (if Ingress is configured).