我无法访问我的容器,但在它创建后,我有这样的消息:
I propose that this problem occures by bad ports configuration.个
#Dockerfile
FROM node:20.11.1-alpine as builder
WORKDIR /app
COPY package.json ./
COPY package-lock.json ./
RUN npm install
COPY . .
EXPOSE 5173
CMD [ "npm", "run", "dev" ]
#docker-compose.dev.yml
version: "3.8"
services:
app:
container_name: front-end-app
image: app-dev
build:
context: ./../
dockerfile: ./Dockerfile
volumes:
- ./src:/app/src
ports:
- 5173:5173
stdin_open: true
env_file:
- ./../.env
#Package.json
"scripts": {
"dev": "vite",
}
!已更新 #vite.config.ts
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import tsconfigPaths from "vite-tsconfig-paths";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [tsconfigPaths(), react()],
});