Skip to content

Commit

Permalink
feat: WIP - use known base image and autogenerate prisma client
Browse files Browse the repository at this point in the history
  • Loading branch information
okjodom committed Nov 7, 2024
1 parent 05c902c commit 4842636
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions apps/swap/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
FROM oven/bun:latest AS development
FROM ubuntu:24.04 AS development

# Install Node.js and other dependencies
RUN apt-get update && apt-get install -y curl gnupg unzip
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
RUN apt-get install -y nodejs

# Install Bun
RUN curl -fsSL https://bun.sh/install | bash
ENV PATH="/root/.bun/bin:${PATH}"

WORKDIR /usr/src/app

COPY package.json ./
COPY bun.lockb ./
COPY tsconfig.json tsconfig.json
COPY nest-cli.json nest-cli.json
COPY apps/swap/prisma/client ./prisma/client

# FIXME: This hack allows prisma to work with oven/bun
# Ref: https://github.com/oven-sh/bun/issues/5320#issuecomment-1730927088
COPY --from=node:20 /usr/local/bin/node /usr/local/bin/node

COPY apps/swap apps/swap
COPY libs libs
COPY proto proto

# Generate Prisma client
RUN bunx prisma generate --schema apps/swap/prisma/schema.prisma

RUN bun install
RUN bun build:swap

FROM oven/bun:latest AS production
FROM ubuntu:24.04 AS production

# Install Node.js and other dependencies
RUN apt-get update && apt-get install -y curl gnupg unzip
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
RUN apt-get install -y nodejs

# Install Bun
RUN curl -fsSL https://bun.sh/install | bash
ENV PATH="/root/.bun/bin:${PATH}"

ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}
Expand All @@ -33,6 +49,6 @@ RUN bun install --production

COPY --from=development /usr/src/app/dist ./dist
COPY --from=development /usr/src/app/proto ./proto
COPY --from=development /usr/src/app/prisma ./prisma
COPY --from=development /usr/src/app/apps/swap/prisma ./prisma

CMD ["sh", "-c", "bun run prisma migrate deploy && bun run dist/apps/swap/main.js"]
CMD ["sh", "-c", "bun run prisma migrate deploy --schema prisma/schema.prisma && bun run dist/apps/swap/main.js"]

0 comments on commit 4842636

Please sign in to comment.