Skip to content
Open
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
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
node_modules
npm-debug.log
.git
.gitignore
.env
.env.local
*.md
tests/
k6/
coverage
.nyc_output
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Stage 1
FROM node:20-slim AS deps
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit-dev --no-audit --no-fund || npm install --omit-dev --no-audit --no-fund

# Stage 2
FROM node:20-slim AS production
RUN apt-get update && apt-get install -y --no-install-recommends dumb-init && rm -rf /var/lib/apt/lists/*
RUN groupadd -r appuser && useradd -r -g appuser appuser
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NODE_ENV=production
ENV PORT=3000
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 CMD node -e "require(http).get(http://localhost:3000/health,r=>process.exit(r.statusCode===200?0:1))"
USER appuser
EXPOSE 3000
ENTRYPOINT ["dumb-init","--"]
CMD ["node","index.js"]
25 changes: 25 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: 3.8
services:
app:
build:
context: .
dockerfile: Dockerfile
ports:
- "3000:3000"
environment:
- NODE_ENV=production
- REDIS_URL=redis://redis:6379
depends_on:
redis:
condition: service_healthy
restart: unless-stopped
redis:
image: redis:7-alpine
ports:
- "6379:6379"
healthcheck:
test: ["CMD","redis-cli","ping"]
interval: 10s
timeout: 3s
retries: 5
restart: unless-stopped