Skip to content

Commit

Permalink
Refactor Dockerfile to use Node.js base image and pnpm for package ma…
Browse files Browse the repository at this point in the history
…nagement. Removed Bun references, updated installation commands, and ensured pnpm is available in the final image. This change streamlines the build process and aligns with the project's current dependency management strategy.
  • Loading branch information
tinypell3ts committed Jan 16, 2025
1 parent 54bfe0c commit fa6e907
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,39 +1,43 @@
# syntax = docker/dockerfile:1

# Adjust BUN_VERSION as desired
ARG BUN_VERSION=1.1.18
FROM oven/bun:${BUN_VERSION}-slim as base
# Use a Node.js base image
FROM node:23-slim as base

LABEL fly_launch_runtime="Bun"
LABEL fly_launch_runtime="Node.js"

# Bun app lives here
# Node.js app lives here
WORKDIR /app

# Set production environment
ENV NODE_ENV="production"


# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build node modules
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential pkg-config python-is-python3

# Install node modules
COPY bun.lockb package.json ./
RUN bun install --ci
# Install pnpm
RUN npm install -g pnpm

# Install node modules using pnpm
COPY pnpm-lock.yaml ./
COPY package.json ./
RUN pnpm install --frozen-lockfile

# Copy application code
COPY . .


# Final stage for app image
FROM base

# Ensure pnpm is available in the final image
RUN npm install -g pnpm

# Copy built application
COPY --from=build /app /app

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD [ "bun", "run", "start" ]
CMD [ "pnpm", "start" ]

0 comments on commit fa6e907

Please sign in to comment.