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
6 changes: 5 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ coverage
.git
.github
test
README.md
README.md
.env
.env.local
docker-compose.override.yml
.dockerignore
16 changes: 12 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Server
PORT=4000

# Redis
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASSWORD=
REDIS_URL=redis://redis:6379

# Database
DATABASE_URL=postgres://smartdrop:smartdrop@postgres:5432/smartdrop
# Runtime environment
# NODE_ENV: string enum (development, test, production). Default: development.
NODE_ENV=development
Expand Down Expand Up @@ -36,13 +47,10 @@ PRICE_STALE_THRESHOLD_MINUTES=5
PRICE_ANOMALY_THRESHOLD_PCT=20

# API key auth
# Generate with: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
ADMIN_API_KEY=

# LOG_LEVEL: string enum (debug, info, warn, error). Default: info.
LOG_LEVEL=info

# CORS
# Comma-separated list of allowed origins (no trailing slashes)
# Production: CORS_ALLOWED_ORIGINS=https://app.smartdrop.io,https://staging.smartdrop.io
CORS_ALLOWED_ORIGINS=http://localhost:3000,http://localhost:3001
CORS_ALLOWED_ORIGINS=http://localhost:4000,http://localhost:3001
26 changes: 24 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
FROM node:20-alpine
# --- Base & Development Stage ---
FROM node:20-alpine AS development
WORKDIR /app

# Instalar dependencias completas (incluye devDependencies para nodemon/hot-reload)
COPY package*.json ./
RUN npm install --legacy-peer-deps

# Copiar el código fuente
COPY . .

EXPOSE 4000
CMD ["npm", "run", "dev"]

# --- Builder Stage para Producción ---
FROM node:20-alpine AS builder
WORKDIR /app

COPY package*.json ./
RUN npm ci --omit=dev

COPY src ./src

EXPOSE 3000
# --- Production Stage ---
FROM node:20-alpine AS production
WORKDIR /app
ENV NODE_ENV=production

COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/src ./src
COPY package*.json ./

EXPOSE 4000
CMD ["node", "src/index.js"]
Loading