Skip to content

Commit

Permalink
Reworked dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
xamey committed Nov 18, 2024
1 parent a5b9205 commit 35f8d8c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
48 changes: 30 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
# Use a base image with Bun installed
FROM oven/bun:1

# Set the working directory
WORKDIR /app

# Copy package.json and package-lock.json
COPY package.json ./

# Install dependencies
RUN bun install

# Copy the rest of the application code
# 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 --frozen-lockfile

# install with --production (exclude devDependencies)
RUN mkdir -p /temp/prod
COPY package.json bun.lockb /temp/prod/
RUN cd /temp/prod && bun install --frozen-lockfile --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 . .

# Expose the port that the app runs on
EXPOSE 3000
# 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 @@ -28,6 +39,7 @@ RUN if [ "$DB_SEED" = "true" ]; then bun run migration:seed; fi
# Run bun:migration:drop if DB_DROP is set
RUN if [ "$DB_DROP" = "true" ]; then bun run migration:drop; fi


# Command to run the application
CMD ["bun", "dev"]
# run the app
USER bun
EXPOSE 3000/tcp
ENTRYPOINT [ "bun", "run", "index.ts" ]
Binary file modified sqlite/demands.sqlite-shm
Binary file not shown.

0 comments on commit 35f8d8c

Please sign in to comment.