File size: 1,161 Bytes
e933369
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# =========================
# Builder
# =========================
FROM node:22-alpine AS builder

RUN apk add --no-cache python3 make g++

WORKDIR /app

COPY package.json yarn.lock ./

RUN yarn install --frozen-lockfile

# =========================
# Runtime
# =========================
FROM node:22-alpine

LABEL org.opencontainers.image.title="Nodejs JSON API Server"
LABEL org.opencontainers.image.description="Nodejs JSON API with SQLite, Redis caching, rate limiting, and admin endpoints"
LABEL org.opencontainers.image.source="https://github.com/anomalyco/Nodejs-JSON-API-Server"
LABEL org.opencontainers.image.licenses="MIT"

WORKDIR /app

# Create non-root user
RUN addgroup -S app && adduser -S app -G app

# Copy dependencies
COPY --from=builder /app/node_modules ./node_modules

# Copy application source
COPY --chown=app:app . .

# Prepare runtime directories
RUN mkdir -p /app/storage \
    && chmod +x /app/docker-entrypoint.sh \
    && chown -R app:app /app/storage

USER app

ENV NODE_ENV=production \
    DB_PATH=/app/storage/data.db

EXPOSE 3000

VOLUME ["/app/storage"]

ENTRYPOINT ["/app/docker-entrypoint.sh"]

CMD ["node", "bin/start.js"]