Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ services:
environment:
NODE_ENV: ${NODE_ENV:-development}
NEXT_TELEMETRY_DISABLED: "1"
# App uses this to connect to Mongo:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review
All changes have been reviewed and approved based on the risk assessed.

Status:
Approved

MONGODB_URI: ${MONGODB_URI:-mongodb://appuser:apppass@mongo:27017/mokse?authSource=admin}
volumes:
- ${DEV_MOUNT:-.:/app}
# - ${DEV_NODEMODULES_MOUNT:-/app/node_modules} # this is thought to be handled in Dockerfile now
Expand All @@ -20,28 +18,3 @@ services:
condition: service_healthy
profiles:
- ${COMPOSE_PROFILES:-dev}

mongo:
image: mongo:7
container_name: mongo
restart: unless-stopped
# Expose the port ONLY in dev by default (override via .env if needed)
ports:
- "${MONGO_PORT:-27017}:27017"
environment:
MONGO_INITDB_ROOT_USERNAME: ${MONGO_ROOT_USER:-root}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_ROOT_PASS:-changeme}
MONGO_INITDB_DATABASE: ${MONGO_DB:-mokse}
volumes:
- mongo_data:/data/db
- ./docker/mongo/init:/docker-entrypoint-initdb.d:ro
healthcheck:
test: ["CMD-SHELL", "mongosh --norc --quiet --eval \"db.runCommand({ ping: 1 }).ok\" | grep 1 >/dev/null"]
interval: 10s
timeout: 5s
retries: 5
profiles:
- ${COMPOSE_PROFILES:-dev}

volumes:
mongo_data:
15 changes: 0 additions & 15 deletions docker/mongo/init/01-create-app-user.js

This file was deleted.

47 changes: 47 additions & 0 deletions ogDockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# ---- Base ----
Comment thread
JMG3000 marked this conversation as resolved.
FROM node:20-alpine AS base
WORKDIR /app
RUN apk add --no-cache libc6-compat
ENV NEXT_TELEMETRY_DISABLED=1

# ---- Deps (with dev deps; used by dev & build) ----
FROM base AS deps
COPY package.json package-lock.json* pnpm-lock.yaml* yarn.lock* .npmrc* ./
RUN if [ -f package-lock.json ]; then npm ci; else npm install; fi

# ---- Builder (prod build) ----
FROM base AS builder
ENV NODE_ENV=development
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Standalone output for tiny runtime
RUN npm run build

# ---- Runner (prod runtime) ----
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1

# Non-root
RUN addgroup -S nextjs && adduser -S nextjs -G nextjs

# Only what the server needs
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public

RUN apk add --no-cache wget

EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=5s --retries=3 CMD wget -qO- http://127.0.0.1:3000/ || exit 1
USER nextjs
CMD ["node", "server.js"]

# ---- Dev (hot-reload runtime) ----
FROM base AS dev
ENV NODE_ENV=development
COPY --from=deps /app/node_modules ./node_modules
# source is bind-mounted in compose; keep image lean
EXPOSE 3000
CMD ["npm", "run", "dev"]
Loading