Skip to content

Commit b0c12f9

Browse files
Convert to Vite from CRA (#136)
2 parents 9056567 + 08d48cd commit b0c12f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+4700
-16282
lines changed

.github/workflows/eslint.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ name: Lint
33
on:
44
pull_request:
55
paths:
6-
- "**.js"
7-
- "**.jsx"
8-
- "**.ts"
9-
- "**.tsx"
6+
- "src/**/*.js"
7+
- "src/**/*.jsx"
8+
- "src/**/*.ts"
9+
- "src/**/*.tsx"
1010

1111
jobs:
1212
eslint:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*.DS_Store
22
node_modules
33
build
4+
dist
45
.env
56
.vscode

Dockerfile

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,37 @@
1-
FROM node:23-alpine3.21 AS base
2-
3-
# Install dependencies
4-
FROM base AS deps
1+
# Build stage
2+
FROM node:22-alpine3.21 AS builder
53

64
WORKDIR /app
75

8-
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
6+
# Install libc6-compat if needed
97
RUN apk add --no-cache libc6-compat
108

9+
# Install dependencies
1110
COPY package.json package-lock.json ./
12-
1311
RUN npm ci
1412

15-
# Build the app with the node modules installed
16-
FROM base AS builder
17-
18-
WORKDIR /app
19-
20-
COPY --from=deps /app/node_modules ./node_modules
13+
# Build the Vite app
2114
COPY . .
22-
2315
RUN npm run build
2416

25-
# Create a new image with the build files
26-
FROM base AS runner
17+
# Final stage: nginx serving dist/
18+
FROM nginx:stable-alpine as runner
2719

28-
WORKDIR /app
20+
# Remove default nginx website
21+
RUN rm -rf /usr/share/nginx/html/*
22+
23+
# Copy custom nginx config
24+
COPY nginx.conf /etc/nginx/nginx.conf
2925

30-
COPY --from=builder /app/build ./build
31-
RUN npm install -g serve
26+
# Copy built Vite files
27+
COPY --from=builder /app/dist /usr/share/nginx/html
3228

29+
# Healthcheck for nginx
3330
HEALTHCHECK --interval=10s --timeout=5s --start-period=5s --retries=3 \
34-
CMD wget --no-verbose --tries=1 --spider http://0.0.0.0:3000/health || exit 1
31+
CMD wget --no-verbose --tries=1 --spider http://0.0.0.0/health || exit 1
3532

36-
EXPOSE 3000
33+
# Expose port 80 (standard HTTP)
34+
EXPOSE 80
3735

38-
CMD ["serve", "-s", "build"]
36+
# Start nginx automatically
37+
CMD ["nginx", "-g", "daemon off;"]

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
develop:
2-
npm start
2+
npm run dev
33

44
build:
55
npm run build
@@ -13,7 +13,7 @@ docker-build: build
1313
docker push enchanter77/labconnect-frontend
1414

1515
lint:
16-
eslint --max-warnings=0 'src/**/*{js,jsx,ts,tsx}'
16+
npm run lint
1717

1818
lintfix:
1919
eslint --max-warnings=0 'src/**/*{js,jsx,ts,tsx}' --fix

index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8" />
6+
<link rel="icon" href="/favicon.ico" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8+
<title>Labconnect</title>
9+
</head>
10+
11+
<body>
12+
<div id="root"></div>
13+
<script type="module" src="/src/main.tsx"></script>
14+
</body>
15+
16+
</html>

nginx.conf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
worker_processes 1;
2+
3+
events { worker_connections 1024; }
4+
5+
http {
6+
include mime.types;
7+
default_type application/octet-stream;
8+
sendfile on;
9+
keepalive_timeout 65;
10+
11+
server {
12+
listen 80;
13+
14+
server_name _;
15+
16+
root /usr/share/nginx/html;
17+
index index.html;
18+
19+
location / {
20+
try_files $uri $uri/ /index.html;
21+
}
22+
23+
# Enable gzip compression
24+
gzip on;
25+
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
26+
}
27+
}

0 commit comments

Comments
 (0)