Add Docker support and update Vite config for container dev
- Add Dockerfile for Node-based Vite dev server setup - Add empty docker-compose.yml as placeholder - Set Vite to listen on 0.0.0.0 and strict port 5173 in config
This commit is contained in:
25
Dockerfile
Normal file
25
Dockerfile
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# Use official Node.js image
|
||||||
|
FROM node:20
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy only package.json and package-lock.json for install step
|
||||||
|
COPY package.json ./
|
||||||
|
# If you have a package-lock.json or pnpm-lock.yaml/yarn.lock, copy it as well
|
||||||
|
# COPY package-lock.json ./
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
# Now copy the rest of the app
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Expose the Vite dev server port
|
||||||
|
EXPOSE 5173
|
||||||
|
|
||||||
|
# Set environment variable if desired (can be overridden in compose)
|
||||||
|
ENV HOST=0.0.0.0
|
||||||
|
|
||||||
|
# Default command runs Vite dev server
|
||||||
|
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"]
|
||||||
0
docker-compose.yml
Normal file
0
docker-compose.yml
Normal file
@@ -3,5 +3,10 @@ import react from '@vitejs/plugin-react'
|
|||||||
import tailwind from '@tailwindcss/vite'
|
import tailwind from '@tailwindcss/vite'
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
server: {
|
||||||
|
host: '0.0.0.0', // or 'my.local.dev'
|
||||||
|
port: 5173,
|
||||||
|
strictPort: true
|
||||||
|
},
|
||||||
plugins: [react(), tailwind()],
|
plugins: [react(), tailwind()],
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user