diff --git a/.github/workflows/eslint.yml b/.github/workflows/eslint.yml index 0d31d09e..5246bdbe 100644 --- a/.github/workflows/eslint.yml +++ b/.github/workflows/eslint.yml @@ -3,10 +3,10 @@ name: Lint on: pull_request: paths: - - "**.js" - - "**.jsx" - - "**.ts" - - "**.tsx" + - "src/**/*.js" + - "src/**/*.jsx" + - "src/**/*.ts" + - "src/**/*.tsx" jobs: eslint: diff --git a/.gitignore b/.gitignore index fe1ae567..fa252883 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.DS_Store node_modules build +dist .env .vscode \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 2cc372ed..a6b2fa56 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,38 +1,37 @@ -FROM node:23-alpine3.21 AS base - -# Install dependencies -FROM base AS deps +# Build stage +FROM node:22-alpine3.21 AS builder WORKDIR /app -# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. +# Install libc6-compat if needed RUN apk add --no-cache libc6-compat +# Install dependencies COPY package.json package-lock.json ./ - RUN npm ci -# Build the app with the node modules installed -FROM base AS builder - -WORKDIR /app - -COPY --from=deps /app/node_modules ./node_modules +# Build the Vite app COPY . . - RUN npm run build -# Create a new image with the build files -FROM base AS runner +# Final stage: nginx serving dist/ +FROM nginx:stable-alpine as runner -WORKDIR /app +# Remove default nginx website +RUN rm -rf /usr/share/nginx/html/* + +# Copy custom nginx config +COPY nginx.conf /etc/nginx/nginx.conf -COPY --from=builder /app/build ./build -RUN npm install -g serve +# Copy built Vite files +COPY --from=builder /app/dist /usr/share/nginx/html +# Healthcheck for nginx HEALTHCHECK --interval=10s --timeout=5s --start-period=5s --retries=3 \ - CMD wget --no-verbose --tries=1 --spider http://0.0.0.0:3000/health || exit 1 + CMD wget --no-verbose --tries=1 --spider http://0.0.0.0/health || exit 1 -EXPOSE 3000 +# Expose port 80 (standard HTTP) +EXPOSE 80 -CMD ["serve", "-s", "build"] +# Start nginx automatically +CMD ["nginx", "-g", "daemon off;"] diff --git a/Makefile b/Makefile index 6701f98f..54b01d82 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ develop: - npm start + npm run dev build: npm run build @@ -13,7 +13,7 @@ docker-build: build docker push enchanter77/labconnect-frontend lint: - eslint --max-warnings=0 'src/**/*{js,jsx,ts,tsx}' + npm run lint lintfix: eslint --max-warnings=0 'src/**/*{js,jsx,ts,tsx}' --fix \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 00000000..bf15cd2d --- /dev/null +++ b/index.html @@ -0,0 +1,16 @@ + + + +
+ + + +