This repository has been archived by the owner on Dec 2, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update the docker file to use the node bun image as base
- Loading branch information
1 parent
39e16e7
commit ac56114
Showing
1 changed file
with
21 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" ] |