1 Commits

Author SHA1 Message Date
Yamen Ahmad
b66a623141 feat: add Dockerfile for production deployment
Multi-stage build: Node 18 builds the Vite app, nginx serves
the static output. Nginx config proxies /api/ to the backend
container and handles SPA client-side routing with try_files.

Build args VITE_API_BASE_URL and VITE_APP_NAME are configurable
at build time via docker build --build-arg.

Made-with: Cursor
2026-04-01 18:29:18 +04:00
5 changed files with 59 additions and 38 deletions

10
.dockerignore Normal file
View File

@@ -0,0 +1,10 @@
node_modules
dist
.git
.env
.env.local
.env.production
*.md
docs/
.vscode/
coverage/

14
.gitignore vendored
View File

@@ -4,13 +4,9 @@ node_modules/
# Build output # Build output
dist/ dist/
build/ build/
.next/
out/
# Environment / secrets — never commit # Environment
.env .env
.env.*
!.env.example
.env.local .env.local
.env.production .env.production
.env.*.local .env.*.local
@@ -29,5 +25,9 @@ Thumbs.db
# Logs # Logs
*.log *.log
npm-debug.log* npm-debug.log*
yarn-debug.log*
yarn-error.log* # Testing
coverage/
# Vite
*.local

41
Dockerfile Normal file
View File

@@ -0,0 +1,41 @@
FROM node:18-alpine AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
ARG VITE_API_BASE_URL=/api
ARG VITE_APP_NAME=EnCoach
ENV VITE_API_BASE_URL=$VITE_API_BASE_URL
ENV VITE_APP_NAME=$VITE_APP_NAME
RUN npm run build
FROM nginx:stable-alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY <<'NGINX' /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
location /api/ {
proxy_pass http://backend:8069/api/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 300s;
}
location / {
try_files $uri $uri/ /index.html;
}
location ~* \.(?:css|js|svg|png|jpg|jpeg|gif|ico|woff2?|ttf|eot)$ {
expires 30d;
add_header Cache-Control "public, immutable";
}
}
NGINX
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

View File

@@ -1,24 +1,3 @@
# EnCoach Frontend — v2
## Branching Workflow
This repo is connected to the staging server via a Git post-receive hook.
**All deployment is automatic — but only after code review approval.**
### How to contribute
1. Never push directly to `main` — branch protection will block it.
2. Push your changes to your feature branch (e.g. `feature/full-frontend-v1`)
3. Open a Pull Request on Gitea targeting `main`
4. Request review from **devops (Talal)**
5. Once approved and merged, the staging server rebuilds and redeploys automatically.
### Environment
The `.env` file is **not committed**. It lives only on the staging server at `/opt/encoach/frontend-v2/.env`.
---
# EnCoach — Adaptive Learning Platform (Frontend) # EnCoach — Adaptive Learning Platform (Frontend)
The frontend application for the EnCoach Adaptive Learning Platform, serving UTAS university students and freelance learners across IELTS, Mathematics, and IT courses. The frontend application for the EnCoach Adaptive Learning Platform, serving UTAS university students and freelance learners across IELTS, Mathematics, and IT courses.

View File

@@ -1,9 +0,0 @@
services:
frontend:
build: .
image: encoach-frontend:latest
container_name: encoach-frontend
restart: unless-stopped
ports:
- "3000:3000"
env_file: .env