Skip to content

Instantly share code, notes, and snippets.

@antoniopresto
Created January 23, 2025 23:44
Show Gist options
  • Save antoniopresto/4dfcd89e2fdaa8cea49bcad40e8e5eb6 to your computer and use it in GitHub Desktop.
Save antoniopresto/4dfcd89e2fdaa8cea49bcad40e8e5eb6 to your computer and use it in GitHub Desktop.
PNPM with Bun.js and Docker

Here i'm creating a simple sh script to redirect the node command to bun.

#!/usr/bin/env sh
# pnpm requires node, so we use this script as an alias on docker;
if [ "$1" = "--version" ]; then
  echo "v20.11.1"
else
  command bun "$@"
fi
FROM oven/bun:1-alpine as base

WORKDIR $APP_PATH
COPY . .

ENV PNPM_VERSION=8.15.6
ENV PNPM_HOME=/root/.local/share/pnpm
ENV PATH=$PATH:$PNPM_HOME

# ⛳️ ./node is just a sh script redirecting `node` commands to `bun`
RUN cp node /bin/node && chmod +x /bin/node

RUN apk add --no-cache curl
RUN curl -fsSL "https://github.com/pnpm/pnpm/releases/download/v${PNPM_VERSION}/pnpm-linuxstatic-x64" -o /bin/pnpm;  \
    chmod +x /bin/pnpm && \
    apk del curl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment