first pass
This commit is contained in:
32
templates/nodejs/vite-react-ssr/.dockerignore.template
Normal file
32
templates/nodejs/vite-react-ssr/.dockerignore.template
Normal file
@@ -0,0 +1,32 @@
|
||||
node_modules
|
||||
npm-debug.log*
|
||||
.git
|
||||
.gitignore
|
||||
.env
|
||||
.env.local
|
||||
.env.*.local
|
||||
*.tar
|
||||
*.tar.gz
|
||||
|
||||
# IDE
|
||||
.vscode
|
||||
.idea
|
||||
|
||||
# Test & Coverage
|
||||
coverage
|
||||
.nyc_output
|
||||
|
||||
# Build output (built during docker build)
|
||||
dist
|
||||
|
||||
# Documentation
|
||||
README.md
|
||||
README.DOCKER.md
|
||||
docs
|
||||
|
||||
# Docker files
|
||||
Dockerfile
|
||||
docker-compose.yml
|
||||
.dockerignore
|
||||
docker-deployment.json
|
||||
*.ps1
|
||||
34
templates/nodejs/vite-react-ssr/Dockerfile.template
Normal file
34
templates/nodejs/vite-react-ssr/Dockerfile.template
Normal file
@@ -0,0 +1,34 @@
|
||||
# Stage 1: Build
|
||||
FROM node:{{NODE_VERSION}}-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json package-lock.json* ./
|
||||
RUN npm ci
|
||||
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
# Stage 2: Production
|
||||
FROM node:{{NODE_VERSION}}-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files and install production dependencies
|
||||
COPY package.json package-lock.json* ./
|
||||
RUN npm ci --omit=dev
|
||||
|
||||
# Copy built files from builder
|
||||
COPY --from=builder /app/dist ./dist
|
||||
|
||||
# Copy server file
|
||||
COPY server.mjs ./server.mjs
|
||||
|
||||
# Set environment
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT={{PORT}}
|
||||
ENV DIST_DIR=/app/dist
|
||||
|
||||
EXPOSE {{PORT}}
|
||||
|
||||
CMD ["node", "server.mjs"]
|
||||
24
templates/nodejs/vite-react-ssr/docker-compose.yml.template
Normal file
24
templates/nodejs/vite-react-ssr/docker-compose.yml.template
Normal file
@@ -0,0 +1,24 @@
|
||||
services:
|
||||
{{PROJECT_NAME}}:
|
||||
build: .
|
||||
container_name: {{PROJECT_NAME}}
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "${HOST_PORT:-{{PORT}}}:{{PORT}}"
|
||||
{{#if USE_ENV_FILE}}
|
||||
env_file:
|
||||
- .env
|
||||
{{/if}}
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
PORT: {{PORT}}
|
||||
{{#if HAS_VOLUMES}}
|
||||
volumes:
|
||||
{{#each VOLUMES}}
|
||||
- {{this}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{#if EXTRA_HOSTS}}
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
{{/if}}
|
||||
Reference in New Issue
Block a user