dockerized

This commit is contained in:
salvacybersec
2025-11-11 04:30:25 +03:00
parent 8ddd6a983f
commit c62478937e
15 changed files with 1041 additions and 21 deletions

33
frontend/.dockerignore Normal file
View File

@@ -0,0 +1,33 @@
# Node modules
node_modules/
npm-debug.log
# Environment files
.env
.env.local
# Git
.git/
.gitignore
# Build artifacts
dist/
.cache/
# Documentation
*.md
# IDE
.vscode/
.idea/
# OS
.DS_Store
# Testing
coverage/
# Temporary
tmp/
temp/

49
frontend/Dockerfile Normal file
View File

@@ -0,0 +1,49 @@
# Frontend Dockerfile
# Multi-stage build for optimized production image
# Stage 1: Build stage
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm ci
# Copy application code
COPY . .
# Build for production
RUN npm run build
# Stage 2: Production stage
FROM node:20-alpine
# Create app user
RUN addgroup -g 1001 -S oltalama && \
adduser -S oltalama -u 1001 -G oltalama
WORKDIR /app
# Copy built assets from builder
COPY --from=builder --chown=oltalama:oltalama /app/dist ./dist
COPY --from=builder --chown=oltalama:oltalama /app/package*.json ./
# Install only production dependencies (for preview server)
RUN npm ci --only=production
# Switch to non-root user
USER oltalama
# Expose port
EXPOSE 4173
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:4173 || exit 1
# Start preview server
CMD ["npm", "run", "preview", "--", "--host", "0.0.0.0"]

22
frontend/Dockerfile.dev Normal file
View File

@@ -0,0 +1,22 @@
# Frontend Development Dockerfile
# Hot reload enabled with Vite
FROM node:20-alpine
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install all dependencies (including dev)
RUN npm install
# Copy application code
COPY . .
# Expose Vite dev server port
EXPOSE 5173
# Start Vite dev server with host binding
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"]