Skip to content

Instantly share code, notes, and snippets.

@antoniopresto
Created January 23, 2025 23:44
Show Gist options
  • Select an option

  • Save antoniopresto/4dfcd89e2fdaa8cea49bcad40e8e5eb6 to your computer and use it in GitHub Desktop.

Select an option

Save antoniopresto/4dfcd89e2fdaa8cea49bcad40e8e5eb6 to your computer and use it in GitHub Desktop.

Revisions

  1. antoniopresto created this gist Jan 23, 2025.
    31 changes: 31 additions & 0 deletions pnpm_bun_docker.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    Here i'm creating a simple sh script to redirect the `node` command to `bun`.

    ```sh
    #!/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
    ```


    ```dockerfile
    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;
    ```