mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-18 11:59:26 +00:00
chore: add .dockerignore file and update Dockerfile for improved build process and environment management for self hosting
This commit is contained in:
parent
05abc93017
commit
0db916c512
5 changed files with 1727 additions and 1475 deletions
132
.dockerignore
Normal file
132
.dockerignore
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
# Dependencies
|
||||
node_modules
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
|
||||
# Production builds
|
||||
.next
|
||||
out
|
||||
dist
|
||||
build
|
||||
|
||||
# Environment files
|
||||
.env
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
# IDE files
|
||||
.vscode
|
||||
.idea
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# OS files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Git
|
||||
.git
|
||||
.gitignore
|
||||
|
||||
# Docker
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
docker-compose.yml
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Dependency directories
|
||||
jspm_packages/
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Storybook build outputs
|
||||
.out
|
||||
.storybook-out
|
||||
|
||||
# Temporary folders
|
||||
tmp/
|
||||
temp/
|
||||
|
||||
# Python
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
*.so
|
||||
.Python
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
.pytest_cache/
|
||||
.coverage
|
||||
htmlcov/
|
||||
.tox/
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
.hypothesis/
|
||||
|
||||
# Database
|
||||
*.db
|
||||
*.sqlite3
|
||||
|
||||
# Media files (can be large)
|
||||
uploads/
|
||||
media/
|
||||
|
||||
# Documentation
|
||||
README.md
|
||||
docs/
|
||||
*.md
|
||||
87
Dockerfile
87
Dockerfile
|
|
@ -1,5 +1,5 @@
|
|||
# Base image
|
||||
FROM python:3.12.3-slim-bookworm as base
|
||||
# Base image for Python backend
|
||||
FROM python:3.12.3-slim-bookworm AS base
|
||||
|
||||
# Install Nginx, curl, and build-essential
|
||||
RUN apt update && apt install -y nginx curl build-essential \
|
||||
|
|
@ -10,32 +10,80 @@ RUN apt update && apt install -y nginx curl build-essential \
|
|||
# Install Node tools
|
||||
RUN curl -fsSL https://deb.nodesource.com/setup_21.x | bash - \
|
||||
&& apt-get install -y nodejs \
|
||||
&& npm install -g corepack pm2
|
||||
&& npm install -g pm2
|
||||
|
||||
# Frontend Build
|
||||
FROM base AS deps
|
||||
# Frontend Build - Using Node.js Alpine for better performance
|
||||
FROM node:22-alpine AS frontend-base
|
||||
|
||||
# Install dependencies only when needed
|
||||
FROM frontend-base AS frontend-deps
|
||||
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
||||
RUN apk add --no-cache libc6-compat
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies based on the preferred package manager
|
||||
COPY apps/web/package.json apps/web/pnpm-lock.yaml* ./
|
||||
RUN \
|
||||
if [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
|
||||
else echo "Lockfile not found." && exit 1; \
|
||||
fi
|
||||
|
||||
# Rebuild the source code only when needed
|
||||
FROM frontend-base AS frontend-builder
|
||||
WORKDIR /app
|
||||
COPY --from=frontend-deps /app/node_modules ./node_modules
|
||||
COPY apps/web .
|
||||
|
||||
# Set environment variables for the build
|
||||
ENV NEXT_PUBLIC_LEARNHOUSE_API_URL=http://localhost/api/v1/
|
||||
ENV NEXT_PUBLIC_LEARNHOUSE_BACKEND_URL=http://localhost/
|
||||
ENV NEXT_PUBLIC_LEARNHOUSE_DOMAIN=localhost
|
||||
|
||||
WORKDIR /app/web
|
||||
COPY ./apps/web/package.json ./apps/web/pnpm-lock.yaml* ./
|
||||
COPY ./apps/web /app/web
|
||||
# Next.js collects completely anonymous telemetry data about general usage.
|
||||
# Learn more here: https://nextjs.org/telemetry
|
||||
# Uncomment the following line in case you want to disable telemetry during the build.
|
||||
# ENV NEXT_TELEMETRY_DISABLED 1
|
||||
|
||||
# Remove .env files from the final image
|
||||
# This is a good practice to avoid leaking sensitive data
|
||||
# Learn more about it in the Next.js documentation: https://nextjs.org/docs/basic-features/environment-variables
|
||||
RUN rm -f .env*
|
||||
RUN if [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile && pnpm run build; \
|
||||
|
||||
RUN \
|
||||
if [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
|
||||
else echo "Lockfile not found." && exit 1; \
|
||||
fi
|
||||
|
||||
# Final image
|
||||
FROM base as runner
|
||||
RUN addgroup --system --gid 1001 system \
|
||||
&& adduser --system --uid 1001 app \
|
||||
&& mkdir .next \
|
||||
&& chown app:system .next
|
||||
COPY --from=deps /app/web/public ./app/web/public
|
||||
COPY --from=deps --chown=app:system /app/web/.next/standalone ./app/web/
|
||||
COPY --from=deps --chown=app:system /app/web/.next/static ./app/web/.next/static
|
||||
# Production image, copy all the files and run next
|
||||
FROM frontend-base AS frontend-runner
|
||||
WORKDIR /app
|
||||
|
||||
# Install curl
|
||||
RUN apk add --no-cache curl
|
||||
|
||||
ENV NODE_ENV production
|
||||
# Uncomment the following line in case you want to disable telemetry during runtime.
|
||||
# ENV NEXT_TELEMETRY_DISABLED 1
|
||||
|
||||
RUN addgroup --system --gid 1001 nodejs
|
||||
RUN adduser --system --uid 1001 nextjs
|
||||
|
||||
COPY --from=frontend-builder /app/public ./public
|
||||
|
||||
# Set the correct permission for prerender cache
|
||||
RUN mkdir .next
|
||||
RUN chown nextjs:nodejs .next
|
||||
|
||||
# Automatically leverage output traces to reduce image size
|
||||
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
||||
COPY --from=frontend-builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||
COPY --from=frontend-builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||
|
||||
# Final image combining frontend and backend
|
||||
FROM base AS runner
|
||||
|
||||
# Copy the frontend standalone build
|
||||
COPY --from=frontend-runner /app /app/web
|
||||
|
||||
# Backend Build
|
||||
WORKDIR /app/api
|
||||
|
|
@ -51,4 +99,5 @@ WORKDIR /app
|
|||
COPY ./extra/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
ENV PORT=8000 LEARNHOUSE_PORT=9000 HOSTNAME=0.0.0.0
|
||||
COPY ./extra/start.sh /app/start.sh
|
||||
CMD ["sh", "start.sh"]
|
||||
RUN chmod +x /app/start.sh
|
||||
CMD ["sh", "/app/start.sh"]
|
||||
|
|
@ -30,7 +30,7 @@ export default function RootLayout({
|
|||
initial="hidden" // Set the initial state to variants.hidden
|
||||
animate="enter" // Animated state to variants.enter
|
||||
exit="exit" // Exit state (used later) to variants.exit
|
||||
transition={{ type: 'linear' }} // Set the transition to linear
|
||||
transition={{ type: 'tween' }} // Set the transition to tween
|
||||
>
|
||||
{children}
|
||||
</motion.main>
|
||||
|
|
|
|||
|
|
@ -16,39 +16,39 @@
|
|||
"@hello-pangea/dnd": "^18.0.1",
|
||||
"@icons-pack/react-simple-icons": "^10.2.0",
|
||||
"@radix-ui/colors": "^0.1.9",
|
||||
"@radix-ui/react-aspect-ratio": "^1.1.2",
|
||||
"@radix-ui/react-aspect-ratio": "^1.1.7",
|
||||
"@radix-ui/react-checkbox": "^1.3.2",
|
||||
"@radix-ui/react-dialog": "^1.1.6",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.6",
|
||||
"@radix-ui/react-dialog": "^1.1.14",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.15",
|
||||
"@radix-ui/react-form": "^0.0.3",
|
||||
"@radix-ui/react-hover-card": "^1.1.6",
|
||||
"@radix-ui/react-hover-card": "^1.1.14",
|
||||
"@radix-ui/react-icons": "^1.3.2",
|
||||
"@radix-ui/react-label": "^2.1.2",
|
||||
"@radix-ui/react-select": "^2.1.6",
|
||||
"@radix-ui/react-slot": "^1.1.2",
|
||||
"@radix-ui/react-switch": "^1.1.3",
|
||||
"@radix-ui/react-tabs": "^1.1.3",
|
||||
"@radix-ui/react-toggle": "^1.1.2",
|
||||
"@radix-ui/react-toggle-group": "^1.1.2",
|
||||
"@radix-ui/react-tooltip": "^1.1.8",
|
||||
"@radix-ui/react-label": "^2.1.7",
|
||||
"@radix-ui/react-select": "^2.2.5",
|
||||
"@radix-ui/react-slot": "^1.2.3",
|
||||
"@radix-ui/react-switch": "^1.2.5",
|
||||
"@radix-ui/react-tabs": "^1.1.12",
|
||||
"@radix-ui/react-toggle": "^1.1.9",
|
||||
"@radix-ui/react-toggle-group": "^1.1.10",
|
||||
"@radix-ui/react-tooltip": "^1.2.7",
|
||||
"@stitches/react": "^1.2.8",
|
||||
"@tanstack/react-table": "^8.21.2",
|
||||
"@tiptap/core": "^2.11.7",
|
||||
"@tiptap/extension-bullet-list": "^2.11.7",
|
||||
"@tiptap/extension-code-block-lowlight": "^2.11.7",
|
||||
"@tiptap/extension-heading": "^2.12.0",
|
||||
"@tiptap/extension-link": "^2.11.7",
|
||||
"@tiptap/extension-list-item": "^2.11.7",
|
||||
"@tiptap/extension-ordered-list": "^2.11.7",
|
||||
"@tiptap/extension-table": "^2.11.7",
|
||||
"@tiptap/extension-table-cell": "^2.11.7",
|
||||
"@tiptap/extension-table-header": "^2.11.7",
|
||||
"@tiptap/extension-table-row": "^2.11.7",
|
||||
"@tiptap/extension-youtube": "^2.11.7",
|
||||
"@tiptap/html": "^2.11.7",
|
||||
"@tiptap/pm": "^2.11.7",
|
||||
"@tiptap/react": "^2.11.7",
|
||||
"@tiptap/starter-kit": "^2.11.7",
|
||||
"@tanstack/react-table": "^8.21.3",
|
||||
"@tiptap/core": "^2.26.1",
|
||||
"@tiptap/extension-bullet-list": "^2.26.1",
|
||||
"@tiptap/extension-code-block-lowlight": "^2.26.1",
|
||||
"@tiptap/extension-heading": "^2.26.1",
|
||||
"@tiptap/extension-link": "^2.26.1",
|
||||
"@tiptap/extension-list-item": "^2.26.1",
|
||||
"@tiptap/extension-ordered-list": "^2.26.1",
|
||||
"@tiptap/extension-table": "^2.26.1",
|
||||
"@tiptap/extension-table-cell": "^2.26.1",
|
||||
"@tiptap/extension-table-header": "^2.26.1",
|
||||
"@tiptap/extension-table-row": "^2.26.1",
|
||||
"@tiptap/extension-youtube": "^2.26.1",
|
||||
"@tiptap/html": "^2.26.1",
|
||||
"@tiptap/pm": "^2.26.1",
|
||||
"@tiptap/react": "^2.26.1",
|
||||
"@tiptap/starter-kit": "^2.26.1",
|
||||
"@types/dompurify": "^3.2.0",
|
||||
"@types/html2canvas": "^1.0.0",
|
||||
"@types/randomcolor": "^0.5.9",
|
||||
|
|
@ -57,16 +57,16 @@
|
|||
"clsx": "^2.1.1",
|
||||
"currency-codes": "^2.2.0",
|
||||
"dayjs": "^1.11.13",
|
||||
"dompurify": "^3.2.5",
|
||||
"dompurify": "^3.2.6",
|
||||
"emblor": "^1.4.8",
|
||||
"formik": "^2.4.6",
|
||||
"framer-motion": "^12.6.3",
|
||||
"framer-motion": "^12.23.12",
|
||||
"get-youtube-id": "^1.0.1",
|
||||
"highlight.js": "^11.11.1",
|
||||
"html2canvas": "^1.4.1",
|
||||
"jspdf": "^3.0.1",
|
||||
"jspdf-html2canvas": "^1.5.2",
|
||||
"katex": "^0.16.21",
|
||||
"katex": "^0.16.22",
|
||||
"lowlight": "^3.3.0",
|
||||
"lucide-react": "^0.453.0",
|
||||
"next": "15.3.5",
|
||||
|
|
@ -81,23 +81,23 @@
|
|||
"react-confetti": "^6.4.0",
|
||||
"react-dom": "19.0.0",
|
||||
"react-hot-toast": "^2.5.2",
|
||||
"react-katex": "^3.0.1",
|
||||
"react-katex": "^3.1.0",
|
||||
"react-plyr": "^2.2.0",
|
||||
"react-spinners": "^0.13.8",
|
||||
"react-youtube": "^10.1.0",
|
||||
"require-in-the-middle": "^7.5.2",
|
||||
"sharp": "^0.33.5",
|
||||
"styled-components": "^6.1.17",
|
||||
"swr": "^2.3.3",
|
||||
"styled-components": "^6.1.19",
|
||||
"swr": "^2.3.4",
|
||||
"tailwind-merge": "^2.6.0",
|
||||
"tailwindcss-animate": "^1.0.7",
|
||||
"unsplash-js": "^7.0.19",
|
||||
"usehooks-ts": "^3.1.1",
|
||||
"uuid": "^9.0.1",
|
||||
"yup": "^1.6.1"
|
||||
"yup": "^1.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/postcss": "^4.1.3",
|
||||
"@tailwindcss/postcss": "^4.1.11",
|
||||
"@types/node": "20.12.2",
|
||||
"@types/qrcode": "^1.5.5",
|
||||
"@types/react": "19.0.10",
|
||||
|
|
@ -106,11 +106,11 @@
|
|||
"@types/react-transition-group": "^4.4.12",
|
||||
"@types/styled-components": "^5.1.34",
|
||||
"@types/uuid": "^9.0.8",
|
||||
"eslint": "^9.24.0",
|
||||
"eslint": "^9.32.0",
|
||||
"eslint-config-next": "15.2.1",
|
||||
"eslint-plugin-unused-imports": "^3.2.0",
|
||||
"postcss": "^8.5.3",
|
||||
"tailwindcss": "^4.1.3",
|
||||
"postcss": "^8.5.6",
|
||||
"tailwindcss": "^4.1.11",
|
||||
"typescript": "5.4.4"
|
||||
},
|
||||
"pnpm": {
|
||||
|
|
|
|||
2895
apps/web/pnpm-lock.yaml
generated
2895
apps/web/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue