trips) adding initial commit
This commit is contained in:
45
Dockerfile
Normal file
45
Dockerfile
Normal file
@@ -0,0 +1,45 @@
|
||||
# ── Build stage ────────────────────────────────────────────────────────────────
|
||||
FROM oven/bun:1 AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy dependency manifests first for better layer caching
|
||||
COPY package.json bun.lock ./
|
||||
|
||||
# Install all deps (including devDependencies needed for the build).
|
||||
# better-sqlite3 is a native module — it must be compiled here on Linux,
|
||||
# not copied from a macOS node_modules.
|
||||
RUN bun install --frozen-lockfile
|
||||
|
||||
# Copy source and build
|
||||
COPY . .
|
||||
RUN bun run build
|
||||
|
||||
# Prune to production-only deps, recompiling native modules for Linux
|
||||
RUN bun install --frozen-lockfile --production
|
||||
|
||||
# ── Runtime stage ───────────────────────────────────────────────────────────────
|
||||
FROM node:22-alpine AS runtime
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Create a non-root user to run the app
|
||||
RUN addgroup -S trips && adduser -S trips -G trips
|
||||
|
||||
# Copy the built app and production node_modules from the builder
|
||||
COPY --from=builder /app/build ./build
|
||||
COPY --from=builder /app/node_modules ./node_modules
|
||||
COPY --from=builder /app/package.json ./package.json
|
||||
|
||||
# Directory for the SQLite database (mount a volume here)
|
||||
RUN mkdir -p /data && chown trips:trips /data
|
||||
|
||||
USER trips
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV DATABASE_URL=file:/data/trips.db
|
||||
ENV PORT=3000
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["node", "build"]
|
||||
Reference in New Issue
Block a user