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/fullchain.pem
certs/privateKey.pem certs/privateKey.pem
.vscode/ .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`. 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`. 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. 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 ## Notes
- Traefik terminates TLS and routes frontend, API, admin, static, media, Grafana, Prometheus, and Uptime Kuma. - 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. - 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. - 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: build:
context: ./frontend/guilan-ace-frontend context: ./frontend/guilan-ace-frontend
dockerfile: ./frontend/Dockerfile dockerfile: ./frontend/Dockerfile
env_file:
- ./frontend/guilan-ace-frontend/.env
labels: labels:
- traefik.enable=true - traefik.enable=true
- traefik.http.routers.frontend.rule=Host(`${NEXT_HOST}`) - traefik.http.routers.frontend.rule=Host(`${NEXT_HOST}`)
- traefik.http.routers.frontend.entrypoints=websecure - traefik.http.routers.frontend.entrypoints=websecure
- traefik.http.routers.frontend.tls.certresolver=le - traefik.http.routers.frontend.tls.certresolver=le
- traefik.http.services.frontend.loadbalancer.server.port=80 - traefik.http.services.frontend.loadbalancer.server.port=3000
static: static:
image: nginx:1.27-alpine 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 WORKDIR /app
RUN npm config set registry https://package-mirror.liara.ir/repository/npm/ --global RUN npm config set registry https://package-mirror.liara.ir/repository/npm/ --global
# Copy package files
COPY package*.json ./ COPY package*.json ./
# Install dependencies RUN npm ci
RUN npm install
# Copy source code FROM node:20-alpine AS builder
WORKDIR /app
ENV NODE_ENV=production
COPY --from=deps /app/node_modules ./node_modules
COPY . . COPY . .
# Build the application
RUN npm run build RUN npm run build
# Production image FROM node:20-alpine AS runner
FROM nginx:alpine
# Copy built files to nginx WORKDIR /app
COPY --from=builder /app/dist /usr/share/nginx/html
# Copy nginx configuration ENV NODE_ENV=production
COPY nginx.conf /etc/nginx/conf.d/default.conf 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"]