mirror of
https://github.com/remvze/moodist.git
synced 2025-12-18 17:34:17 +00:00
- 新增 Dockerfile.dev-server:类生产模式容器(无热重载干扰) - 新增 Dockerfile.prod-like:纯生产模式容器尝试 - 新增 Dockerfile.server:服务器模式容器 - 更新 docker-compose.yml:移除过时 version 字段,优化卷挂载 - 更新 .gitignore:忽略 data 目录(SQLite 数据库) - 更新 astro.config.mjs:支持服务器端渲染模式 这解决了 react-icons 在生产构建中的 ES 模块兼容性问题, 提供了稳定的生产级 Docker 部署方案。
58 lines
No EOL
1.4 KiB
Text
58 lines
No EOL
1.4 KiB
Text
# 使用现有的本地构建成果 - Node.js 服务器版本
|
||
FROM node:20-alpine
|
||
|
||
# 安装必要的系统依赖
|
||
RUN apk add --no-cache curl
|
||
|
||
# 创建应用用户
|
||
RUN addgroup -g 1001 -S nodejs && \
|
||
adduser -S nodejs -u 1001
|
||
|
||
# 设置工作目录
|
||
WORKDIR /app
|
||
|
||
# 设置环境变量
|
||
ENV NODE_ENV=production
|
||
ENV PORT=8080
|
||
|
||
# 复制package文件
|
||
COPY package*.json ./
|
||
|
||
# 安装所有依赖(运行时需要adapter)
|
||
RUN npm ci --ignore-scripts && \
|
||
npm cache clean --force
|
||
|
||
# 复制本地构建的完整产物
|
||
COPY --chown=nodejs:nodejs dist/ ./dist
|
||
|
||
# 创建数据目录
|
||
RUN mkdir -p /app/data && \
|
||
chown -R nodejs:nodejs /app
|
||
|
||
# 切换到非root用户
|
||
USER nodejs
|
||
|
||
# 暴露端口
|
||
EXPOSE 8080
|
||
|
||
# 健康检查
|
||
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
||
CMD curl -f http://localhost:8080/ || exit 1
|
||
|
||
# 启动应用
|
||
CMD ["node", "./dist/server/entry.mjs"]
|
||
|
||
# 定义构建参数
|
||
ARG VERSION=latest
|
||
ARG BUILD_DATE
|
||
ARG VCS_REF
|
||
|
||
# 添加标签信息
|
||
LABEL maintainer="walllee" \
|
||
org.opencontainers.image.title="Moodist" \
|
||
org.opencontainers.image.description="Ambient sounds for focus and calm - 多语言环境音应用 (Full Stack)" \
|
||
org.opencontainers.image.version="${VERSION}" \
|
||
org.opencontainers.image.created="${BUILD_DATE}" \
|
||
org.opencontainers.image.revision="${VCS_REF}" \
|
||
org.opencontainers.image.source="https://github.com/wheesys/moodist" \
|
||
org.opencontainers.image.licenses="MIT" |