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 --platform=linux/amd64 node:20-alpine as build
|
||||
ARG NODE_ENV=production
|
||||
ENV NODE_ENV=${NODE_ENV}
|
||||
FROM node:20-alpine AS base
|
||||
|
||||
# Enable pnpm
|
||||
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# System dependencies with enhanced build tools
|
||||
RUN apk add --no-cache python3 make g++ curl git libc6-compat
|
||||
# Copy package files
|
||||
COPY package.json pnpm-lock.yaml* ./
|
||||
|
||||
# Clean and prepare npm
|
||||
RUN npm cache clean --force
|
||||
RUN npm install -g npm@latest
|
||||
# Install dependencies
|
||||
FROM base AS deps
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# Install dependencies from package.json
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
RUN npm install -g typescript
|
||||
|
||||
# Copy source code and build
|
||||
# Build the app
|
||||
FROM base AS builder
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
RUN pnpm build
|
||||
|
||||
# Production stage with Nginx
|
||||
FROM nginx:alpine
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
# Production image
|
||||
FROM base AS runner
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY --from=builder /app/dist ./dist
|
||||
COPY package.json ./
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost/ || exit 1
|
||||
EXPOSE 804
|
||||
|
||||
EXPOSE 80
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
CMD ["pnpm", "preview", "--port", "804", "--host"]
|
||||
|
|
|
|||
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'
|
||||
|
||||
services:
|
||||
web:
|
||||
build:
|
||||
context: .
|
||||
args:
|
||||
NODE_ENV: production
|
||||
dockerfile: Dockerfile
|
||||
pull_policy: build
|
||||
ports:
|
||||
- "804:80"
|
||||
restart: always
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '0.50'
|
||||
memory: 512M
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
- "804:804"
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- PORT=804
|
||||
restart: unless-stopped
|
||||
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",
|
||||
"typescript": "~5.7.2",
|
||||
"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