migrate frontend service to Next.js
Some checks failed
Deployment CI/CD / validate (push) Has been cancelled
Deployment CI/CD / deploy (push) Has been cancelled

This commit is contained in:
2026-05-20 10:10:11 +03:30
parent b4c6b3c012
commit c75d03a548
4 changed files with 29 additions and 16 deletions

3
.gitignore vendored
View File

@@ -3,3 +3,6 @@ data/
certs/fullchain.pem
certs/privateKey.pem
.vscode/
backend/guilan-ace-backend
frontend/guilan-ace-frontend

View File

@@ -24,9 +24,11 @@ parent-directory/
3. On the deployment server, place the backend repo at `guilan-ace-deployment/backend/guilan-ace-backend`.
4. On the deployment server, place the frontend repo at `guilan-ace-deployment/frontend/guilan-ace-frontend`.
5. Create `backend/guilan-ace-backend/.env` from the backend repo sample.
6. Run `docker compose up -d --build`.
6. Create `frontend/guilan-ace-frontend/.env` from the frontend repo sample.
7. Run `docker compose up -d --build`.
## Notes
- Traefik terminates TLS and routes frontend, API, admin, static, media, Grafana, Prometheus, and Uptime Kuma.
- The frontend is a Next.js standalone Node runtime behind Traefik on internal port `3000`.
- Alertmanager has been removed from this stack. Prometheus scraping and Grafana provisioning remain intact.
- Dockerfiles live only in this deployment repository, and compose is intentionally wired only for the nested production layout.

View File

@@ -130,12 +130,14 @@ services:
build:
context: ./frontend/guilan-ace-frontend
dockerfile: ./frontend/Dockerfile
env_file:
- ./frontend/guilan-ace-frontend/.env
labels:
- traefik.enable=true
- traefik.http.routers.frontend.rule=Host(`${NEXT_HOST}`)
- traefik.http.routers.frontend.entrypoints=websecure
- traefik.http.routers.frontend.tls.certresolver=le
- traefik.http.services.frontend.loadbalancer.server.port=80
- traefik.http.services.frontend.loadbalancer.server.port=3000
static:
image: nginx:1.27-alpine

View File

@@ -1,30 +1,36 @@
FROM node:20-alpine AS builder
FROM node:20-alpine AS deps
WORKDIR /app
RUN npm config set registry https://package-mirror.liara.ir/repository/npm/ --global
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm install
RUN npm ci
# Copy source code
FROM node:20-alpine AS builder
WORKDIR /app
ENV NODE_ENV=production
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Build the application
RUN npm run build
# Production image
FROM nginx:alpine
FROM node:20-alpine AS runner
# Copy built files to nginx
COPY --from=builder /app/dist /usr/share/nginx/html
WORKDIR /app
# Copy nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf
ENV NODE_ENV=production
ENV PORT=3000
ENV HOSTNAME=0.0.0.0
EXPOSE 80
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
CMD ["nginx", "-g", "daemon off;"]
EXPOSE 3000
CMD ["node", "server.js"]