clait doccker image
This commit is contained in:
parent
6e15458e4c
commit
4fd1f5f0b0
@ -1,4 +1,4 @@
|
|||||||
FROM node:20-bullseye-slim
|
FROM node:20-alpine
|
||||||
|
|
||||||
# Install Git during the build phase using apt.
|
# Install Git during the build phase using apt.
|
||||||
RUN apt-get update -y && apt-get install -y git && rm -rf /var/lib/apt/lists/*
|
RUN apt-get update -y && apt-get install -y git && rm -rf /var/lib/apt/lists/*
|
||||||
|
|||||||
@ -1,31 +1,99 @@
|
|||||||
version: "3.8"
|
version: "3.9"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
medusa:
|
# ─────────────────────── Databases & Caches ───────────────────────
|
||||||
|
postgres:
|
||||||
|
image: postgres:16-alpine
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: postgres
|
||||||
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||||
|
POSTGRES_DB: postgres
|
||||||
|
volumes:
|
||||||
|
- postgres-data:/var/lib/postgresql/data
|
||||||
|
networks: [backend]
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: redis:7-alpine
|
||||||
|
restart: unless-stopped
|
||||||
|
command: ["redis-server", "--requirepass", "${REDIS_PASSWORD}"]
|
||||||
|
volumes:
|
||||||
|
- redis-data:/data
|
||||||
|
networks: [backend]
|
||||||
|
|
||||||
|
minio:
|
||||||
|
image: minio/minio:RELEASE.2024-04-18T19-09-19Z
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
MINIO_ROOT_USER: ${MINIO_ROOT_USER}
|
||||||
|
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD}
|
||||||
|
command: server /data --console-address ":9001"
|
||||||
|
volumes:
|
||||||
|
- minio-data:/data
|
||||||
|
ports: # expose console if you like; remove ons‑prod
|
||||||
|
- "9001:9001"
|
||||||
|
networks: [backend]
|
||||||
|
|
||||||
|
# ─────────────────────── Medusa processes ───────────────────────
|
||||||
|
medusa-server:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: server/Server.Dockerfile # path relative to repo root
|
||||||
|
depends_on: [postgres, redis, minio]
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
# Core DB / cache
|
||||||
|
DATABASE_URL: postgres://postgres:${POSTGRES_PASSWORD}@postgres:5432/postgres?sslmode=disable
|
||||||
|
REDIS_URL: redis://default:${REDIS_PASSWORD}@redis:6379/0
|
||||||
|
# S3 (MinIO) storage
|
||||||
|
S3_ENDPOINT: http://minio:9000
|
||||||
|
S3_REGION: ${S3_REGION:-us-east-1}
|
||||||
|
S3_BUCKET: ${S3_BUCKET}
|
||||||
|
S3_ACCESS_KEY_ID: ${MINIO_ROOT_USER}
|
||||||
|
S3_SECRET_ACCESS_KEY: ${MINIO_ROOT_PASSWORD}
|
||||||
|
# Medusa‑specific
|
||||||
|
MEDUSA_BACKEND_URL: ${MEDUSA_BACKEND_URL:-http://localhost:9000}
|
||||||
|
MEDUSA_WORKER_MODE: server
|
||||||
|
DISABLE_MEDUSA_ADMIN: "false"
|
||||||
|
COOKIE_SECRET: ${COOKIE_SECRET}
|
||||||
|
JWT_SECRET: ${JWT_SECRET}
|
||||||
|
# CORS etc.
|
||||||
|
ADMIN_CORS: ${ADMIN_CORS}
|
||||||
|
STORE_CORS: ${STORE_CORS}
|
||||||
|
AUTH_CORS: ${AUTH_CORS}
|
||||||
|
# Any other keys (Stripe, Resend, …)
|
||||||
|
STRIPE_API_KEY: ${STRIPE_API_KEY}
|
||||||
|
STRIPE_WEBHOOK_SECRET: ${STRIPE_WEBHOOK_SECRET}
|
||||||
|
RESEND_API_KEY: ${RESEND_API_KEY}
|
||||||
|
RESEND_FROM_EMAIL: ${RESEND_FROM_EMAIL}
|
||||||
ports:
|
ports:
|
||||||
- "9000:9000"
|
- "9000:9000" # expose externally
|
||||||
environment:
|
networks: [backend]
|
||||||
# Default environment variables
|
|
||||||
DATABASE_URL: "postgres://medusa:medusa@db:5432/medusa?ssl_mode=disable"
|
|
||||||
# You can include additional environment variables as needed, e.g.:
|
|
||||||
MEDUSA_STORE_NAME: "My Medusa Store"
|
|
||||||
MEDUSA_ADMIN_EMAIL: "admin@medusajs.com"
|
|
||||||
MEDUSA_ADMIN_PASSWORD: "supersecret"
|
|
||||||
volumes:
|
|
||||||
# Persist the generated Medusa project so that installation only runs once.
|
|
||||||
- medusa_app_data:/app
|
|
||||||
|
|
||||||
db:
|
medusa-worker:
|
||||||
image: postgres:13
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: server/Worker.Dockerfile
|
||||||
|
depends_on: [postgres, redis]
|
||||||
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_USER: medusa
|
DATABASE_URL: postgres://postgres:${POSTGRES_PASSWORD}@postgres:5432/postgres?sslmode=disable
|
||||||
POSTGRES_PASSWORD: medusa
|
REDIS_URL: redis://default:${REDIS_PASSWORD}@redis:6379/0
|
||||||
POSTGRES_DB: medusa
|
S3_ENDPOINT: http://minio:9000
|
||||||
volumes:
|
S3_REGION: ${S3_REGION:-us-east-1}
|
||||||
- postgres_data:/var/lib/postgresql/data
|
S3_BUCKET: ${S3_BUCKET}
|
||||||
|
S3_ACCESS_KEY_ID: ${MINIO_ROOT_USER}
|
||||||
|
S3_SECRET_ACCESS_KEY: ${MINIO_ROOT_PASSWORD}
|
||||||
|
MEDUSA_WORKER_MODE: worker
|
||||||
|
DISABLE_MEDUSA_ADMIN: "true"
|
||||||
|
networks: [backend]
|
||||||
|
|
||||||
|
# ────────────────────────── Shared Stuff ──────────────────────────
|
||||||
volumes:
|
volumes:
|
||||||
medusa_app_data:
|
postgres-data:
|
||||||
postgres_data:
|
redis-data:
|
||||||
|
minio-data:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
backend:
|
||||||
|
driver: bridge
|
||||||
|
|||||||
41
server/Server.Dockerfile
Normal file
41
server/Server.Dockerfile
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
# Use Node.js base image
|
||||||
|
FROM node:20-alpine
|
||||||
|
LABEL authors="clait"
|
||||||
|
|
||||||
|
# Install dependencies only once
|
||||||
|
RUN apk add --no-cache curl && corepack enable
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
# Copy dependency files first to leverage Docker caching
|
||||||
|
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
|
||||||
|
|
||||||
|
# Install dependencies based on the lock file available
|
||||||
|
RUN \
|
||||||
|
if [ -f yarn.lock ]; then yarn install --immutable; \
|
||||||
|
elif [ -f package-lock.json ]; then npm ci; \
|
||||||
|
elif [ -f pnpm-lock.yaml ]; then pnpm i --frozen-lockfile; \
|
||||||
|
else echo "Lockfile not found." && exit 1; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Copy the rest of the application files (to avoid re-triggering dependency install step unnecessarily)
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Build the Medusa application
|
||||||
|
RUN \
|
||||||
|
if [ -f yarn.lock ]; then yarn build; \
|
||||||
|
elif [ -f package-lock.json ]; then npm run build; \
|
||||||
|
elif [ -f pnpm-lock.yaml ]; then pnpm run build; \
|
||||||
|
else echo "Lockfile not found." && exit 1; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install Medusa dependencies
|
||||||
|
WORKDIR /usr/src/app/.medusa/server
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
# Expose default Medusa port
|
||||||
|
EXPOSE 9000
|
||||||
|
|
||||||
|
# Command to run in production
|
||||||
|
CMD ["sh", "-c", "npm run predeploy && npm run start"]
|
||||||
41
server/Worker.Dockerfile
Normal file
41
server/Worker.Dockerfile
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
# Use Node.js base image
|
||||||
|
FROM node:20-alpine
|
||||||
|
LABEL authors="clait"
|
||||||
|
|
||||||
|
# Install dependencies only once
|
||||||
|
RUN apk add --no-cache curl && corepack enable
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
# Copy dependency files first to leverage Docker caching
|
||||||
|
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
|
||||||
|
|
||||||
|
# Install dependencies based on the lock file available
|
||||||
|
RUN \
|
||||||
|
if [ -f yarn.lock ]; then yarn install --immutable; \
|
||||||
|
elif [ -f package-lock.json ]; then npm ci; \
|
||||||
|
elif [ -f pnpm-lock.yaml ]; then pnpm i --frozen-lockfile; \
|
||||||
|
else echo "Lockfile not found." && exit 1; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Copy the rest of the application files (to avoid re-triggering dependency install step unnecessarily)
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Build the Medusa application
|
||||||
|
RUN \
|
||||||
|
if [ -f yarn.lock ]; then yarn build; \
|
||||||
|
elif [ -f package-lock.json ]; then npm run build; \
|
||||||
|
elif [ -f pnpm-lock.yaml ]; then pnpm run build; \
|
||||||
|
else echo "Lockfile not found." && exit 1; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install Medusa dependencies
|
||||||
|
WORKDIR /usr/src/app/.medusa/server
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
# Expose default Medusa port
|
||||||
|
EXPOSE 9000
|
||||||
|
|
||||||
|
# Command to run in production
|
||||||
|
CMD ["sh", "-c", "npm run start"]
|
||||||
Loading…
x
Reference in New Issue
Block a user