Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save matthewlilley/08b1546568abffc12b1e917a25f61879 to your computer and use it in GitHub Desktop.
Save matthewlilley/08b1546568abffc12b1e917a25f61879 to your computer and use it in GitHub Desktop.
FROM node:18-alpine
# Install git and pnpm
RUN apk add --no-cache git libc6-compat grep
RUN npm install -g pnpm@7.18.2 turbo@1.7.0
# Do ARG stuff
ARG SCRIPT_PATH="./"
ENV SCRIPT_PATH ${SCRIPT_PATH}
ARG TURBO_TOKEN
ARG TURBO_TEAM
# Copy the repo into the build context
WORKDIR /workdir/repo
COPY . .
# Prune unneeded packages
# Need to pull the package name from the path
RUN turbo prune --out-dir=../pruned --scope=$(pnpm list --depth -1 --parseable --long --filter "./$SCRIPT_PATH" | grep -oP '(?<=\:)(.*(?=@))')
WORKDIR /workdir/pruned
# Can delete the previous workdir, won't be needed anymore
RUN rm -rf /workdir/repo
RUN HUSKY=0 pnpm install
RUN pnpm exec turbo run build --filter="./$SCRIPT_PATH"
# Delete store path since it's now unneeded, to reduce image size
RUN rm -rf $(pnpm store path)
EXPOSE 8080/tcp
CMD pnpm exec turbo run start --only --filter="./$SCRIPT_PATH"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment