diff --git a/Dockerfile b/Dockerfile index a8c31c1..ac68216 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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" ] \ No newline at end of file