使用Docker运行Remix
文件夹结构
-
- root/
docker-compose.yaml (本番用)
docker-compose-dev.yaml(開発用)
remix/
Dockerfile(本番用)
DockerfileDev(開発用)
remix文件夹是使用npx create-remix@latest命令创建的项目文件夹。
请使用本案
(Please use this case)
FROM node:20-alpine
WORKDIR /usr/server
COPY ./package.json ./
RUN npm install
COPY ./ .
RUN npm run build
ENV NODE_ENV=production
CMD ["npm", "run", "start"]
services:
remix:
build: ./remix
ports:
- "3000:3000"
volumes:
- ./remix/app:/usr/server/app
- ./remix/public:/usr/server/public
专为开发而设计的
FROM node:20-alpine
WORKDIR /usr/server
COPY ./package.json ./
RUN npm install
COPY ./ .
ENV NODE_ENV=development
CMD ["npm", "run", "dev"]
services:
remix:
build:
context: ./remix
dockerfile: DockerfileDev
ports:
- "3000:3000"
- "3001:3001"
volumes:
- ./remix/app:/usr/server/app
- ./remix/public:/usr/server/public
開發版會使WebSockets運作,並不僅僅開放3000端口,還會開放3001端口。