diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..1a91859 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +node_modules +npm-debug.log +dist +.git +.gitignore +README.md +.env +.nyc_output +coverage +.vscode \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..884c61b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +# Multi-stage build for production deployment +FROM node:18-alpine AS builder + +# Set working directory +WORKDIR /app + +# Clone the repository +RUN apk add --no-cache git +RUN git clone https://git.raphaelforment.fr/BuboBubo/cosmique.git . + +# Install dependencies +RUN npm ci --only=production=false + +# Build the application +RUN npm run build + +# Production stage +FROM nginx:alpine AS production + +# Copy built files to nginx +COPY --from=builder /app/dist /usr/share/nginx/html + +# Copy custom nginx configuration +COPY nginx.conf /etc/nginx/nginx.conf + +# Expose port 80 +EXPOSE 80 + +# Start nginx +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/README.md b/README.md index 6e29aea..3d592ac 100644 --- a/README.md +++ b/README.md @@ -113,10 +113,3 @@ docker run -p 3000:3000 rayon-cosmique - **Escape**: Cancel current edit - **Mouse Wheel**: Scroll through hex data - **Click**: Edit individual bytes or ASCII characters - -## Development - -## Author - -**Raphaƫl Forment (BuboBubo)** -Email: raphael.forment@gmail.com diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..5f2b890 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,49 @@ +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + # Gzip compression + gzip on; + gzip_vary on; + gzip_min_length 1024; + gzip_proxied any; + gzip_comp_level 6; + gzip_types + text/plain + text/css + text/xml + text/javascript + application/json + application/javascript + application/xml+rss + application/atom+xml + image/svg+xml; + + server { + listen 80; + server_name localhost; + + root /usr/share/nginx/html; + index index.html index.htm; + + # Handle client routing + location / { + try_files $uri $uri/ /index.html; + } + + # Cache static assets + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + } + + # Security headers + add_header X-Frame-Options "SAMEORIGIN" always; + add_header X-Content-Type-Options "nosniff" always; + add_header X-XSS-Protection "1; mode=block" always; + } +} \ No newline at end of file