Refactor configuration files for consistency and update Dockerfile base images

This commit is contained in:
Tudor Stanciu 2025-09-28 03:33:18 +03:00
parent a8adedbd40
commit d467172271
3 changed files with 29 additions and 24 deletions

View File

@ -1,6 +1,8 @@
{
"bracketSpacing": true,
"arrowParens": "avoid",
"printWidth": 160,
"trailingComma": "none",
"tabWidth": 2,
"semi": true,
"singleQuote": false
"singleQuote": false,
"endOfLine": "auto"
}

View File

@ -1,6 +1,6 @@
# Modern Dockerfile for Vite + React application
# Build stage
FROM node:18-alpine as builder
FROM 24.9-alpine3.21 AS builder
WORKDIR /app
@ -23,7 +23,7 @@ ENV VITE_BASE_PATH=${VITE_BASE_PATH}
RUN npm run build
# Production stage - Use nginx for better performance
FROM nginx:alpine
FROM nginx:1.29.1-alpine
# Remove default nginx website
RUN rm -rf /usr/share/nginx/html/*
@ -44,7 +44,7 @@ EXPOSE 80
# Health check
HEALTHCHECK --interval=120s --timeout=10s --start-period=60s --retries=3 \
CMD wget -q -O - http://localhost/ || exit 1
CMD curl -f http://localhost/ || exit 1
# Start nginx
CMD ["nginx", "-g", "daemon off;"]

View File

@ -1,17 +1,20 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { resolve } from 'path'
import { readFileSync } from 'fs'
import viteTsconfigPaths from 'vite-tsconfig-paths'
import checker from 'vite-plugin-checker'
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import viteTsconfigPaths from "vite-tsconfig-paths";
import checker from "vite-plugin-checker";
import { readFileSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url));
// https://vite.dev/config/
export default defineConfig(() => {
// Read package.json for version info
const packageJson = JSON.parse(readFileSync('./package.json', 'utf-8'))
const packageJson = JSON.parse(readFileSync("./package.json", "utf-8"));
return {
base: process.env.VITE_BASE_PATH ? `/${process.env.VITE_BASE_PATH}/` : '/',
base: process.env.VITE_BASE_PATH ? `/${process.env.VITE_BASE_PATH}/` : "/",
plugins: [
react(),
viteTsconfigPaths(), // Enables TypeScript path mapping from tsconfig.json
@ -21,21 +24,21 @@ export default defineConfig(() => {
],
server: {
port: 3000,
open: true,
open: true
},
build: {
outDir: 'build',
sourcemap: true,
outDir: "build",
sourcemap: true
},
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
},
"@": resolve(__dirname, "src")
}
},
define: {
// Expose app version and build date as Vite environment variables
'import.meta.env.VITE_APP_VERSION': JSON.stringify(packageJson.version),
'import.meta.env.VITE_APP_DATE': JSON.stringify(new Date().toISOString()),
},
}
})
"import.meta.env.VITE_APP_VERSION": JSON.stringify(packageJson.version),
"import.meta.env.VITE_APP_DATE": JSON.stringify(new Date().toISOString())
}
};
});