Skip to content

Instantly share code, notes, and snippets.

@derekr
Created September 14, 2023 17:10
Show Gist options
  • Save derekr/15edb8e31b751b26c56a37c6ff0d2c4b to your computer and use it in GitHub Desktop.
Save derekr/15edb8e31b751b26c56a37c6ff0d2c4b to your computer and use it in GitHub Desktop.
# api service
# I typically start with a clean base image that doesn't have any
# transient dependencies, but in your case you'd still want pnpm etc
# but i don't want any unecessary node_modules or build artifacts
# that aren't helpful at runtime so a clean filesystem is helpful.
FROM node:18-alpine as api
WORKDIR /app
# Then I only want runtime files for the specific target.
# If a monorepo I may need to copy other resources, and maybe
# a root node_modules or something.
COPY --from=build /app/apps/api ./apps/api
COPY --from=build /app/node_modules ./node_modules
ARG VERSION
ENV VERSION $VERSION
RUN echo $VERSION > VERSION
ENV HOST 0.0.0.0
ENV PORT 4000
EXPOSE 4000
WORKDIR /app/apps/api
CMD ["pnpm", "start"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment