8 Commits

14 changed files with 720 additions and 21 deletions

31
.dockerignore Normal file
View File

@@ -0,0 +1,31 @@
# Version control
.git
.gitignore
# Dependencies
**/node_modules
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Next.js build output
**/.next/
**/out/
# Medusa build output & cache
**/.medusa/
**/.cache/
# Local environment files (do NOT bake local secrets into images)
**/.env
**/.env.local
**/.env.development.local
**/.env.test.local
**/.env.production.local
# Turbo cache
**/.turbo
# OS metadata
.DS_Store
Thumbs.db

34
.env.production.example Normal file
View File

@@ -0,0 +1,34 @@
# ========================================================
# SUMAN D.O.O. — DOCKER PRODUKCIJSKE VARIJABLE OKRUŽENJA
# ========================================================
# Kopirajte ovaj fajl u .env.production ili .env na serveru:
# cp .env.production.example .env
# --- POSTGRESQL BAZA ---
POSTGRES_USER=suman_prod_user
POSTGRES_PASSWORD=PostaviSigurnuLozinkuBaze123!
POSTGRES_DB=suman_prod_db
# --- REDIS CACHE ---
REDIS_PASSWORD=PostaviSigurnuLozinkuRedis123!
# --- MEDUSA V2 BACKEND ---
BACKEND_PORT=9000
JWT_SECRET=generisi_siguran_jwt_secret_najmanje_32_karaktera
COOKIE_SECRET=generisi_siguran_cookie_secret_najmanje_32_karaktera
MEDUSA_BACKEND_URL=https://api.suman.ba
# CORS Konfiguracija (odvojeno zarezima)
STORE_CORS=https://suman.ba,https://suman.hr,http://localhost:8000,http://localhost:8002
ADMIN_CORS=https://admin.suman.ba,http://localhost:9000
AUTH_CORS=https://admin.suman.ba,https://suman.ba,https://suman.hr,http://localhost:9000,http://localhost:8000,http://localhost:8002
# --- STOREFRONT BOSNA I HERCEGOVINA ---
STOREFRONT_BA_PORT=8000
STOREFRONT_BA_BASE_URL=https://suman.ba
MEDUSA_PUBLISHABLE_KEY_BA=pk_b722e44870bc8cc7828d0713980537e95b2e74ff229a529a4b3fa8155035f1f0
# --- STOREFRONT HRVATSKA ---
STOREFRONT_HR_PORT=8002
STOREFRONT_HR_BASE_URL=https://suman.hr
MEDUSA_PUBLISHABLE_KEY_HR=pk_suman_hrvatska_publishable_key

65
Dockerfile Normal file
View File

@@ -0,0 +1,65 @@
# ==========================================
# Root Dockerfile for Dokploy & Monorepo Deployments
# Defaults to building the Medusa v2 Backend
# ==========================================
# 1. Base stage with dependencies
FROM node:22-alpine AS base
WORKDIR /app
RUN apk add --no-cache libc6-compat curl
# Copy root workspace manifests
COPY package.json package-lock.json ./
COPY apps/backend/package.json ./apps/backend/
COPY apps/suman-bosna/package.json ./apps/suman-bosna/
COPY apps/suman-hrvatska/package.json ./apps/suman-hrvatska/
# Install dependencies for backend workspace
RUN npm ci --workspace=@dtc/backend --include-workspace-root
# 2. Build stage
FROM base AS builder
WORKDIR /app
COPY apps/backend ./apps/backend
ENV NODE_ENV=production
ENV NODE_OPTIONS="--max-old-space-size=2048"
# Build Medusa backend and admin dashboard
RUN npm run build --workspace=@dtc/backend
# Copy compiled medusa-config.js and instrumentation.js to project root for production Node.js runtime
RUN cp apps/backend/.medusa/server/medusa-config.js apps/backend/medusa-config.js && \
if [ -f apps/backend/.medusa/server/instrumentation.js ]; then cp apps/backend/.medusa/server/instrumentation.js apps/backend/instrumentation.js; fi
# Prune devDependencies to keep image light and avoid OOM during copy
RUN npm prune --production --workspace=@dtc/backend
# 3. Production runner stage
FROM node:22-alpine AS runner
WORKDIR /app/apps/backend
RUN apk add --no-cache libc6-compat curl
ENV NODE_ENV=production
ENV PORT=9000
# Non-root user
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 medusa
# Copy pruned dependencies from builder (sequential dependency prevents BuildKit parallel I/O spike)
COPY --from=builder --chown=medusa:nodejs /app/node_modules /app/node_modules
COPY --from=builder --chown=medusa:nodejs /app/package.json /app/package-lock.json /app/
COPY --from=builder --chown=medusa:nodejs /app/apps/backend /app/apps/backend
# Uploads directory
RUN mkdir -p /app/apps/backend/uploads && chown -R medusa:nodejs /app/apps/backend/uploads
USER medusa
EXPOSE 9000
# Run migrations and start Medusa production server
CMD ["sh", "-c", "npx medusa db:migrate && npm run start"]

64
apps/backend/Dockerfile Normal file
View File

@@ -0,0 +1,64 @@
# ==========================================
# Medusa v2 Production Dockerfile
# ==========================================
# 1. Base stage with dependencies
FROM node:22-alpine AS base
WORKDIR /app
RUN apk add --no-cache libc6-compat curl
# Copy root workspace manifests
COPY package.json package-lock.json ./
COPY apps/backend/package.json ./apps/backend/
COPY apps/suman-bosna/package.json ./apps/suman-bosna/
COPY apps/suman-hrvatska/package.json ./apps/suman-hrvatska/
# Install dependencies for backend workspace
RUN npm ci --workspace=@dtc/backend --include-workspace-root
# 2. Build stage
FROM base AS builder
WORKDIR /app
COPY apps/backend ./apps/backend
ENV NODE_ENV=production
ENV NODE_OPTIONS="--max-old-space-size=2048"
# Build Medusa backend and admin dashboard
RUN npm run build --workspace=@dtc/backend
# Copy compiled medusa-config.js and instrumentation.js to project root for production Node.js runtime
RUN cp apps/backend/.medusa/server/medusa-config.js apps/backend/medusa-config.js && \
if [ -f apps/backend/.medusa/server/instrumentation.js ]; then cp apps/backend/.medusa/server/instrumentation.js apps/backend/instrumentation.js; fi
# Prune devDependencies to keep image light and avoid OOM during copy
RUN npm prune --production --workspace=@dtc/backend
# 3. Production runner stage
FROM node:22-alpine AS runner
WORKDIR /app/apps/backend
RUN apk add --no-cache libc6-compat curl
ENV NODE_ENV=production
ENV PORT=9000
# Non-root user
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 medusa
# Copy pruned dependencies from builder (sequential dependency prevents BuildKit parallel I/O spike)
COPY --from=builder --chown=medusa:nodejs /app/node_modules /app/node_modules
COPY --from=builder --chown=medusa:nodejs /app/package.json /app/package-lock.json /app/
COPY --from=builder --chown=medusa:nodejs /app/apps/backend /app/apps/backend
# Uploads directory
RUN mkdir -p /app/apps/backend/uploads && chown -R medusa:nodejs /app/apps/backend/uploads
USER medusa
EXPOSE 9000
# Run migrations and start Medusa production server
CMD ["sh", "-c", "npx medusa db:migrate && npm run start"]

View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@medusajs/framework/utils");
(0, utils_1.loadEnv)(process.env.NODE_ENV || 'development', process.cwd());
module.exports = (0, utils_1.defineConfig)({
projectConfig: {
databaseUrl: process.env.DATABASE_URL,
http: {
storeCors: process.env.STORE_CORS,
adminCors: process.env.ADMIN_CORS,
authCors: process.env.AUTH_CORS,
jwtSecret: process.env.JWT_SECRET,
cookieSecret: process.env.COOKIE_SECRET,
}
},
modules: [
{
resolve: "./src/modules/inquiry",
},
],
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWVkdXNhLWNvbmZpZy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL21lZHVzYS1jb25maWcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxxREFBaUU7QUFFakUsSUFBQSxlQUFPLEVBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxRQUFRLElBQUksYUFBYSxFQUFFLE9BQU8sQ0FBQyxHQUFHLEVBQUUsQ0FBQyxDQUFBO0FBRTdELE1BQU0sQ0FBQyxPQUFPLEdBQUcsSUFBQSxvQkFBWSxFQUFDO0lBQzVCLGFBQWEsRUFBRTtRQUNiLFdBQVcsRUFBRSxPQUFPLENBQUMsR0FBRyxDQUFDLFlBQVk7UUFDckMsSUFBSSxFQUFFO1lBQ0osU0FBUyxFQUFFLE9BQU8sQ0FBQyxHQUFHLENBQUMsVUFBVztZQUNsQyxTQUFTLEVBQUUsT0FBTyxDQUFDLEdBQUcsQ0FBQyxVQUFXO1lBQ2xDLFFBQVEsRUFBRSxPQUFPLENBQUMsR0FBRyxDQUFDLFNBQVU7WUFDaEMsU0FBUyxFQUFFLE9BQU8sQ0FBQyxHQUFHLENBQUMsVUFBVTtZQUNqQyxZQUFZLEVBQUUsT0FBTyxDQUFDLEdBQUcsQ0FBQyxhQUFhO1NBQ3hDO0tBQ0Y7SUFDRCxPQUFPLEVBQUU7UUFDUDtZQUNFLE9BQU8sRUFBRSx1QkFBdUI7U0FDakM7S0FDRjtDQUNGLENBQUMsQ0FBQSJ9

View File

@@ -32,5 +32,6 @@
".medusa/admin", ".medusa/admin",
".cache", ".cache",
"eslint.config.*", "eslint.config.*",
"src/scripts"
] ]
} }

View File

@@ -0,0 +1,56 @@
# ==========================================
# Next.js 16 Storefront Production Dockerfile (Suman Bosna)
# ==========================================
# 1. Base stage with dependencies
FROM node:22-alpine AS base
WORKDIR /app
RUN apk add --no-cache libc6-compat
COPY package.json package-lock.json ./
COPY apps/backend/package.json ./apps/backend/
COPY apps/suman-bosna/package.json ./apps/suman-bosna/
COPY apps/suman-hrvatska/package.json ./apps/suman-hrvatska/
RUN npm ci --workspace=@dtc/suman-bosna --include-workspace-root
# 2. Build stage
FROM base AS builder
WORKDIR /app
COPY apps/suman-bosna ./apps/suman-bosna
ARG NEXT_PUBLIC_MEDUSA_BACKEND_URL
ARG NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY
ARG NEXT_PUBLIC_BASE_URL
ARG NEXT_PUBLIC_DEFAULT_REGION=ba
ENV NEXT_PUBLIC_MEDUSA_BACKEND_URL=$NEXT_PUBLIC_MEDUSA_BACKEND_URL
ENV NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY=$NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY
ENV NEXT_PUBLIC_BASE_URL=$NEXT_PUBLIC_BASE_URL
ENV NEXT_PUBLIC_DEFAULT_REGION=$NEXT_PUBLIC_DEFAULT_REGION
ENV NODE_ENV=production
RUN npm run build --workspace=@dtc/suman-bosna
# 3. Production runner stage
FROM node:22-alpine AS runner
WORKDIR /app/apps/suman-bosna
RUN apk add --no-cache libc6-compat curl
ENV NODE_ENV=production
ENV PORT=8000
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs
COPY --from=base --chown=nextjs:nodejs /app/node_modules /app/node_modules
COPY --from=base --chown=nextjs:nodejs /app/package.json /app/package-lock.json /app/
COPY --from=builder --chown=nextjs:nodejs /app/apps/suman-bosna /app/apps/suman-bosna
USER nextjs
EXPOSE 8000
CMD ["npm", "run", "start"]

View File

@@ -1,7 +1,7 @@
/// <reference types="next" /> /// <reference types="next" />
/// <reference types="next/image-types/global" /> /// <reference types="next/image-types/global" />
import "./.next/dev/types/routes.d.ts"; import "./.next/types/routes.d.ts";
import "./.next/dev/types/root-params.d.ts"; import "./.next/types/root-params.d.ts";
// NOTE: This file should not be edited // NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information. // see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

View File

@@ -0,0 +1,56 @@
# ==========================================
# Next.js 16 Storefront Production Dockerfile (Suman Hrvatska)
# ==========================================
# 1. Base stage with dependencies
FROM node:22-alpine AS base
WORKDIR /app
RUN apk add --no-cache libc6-compat
COPY package.json package-lock.json ./
COPY apps/backend/package.json ./apps/backend/
COPY apps/suman-bosna/package.json ./apps/suman-bosna/
COPY apps/suman-hrvatska/package.json ./apps/suman-hrvatska/
RUN npm ci --workspace=@dtc/suman-hrvatska --include-workspace-root
# 2. Build stage
FROM base AS builder
WORKDIR /app
COPY apps/suman-hrvatska ./apps/suman-hrvatska
ARG NEXT_PUBLIC_MEDUSA_BACKEND_URL
ARG NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY
ARG NEXT_PUBLIC_BASE_URL
ARG NEXT_PUBLIC_DEFAULT_REGION=hr
ENV NEXT_PUBLIC_MEDUSA_BACKEND_URL=$NEXT_PUBLIC_MEDUSA_BACKEND_URL
ENV NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY=$NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY
ENV NEXT_PUBLIC_BASE_URL=$NEXT_PUBLIC_BASE_URL
ENV NEXT_PUBLIC_DEFAULT_REGION=$NEXT_PUBLIC_DEFAULT_REGION
ENV NODE_ENV=production
RUN npm run build --workspace=@dtc/suman-hrvatska
# 3. Production runner stage
FROM node:22-alpine AS runner
WORKDIR /app/apps/suman-hrvatska
RUN apk add --no-cache libc6-compat curl
ENV NODE_ENV=production
ENV PORT=8002
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs
COPY --from=base --chown=nextjs:nodejs /app/node_modules /app/node_modules
COPY --from=base --chown=nextjs:nodejs /app/package.json /app/package-lock.json /app/
COPY --from=builder --chown=nextjs:nodejs /app/apps/suman-hrvatska /app/apps/suman-hrvatska
USER nextjs
EXPOSE 8002
CMD ["npm", "run", "start"]

View File

@@ -1,7 +1,7 @@
/// <reference types="next" /> /// <reference types="next" />
/// <reference types="next/image-types/global" /> /// <reference types="next/image-types/global" />
import "./.next/dev/types/routes.d.ts"; import "./.next/types/routes.d.ts";
import "./.next/dev/types/root-params.d.ts"; import "./.next/types/root-params.d.ts";
// NOTE: This file should not be edited // NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information. // see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

38
docker-compose.local.yml Normal file
View File

@@ -0,0 +1,38 @@
name: suman-local
services:
postgres:
image: postgres:16-alpine
container_name: umbrella_postgres
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER:-suman_user}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-TvojaSigurnaLozinka123!}
POSTGRES_DB: ${POSTGRES_DB:-medusa-suman-doo}
ports:
- "5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-suman_user} -d ${POSTGRES_DB:-medusa-suman-doo}"]
interval: 10s
timeout: 5s
retries: 5
redis:
image: redis:7-alpine
container_name: umbrella-redis
restart: unless-stopped
ports:
- "6379:6379"
volumes:
- redisdata:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
volumes:
pgdata:
redisdata:

178
docker-compose.prod.yml Normal file
View File

@@ -0,0 +1,178 @@
name: suman-prod
services:
# ==========================================
# 1. PostgreSQL Baza Podataka
# ==========================================
postgres:
image: postgres:16-alpine
container_name: suman_prod_postgres
restart: always
environment:
POSTGRES_USER: ${POSTGRES_USER:-suman_prod_user}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-suman_prod_secure_pass_123}
POSTGRES_DB: ${POSTGRES_DB:-suman_prod_db}
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-suman_prod_user} -d ${POSTGRES_DB:-suman_prod_db}"]
interval: 10s
timeout: 5s
retries: 5
networks:
- suman_network
# ==========================================
# 2. Redis Cache & Queue
# ==========================================
redis:
image: redis:7-alpine
container_name: suman_prod_redis
restart: always
command: >
sh -c '
if [ -n "$$REDIS_PASSWORD" ]; then
redis-server --appendonly yes --requirepass "$$REDIS_PASSWORD"
else
redis-server --appendonly yes
fi
'
environment:
REDIS_PASSWORD: ${REDIS_PASSWORD:-}
volumes:
- redis_data:/data
healthcheck:
test: >
sh -c '
if [ -n "$$REDIS_PASSWORD" ]; then
redis-cli -a "$$REDIS_PASSWORD" ping
else
redis-cli ping
fi
'
interval: 10s
timeout: 5s
retries: 5
networks:
- suman_network
# ==========================================
# 3. Medusa v2 Backend (API & Admin)
# ==========================================
backend:
build:
context: .
dockerfile: apps/backend/Dockerfile
container_name: suman_prod_backend
restart: always
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
environment:
NODE_ENV: production
PORT: 9000
DATABASE_URL: postgres://${POSTGRES_USER:-suman_prod_user}:${POSTGRES_PASSWORD:-suman_prod_secure_pass_123}@postgres:5432/${POSTGRES_DB:-suman_prod_db}
REDIS_URL: redis://${REDIS_PASSWORD:+:${REDIS_PASSWORD}@}redis:6379
JWT_SECRET: ${JWT_SECRET:-suman_prod_super_secret_jwt_key_32_chars_min}
COOKIE_SECRET: ${COOKIE_SECRET:-suman_prod_super_secret_cookie_key_32_chars}
STORE_CORS: ${STORE_CORS:-http://localhost:8000,http://localhost:8002,https://suman.ba,https://suman.hr}
ADMIN_CORS: ${ADMIN_CORS:-http://localhost:9000,https://admin.suman.ba,https://suman.ba}
AUTH_CORS: ${AUTH_CORS:-http://localhost:9000,http://localhost:8000,http://localhost:8002,https://suman.ba,https://suman.hr}
MEDUSA_BACKEND_URL: ${MEDUSA_BACKEND_URL:-http://localhost:9000}
volumes:
- backend_uploads:/app/apps/backend/uploads
ports:
- "${BACKEND_PORT:-9000}:9000"
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:9000/health || exit 1"]
interval: 15s
timeout: 5s
retries: 5
start_period: 20s
networks:
- suman_network
# ==========================================
# 4. Storefront Bosna i Hercegovina (Next.js)
# ==========================================
storefront-bosna:
build:
context: .
dockerfile: apps/suman-bosna/Dockerfile
args:
NEXT_PUBLIC_MEDUSA_BACKEND_URL: ${MEDUSA_BACKEND_URL:-http://backend:9000}
NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY: ${MEDUSA_PUBLISHABLE_KEY_BA:-}
NEXT_PUBLIC_BASE_URL: ${STOREFRONT_BA_BASE_URL:-http://localhost:8000}
NEXT_PUBLIC_DEFAULT_REGION: ba
container_name: suman_prod_storefront_bosna
restart: always
depends_on:
backend:
condition: service_healthy
environment:
NODE_ENV: production
PORT: 8000
NEXT_PUBLIC_MEDUSA_BACKEND_URL: ${MEDUSA_BACKEND_URL:-http://backend:9000}
NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY: ${MEDUSA_PUBLISHABLE_KEY_BA:-}
NEXT_PUBLIC_BASE_URL: ${STOREFRONT_BA_BASE_URL:-http://localhost:8000}
NEXT_PUBLIC_DEFAULT_REGION: ba
ports:
- "${STOREFRONT_BA_PORT:-8000}:8000"
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8000/ || exit 1"]
interval: 15s
timeout: 5s
retries: 5
start_period: 15s
networks:
- suman_network
# ==========================================
# 5. Storefront Hrvatska (Next.js)
# ==========================================
storefront-hrvatska:
build:
context: .
dockerfile: apps/suman-hrvatska/Dockerfile
args:
NEXT_PUBLIC_MEDUSA_BACKEND_URL: ${MEDUSA_BACKEND_URL:-http://backend:9000}
NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY: ${MEDUSA_PUBLISHABLE_KEY_HR:-}
NEXT_PUBLIC_BASE_URL: ${STOREFRONT_HR_BASE_URL:-http://localhost:8002}
NEXT_PUBLIC_DEFAULT_REGION: hr
container_name: suman_prod_storefront_hrvatska
restart: always
depends_on:
backend:
condition: service_healthy
environment:
NODE_ENV: production
PORT: 8002
NEXT_PUBLIC_MEDUSA_BACKEND_URL: ${MEDUSA_BACKEND_URL:-http://backend:9000}
NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY: ${MEDUSA_PUBLISHABLE_KEY_HR:-}
NEXT_PUBLIC_BASE_URL: ${STOREFRONT_HR_BASE_URL:-http://localhost:8002}
NEXT_PUBLIC_DEFAULT_REGION: hr
ports:
- "${STOREFRONT_HR_PORT:-8002}:8002"
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8002/ || exit 1"]
interval: 15s
timeout: 5s
retries: 5
start_period: 15s
networks:
- suman_network
volumes:
postgres_data:
name: suman_prod_pgdata
redis_data:
name: suman_prod_redisdata
backend_uploads:
name: suman_prod_uploads
networks:
suman_network:
name: suman_prod_network
driver: bridge

View File

@@ -1,29 +1,178 @@
version: "3.8" name: suman-prod
services: services:
# ==========================================
# 1. PostgreSQL Baza Podataka
# ==========================================
postgres: postgres:
image: postgres:16-alpine image: postgres:16-alpine
container_name: umbrella_postgres container_name: suman_prod_postgres
restart: unless-stopped restart: always
environment: environment:
POSTGRES_USER: ${POSTGRES_USER:-suman_user} POSTGRES_USER: ${POSTGRES_USER:-suman_prod_user}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-TvojaSigurnaLozinka123!} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-suman_prod_secure_pass_123}
POSTGRES_DB: ${POSTGRES_DB:-medusa-suman-doo} POSTGRES_DB: ${POSTGRES_DB:-suman_prod_db}
ports:
- "5432:5432"
volumes: volumes:
- pgdata:/var/lib/postgresql/data - postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-suman_prod_user} -d ${POSTGRES_DB:-suman_prod_db}"]
interval: 10s
timeout: 5s
retries: 5
networks:
- suman_network
# ==========================================
# 2. Redis Cache & Queue
# ==========================================
redis: redis:
image: redis:7-alpine image: redis:7-alpine
container_name: umbrella-redis container_name: suman_prod_redis
restart: unless-stopped restart: always
command: >
sh -c '
if [ -n "$$REDIS_PASSWORD" ]; then
redis-server --appendonly yes --requirepass "$$REDIS_PASSWORD"
else
redis-server --appendonly yes
fi
'
environment:
REDIS_PASSWORD: ${REDIS_PASSWORD:-}
volumes:
- redis_data:/data
healthcheck:
test: >
sh -c '
if [ -n "$$REDIS_PASSWORD" ]; then
redis-cli -a "$$REDIS_PASSWORD" ping
else
redis-cli ping
fi
'
interval: 10s
timeout: 5s
retries: 5
networks:
- suman_network
# ==========================================
# 3. Medusa v2 Backend (API & Admin)
# ==========================================
backend:
build:
context: .
dockerfile: apps/backend/Dockerfile
container_name: suman_prod_backend
restart: always
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
environment:
NODE_ENV: production
PORT: 9000
DATABASE_URL: postgres://${POSTGRES_USER:-suman_prod_user}:${POSTGRES_PASSWORD:-suman_prod_secure_pass_123}@postgres:5432/${POSTGRES_DB:-suman_prod_db}
REDIS_URL: redis://${REDIS_PASSWORD:+:${REDIS_PASSWORD}@}redis:6379
JWT_SECRET: ${JWT_SECRET:-suman_prod_super_secret_jwt_key_32_chars_min}
COOKIE_SECRET: ${COOKIE_SECRET:-suman_prod_super_secret_cookie_key_32_chars}
STORE_CORS: ${STORE_CORS:-http://localhost:8000,http://localhost:8002,https://suman.ba,https://suman.hr}
ADMIN_CORS: ${ADMIN_CORS:-http://localhost:9000,https://admin.suman.ba,https://suman.ba}
AUTH_CORS: ${AUTH_CORS:-http://localhost:9000,http://localhost:8000,http://localhost:8002,https://suman.ba,https://suman.hr}
MEDUSA_BACKEND_URL: ${MEDUSA_BACKEND_URL:-http://localhost:9000}
volumes:
- backend_uploads:/app/apps/backend/uploads
ports: ports:
- "6379:6379" - "${BACKEND_PORT:-9000}:9000"
volumes: healthcheck:
- redisdata:/data test: ["CMD-SHELL", "curl -f http://localhost:9000/health || exit 1"]
interval: 15s
timeout: 5s
retries: 5
start_period: 20s
networks:
- suman_network
# ==========================================
# 4. Storefront Bosna i Hercegovina (Next.js)
# ==========================================
storefront-bosna:
build:
context: .
dockerfile: apps/suman-bosna/Dockerfile
args:
NEXT_PUBLIC_MEDUSA_BACKEND_URL: ${MEDUSA_BACKEND_URL:-http://backend:9000}
NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY: ${MEDUSA_PUBLISHABLE_KEY_BA:-}
NEXT_PUBLIC_BASE_URL: ${STOREFRONT_BA_BASE_URL:-http://localhost:8000}
NEXT_PUBLIC_DEFAULT_REGION: ba
container_name: suman_prod_storefront_bosna
restart: always
depends_on:
backend:
condition: service_healthy
environment:
NODE_ENV: production
PORT: 8000
NEXT_PUBLIC_MEDUSA_BACKEND_URL: ${MEDUSA_BACKEND_URL:-http://backend:9000}
NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY: ${MEDUSA_PUBLISHABLE_KEY_BA:-}
NEXT_PUBLIC_BASE_URL: ${STOREFRONT_BA_BASE_URL:-http://localhost:8000}
NEXT_PUBLIC_DEFAULT_REGION: ba
ports:
- "${STOREFRONT_BA_PORT:-8000}:8000"
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8000/ || exit 1"]
interval: 15s
timeout: 5s
retries: 5
start_period: 15s
networks:
- suman_network
# ==========================================
# 5. Storefront Hrvatska (Next.js)
# ==========================================
storefront-hrvatska:
build:
context: .
dockerfile: apps/suman-hrvatska/Dockerfile
args:
NEXT_PUBLIC_MEDUSA_BACKEND_URL: ${MEDUSA_BACKEND_URL:-http://backend:9000}
NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY: ${MEDUSA_PUBLISHABLE_KEY_HR:-}
NEXT_PUBLIC_BASE_URL: ${STOREFRONT_HR_BASE_URL:-http://localhost:8002}
NEXT_PUBLIC_DEFAULT_REGION: hr
container_name: suman_prod_storefront_hrvatska
restart: always
depends_on:
backend:
condition: service_healthy
environment:
NODE_ENV: production
PORT: 8002
NEXT_PUBLIC_MEDUSA_BACKEND_URL: ${MEDUSA_BACKEND_URL:-http://backend:9000}
NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY: ${MEDUSA_PUBLISHABLE_KEY_HR:-}
NEXT_PUBLIC_BASE_URL: ${STOREFRONT_HR_BASE_URL:-http://localhost:8002}
NEXT_PUBLIC_DEFAULT_REGION: hr
ports:
- "${STOREFRONT_HR_PORT:-8002}:8002"
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8002/ || exit 1"]
interval: 15s
timeout: 5s
retries: 5
start_period: 15s
networks:
- suman_network
volumes: volumes:
pgdata: postgres_data:
redisdata: name: suman_prod_pgdata
redis_data:
name: suman_prod_redisdata
backend_uploads:
name: suman_prod_uploads
networks:
suman_network:
name: suman_prod_network
driver: bridge

View File

@@ -15,7 +15,12 @@
"backend:dev": "turbo dev --filter=@dtc/backend", "backend:dev": "turbo dev --filter=@dtc/backend",
"storefront:dev": "turbo dev --filter=@dtc/suman-bosna", "storefront:dev": "turbo dev --filter=@dtc/suman-bosna",
"suman-bosna:dev": "turbo dev --filter=@dtc/suman-bosna", "suman-bosna:dev": "turbo dev --filter=@dtc/suman-bosna",
"suman-hrvatska:dev": "turbo dev --filter=@dtc/suman-hrvatska" "suman-hrvatska:dev": "turbo dev --filter=@dtc/suman-hrvatska",
"docker:local": "docker compose -f docker-compose.local.yml up -d",
"docker:local:down": "docker compose -f docker-compose.local.yml down",
"docker:prod:build": "docker compose build",
"docker:prod:up": "docker compose up -d",
"docker:prod:down": "docker compose down"
}, },
"pnpm": { "pnpm": {
"overrides": { "overrides": {