Skip to content

Commit

Permalink
modified dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
xamey committed Nov 18, 2024
1 parent b811924 commit 93a4c5c
Showing 1 changed file with 1 addition and 27 deletions.
28 changes: 1 addition & 27 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,6 @@
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1 AS base
WORKDIR /usr/src/app

# install dependencies into temp directory
# this will cache them and speed up future builds
FROM base AS install
RUN mkdir -p /temp/dev
COPY package.json bun.lockb /temp/dev/
RUN cd /temp/dev && bun install

# install with --production (exclude devDependencies)
RUN mkdir -p /temp/prod
COPY package.json bun.lockb /temp/prod/
RUN cd /temp/prod && bun install --production

# copy node_modules from temp directory
# then copy all (non-ignored) project files into the image
FROM base AS prerelease
COPY --from=install /temp/dev/node_modules node_modules
COPY . .

# copy production dependencies and source code into final image
FROM base AS release
COPY --from=install /temp/prod/node_modules node_modules
COPY --from=prerelease /usr/src/app/index.ts .
COPY --from=prerelease /usr/src/app/package.json .

# Run bun:migration:drop if DB_DROP is set
RUN if [ "$DB_DROP" = "true" ]; then bun run migration:drop; fi
Expand All @@ -40,6 +15,5 @@ RUN if [ "$DB_SEED" = "true" ]; then bun run migration:seed; fi
RUN if [ "$DB_DROP" = "true" ]; then bun run migration:drop; fi

# run the app
USER bun
EXPOSE 3000/tcp
ENTRYPOINT [ "bun", "run", "index.ts" ]
CMD [ "bun", "dev" ]

0 comments on commit 93a4c5c

Please sign in to comment.