Development environment:
- Added Dockerfile.dev for local development - Configured volume mounts for hot reloading - Set up Vite dev server with proper host binding Production environment: - Streamlined multi-stage build process - Removed Nginx in favor of future Caddy setup - Optimized container size and build steps
This commit is contained in:
parent
5ed0662665
commit
14fb61aab9
7 changed files with 2956 additions and 4545 deletions
45
Dockerfile
45
Dockerfile
|
|
@ -1,32 +1,29 @@
|
||||||
# Build stage
|
FROM node:20-alpine AS base
|
||||||
FROM --platform=linux/amd64 node:20-alpine as build
|
|
||||||
ARG NODE_ENV=production
|
# Enable pnpm
|
||||||
ENV NODE_ENV=${NODE_ENV}
|
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# System dependencies with enhanced build tools
|
# Copy package files
|
||||||
RUN apk add --no-cache python3 make g++ curl git libc6-compat
|
COPY package.json pnpm-lock.yaml* ./
|
||||||
|
|
||||||
# Clean and prepare npm
|
# Install dependencies
|
||||||
RUN npm cache clean --force
|
FROM base AS deps
|
||||||
RUN npm install -g npm@latest
|
RUN pnpm install --frozen-lockfile
|
||||||
|
|
||||||
# Install dependencies from package.json
|
# Build the app
|
||||||
COPY package*.json ./
|
FROM base AS builder
|
||||||
RUN npm ci
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
RUN npm install -g typescript
|
|
||||||
|
|
||||||
# Copy source code and build
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN npm run build
|
RUN pnpm build
|
||||||
|
|
||||||
# Production stage with Nginx
|
# Production image
|
||||||
FROM nginx:alpine
|
FROM base AS runner
|
||||||
COPY --from=build /app/dist /usr/share/nginx/html
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
COPY --from=builder /app/dist ./dist
|
||||||
|
COPY package.json ./
|
||||||
|
|
||||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
EXPOSE 804
|
||||||
CMD curl -f http://localhost/ || exit 1
|
|
||||||
|
|
||||||
EXPOSE 80
|
CMD ["pnpm", "preview", "--port", "804", "--host"]
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
|
||||||
|
|
|
||||||
14
Dockerfile.dev
Normal file
14
Dockerfile.dev
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
FROM node:20-alpine
|
||||||
|
|
||||||
|
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY package.json pnpm-lock.yaml* ./
|
||||||
|
RUN pnpm install
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
CMD ["pnpm", "dev"]
|
||||||
16
docker-compose.dev.yml
Normal file
16
docker-compose.dev.yml
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
web-dev:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile.dev
|
||||||
|
ports:
|
||||||
|
- "5173:5173"
|
||||||
|
volumes:
|
||||||
|
- .:/app
|
||||||
|
- /app/node_modules
|
||||||
|
environment:
|
||||||
|
- NODE_ENV=development
|
||||||
|
- VITE_HOST=0.0.0.0
|
||||||
|
command: pnpm dev --host 0.0.0.0
|
||||||
|
|
@ -1,25 +1,14 @@
|
||||||
version: '3.8'
|
version: '3.8'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
web:
|
web:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
args:
|
dockerfile: Dockerfile
|
||||||
NODE_ENV: production
|
pull_policy: build
|
||||||
ports:
|
ports:
|
||||||
- "804:80"
|
- "804:804"
|
||||||
restart: always
|
environment:
|
||||||
healthcheck:
|
- NODE_ENV=production
|
||||||
test: ["CMD", "curl", "-f", "http://localhost"]
|
- PORT=804
|
||||||
interval: 30s
|
restart: unless-stopped
|
||||||
timeout: 10s
|
|
||||||
retries: 3
|
|
||||||
deploy:
|
|
||||||
resources:
|
|
||||||
limits:
|
|
||||||
cpus: '0.50'
|
|
||||||
memory: 512M
|
|
||||||
logging:
|
|
||||||
driver: "json-file"
|
|
||||||
options:
|
|
||||||
max-size: "10m"
|
|
||||||
max-file: "3"
|
|
||||||
4500
package-lock.json
generated
4500
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -36,5 +36,6 @@
|
||||||
"globals": "^15.12.0",
|
"globals": "^15.12.0",
|
||||||
"typescript": "~5.7.2",
|
"typescript": "~5.7.2",
|
||||||
"typescript-eslint": "^8.15.0"
|
"typescript-eslint": "^8.15.0"
|
||||||
}
|
},
|
||||||
|
"packageManager": "pnpm@9.14.2"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2894
pnpm-lock.yaml
generated
Normal file
2894
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue