dockerize properly
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,6 +9,7 @@ node_modules
|
||||
.pnp.js
|
||||
|
||||
# Local env files
|
||||
docker.env
|
||||
.env
|
||||
.env.local
|
||||
.env.development.local
|
||||
|
||||
@@ -15,21 +15,32 @@ COPY package.json pnpm-lock.yaml* pnpm-workspace.yaml* ./
|
||||
COPY apps/admin/package.json ./apps/admin/
|
||||
COPY packages/db/package.json ./packages/db/
|
||||
COPY packages/ui/package.json ./packages/ui/
|
||||
COPY packages/eslint-config/package.json ./packages/eslint-config/
|
||||
COPY packages/typescript-config/package.json ./packages/typescript-config/
|
||||
|
||||
# Install dependencies
|
||||
# Install dependencies (including devDependencies for build process)
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# Rebuild the source code only when needed
|
||||
FROM base AS builder
|
||||
RUN apk update && apk add --no-cache libc6-compat
|
||||
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||
WORKDIR /app
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
|
||||
# Copy environment file for build process and create .env for dotenv-cli
|
||||
COPY docker.env ./docker.env
|
||||
COPY docker.env ./.env
|
||||
|
||||
# Set environment variables for build
|
||||
ENV NEXT_TELEMETRY_DISABLED 1
|
||||
ENV NODE_ENV production
|
||||
|
||||
# Build the application
|
||||
# Ensure devDependencies are available during build (needed for PostCSS plugins)
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# Build the application with environment variables
|
||||
RUN pnpm turbo run build --filter=admin...
|
||||
|
||||
# Production image, copy all the files and run next
|
||||
@@ -53,9 +64,9 @@ RUN chown nextjs:nodejs .next
|
||||
|
||||
USER nextjs
|
||||
|
||||
EXPOSE 3001
|
||||
EXPOSE 9001
|
||||
|
||||
ENV PORT 3001
|
||||
ENV PORT 9001
|
||||
ENV HOSTNAME "0.0.0.0"
|
||||
|
||||
# server.js is created by next build from the standalone output
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "dotenv -e ../../.env -- next dev --turbopack -p 3001",
|
||||
"dev": "dotenv -e ../../.env -- next dev --turbopack -p 9001",
|
||||
"build": "dotenv -e ../../.env -- next build",
|
||||
"start": "dotenv -e ../../.env -- next start -p 3001",
|
||||
"start": "dotenv -e ../../.env -- next start -p 9001",
|
||||
"lint": "next lint",
|
||||
"lint:fix": "next lint --fix",
|
||||
"typecheck": "tsc --noEmit"
|
||||
|
||||
@@ -15,21 +15,32 @@ COPY package.json pnpm-lock.yaml* pnpm-workspace.yaml* ./
|
||||
COPY apps/student/package.json ./apps/student/
|
||||
COPY packages/db/package.json ./packages/db/
|
||||
COPY packages/ui/package.json ./packages/ui/
|
||||
COPY packages/eslint-config/package.json ./packages/eslint-config/
|
||||
COPY packages/typescript-config/package.json ./packages/typescript-config/
|
||||
|
||||
# Install dependencies
|
||||
# Install dependencies (including devDependencies for build process)
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# Rebuild the source code only when needed
|
||||
FROM base AS builder
|
||||
RUN apk update && apk add --no-cache libc6-compat
|
||||
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||
WORKDIR /app
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
|
||||
# Copy environment file for build process and create .env for dotenv-cli
|
||||
COPY docker.env ./docker.env
|
||||
COPY docker.env ./.env
|
||||
|
||||
# Set environment variables for build
|
||||
ENV NEXT_TELEMETRY_DISABLED 1
|
||||
ENV NODE_ENV production
|
||||
|
||||
# Build the application
|
||||
# Ensure devDependencies are available during build (needed for PostCSS plugins)
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# Build the application with environment variables
|
||||
RUN pnpm turbo run build --filter=student...
|
||||
|
||||
# Production image, copy all the files and run next
|
||||
@@ -38,6 +49,7 @@ WORKDIR /app
|
||||
|
||||
ENV NODE_ENV production
|
||||
ENV NEXT_TELEMETRY_DISABLED 1
|
||||
ENV ADMIN_DOMAIN "http://admin:9001"
|
||||
|
||||
RUN addgroup --system --gid 1001 nodejs
|
||||
RUN adduser --system --uid 1001 nextjs
|
||||
@@ -53,9 +65,9 @@ RUN chown nextjs:nodejs .next
|
||||
|
||||
USER nextjs
|
||||
|
||||
EXPOSE 3000
|
||||
EXPOSE 9000
|
||||
|
||||
ENV PORT 3000
|
||||
ENV PORT 9000
|
||||
ENV HOSTNAME "0.0.0.0"
|
||||
|
||||
# server.js is created by next build from the standalone output
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "dotenv -e ../../.env -- next dev --turbopack -p 3000",
|
||||
"dev": "dotenv -e ../../.env -- next dev --turbopack -p 9000",
|
||||
"build": "dotenv -e ../../.env -- next build",
|
||||
"start": "dotenv -e ../../.env -- next start -p 3000",
|
||||
"start": "dotenv -e ../../.env -- next start -p 9000",
|
||||
"lint": "next lint",
|
||||
"lint:fix": "next lint --fix",
|
||||
"typecheck": "tsc --noEmit"
|
||||
|
||||
@@ -7,21 +7,21 @@ services:
|
||||
context: .
|
||||
dockerfile: apps/student/Dockerfile
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "9000:9000"
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- PORT=3000
|
||||
- PORT=9000
|
||||
- HOSTNAME=0.0.0.0
|
||||
# Add your environment variables here
|
||||
# env_file:
|
||||
# - .env
|
||||
env_file:
|
||||
- docker.env
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/api/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
# healthcheck:
|
||||
# test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:9000/api/health"]
|
||||
# interval: 30s
|
||||
# timeout: 10s
|
||||
# retries: 3
|
||||
# start_period: 40s
|
||||
|
||||
# Admin application
|
||||
admin:
|
||||
@@ -29,21 +29,21 @@ services:
|
||||
context: .
|
||||
dockerfile: apps/admin/Dockerfile
|
||||
ports:
|
||||
- "3001:3001"
|
||||
- "9001:9001"
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- PORT=3001
|
||||
- PORT=9001
|
||||
- HOSTNAME=0.0.0.0
|
||||
# Add your environment variables here
|
||||
# env_file:
|
||||
# - .env
|
||||
env_file:
|
||||
- docker.env
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3001/api/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
# healthcheck:
|
||||
# test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:9001/api/health"]
|
||||
# interval: 30s
|
||||
# timeout: 10s
|
||||
# retries: 3
|
||||
# start_period: 40s
|
||||
|
||||
# Database (if you need one)
|
||||
# postgres:
|
||||
|
||||
Reference in New Issue
Block a user