dockerized
This commit is contained in:
33
frontend/.dockerignore
Normal file
33
frontend/.dockerignore
Normal 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
49
frontend/Dockerfile
Normal 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
22
frontend/Dockerfile.dev
Normal 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"]
|
||||
|
||||
Reference in New Issue
Block a user