Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
feat: update the docker file to use the node bun image as base
Browse files Browse the repository at this point in the history
  • Loading branch information
taciturnaxolotl committed Jul 8, 2024
1 parent 39e16e7 commit ac56114
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1.1.18 as base
WORKDIR /usr/src/app
# Set Bun and Node version
ARG BUN_VERSION=1.1.18
ARG NODE_VERSION=20.12.2
FROM imbios/bun-node:${BUN_VERSION}-${NODE_VERSION}-slim

# install with --production (exclude devDependencies)
FROM base AS build
RUN mkdir -p /temp/prod
COPY . /temp/prod/
RUN cd /temp/prod && bun install --production --frozen-lockfile
RUN cd /temp/prod && bun i -g prisma
RUN cd /temp/prod && bunx prisma generate
RUN cd /temp/prod && bunx prisma migrate deploy
# Set production environment
ENV NODE_ENV="production"

# copy production build to release image
FROM base AS release
COPY --from=build /temp/prod/ .
RUN ls -la && ls -la node_modules/.prisma
RUN chown -R bun:bun .
# Bun app lives here
WORKDIR /app

# run the app
USER bun
EXPOSE 3000/tcp
ENTRYPOINT [ "bun", "run", "src/index.ts" ]
# Copy app files to app directory
COPY . .

# Install node modules
RUN bun install

# Generate Prisma Client
RUN bunx prisma generate
RUN bunx prisma db push

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD [ "bun", "run", "index.ts" ]

0 comments on commit ac56114

Please sign in to comment.