feat: add support for node docker images

This commit is contained in:
Xylight committed 2024-08-02 15:56:45 -07:00
1 parent 95676518dd
commit 0cce117531
8 files changed
+24 -35

No files matched your search

+16 -10
View File
@@ -1,34 +1,40 @@
# Base stage for both Bun and Node.js
FROM alpine:3.14 as base
FROM alpine:3.14 AS base
WORKDIR /app
COPY package.json .
# Bun stage
FROM oven/bun:1 as bun-builder
FROM oven/bun:1 AS bun-builder
USER bun
WORKDIR /app
COPY --from=base /app/package.json .
COPY . .
RUN bun install
RUN bun run build
RUN ADAPTER=bun bun run build
# Node.js stage
FROM node:18-alpine as node-builder
FROM node:20-alpine AS node-builder
WORKDIR /app
COPY --from=base /app/package.json .
COPY . .
RUN npm install
RUN npm run build
RUN npm install --no-lockfile
RUN ADAPTER=node npm run build
# Final Bun image
FROM oven/bun:1-alpine AS bun
WORKDIR /app
COPY --from=bun-builder /app .
COPY --from=bun-builder /app/build /app/build
COPY --from=bun-builder /app/node_modules /app/node_modules
EXPOSE 3000
CMD ["bun", "/app/build/index.js"]
USER bun
CMD ["bun", "build/index.js"]
# Final Node.js image
FROM node:20-alpine AS node
USER node
WORKDIR /app
COPY --from=node-builder /app .
COPY --from=node-builder /app/build /app/build
COPY --from=node-builder /app/node_modules /app/node_modules
COPY --from=node-builder /app/package.json /app/package.json
EXPOSE 3000
CMD ["node", "/app/build/index.js"]
CMD ["node", "build/index.js"]