diff --git a/Dockerfile b/Dockerfile index 37891d1a..ef8372c3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ -# use dumb-init to add graceful shutdown -FROM building5/dumb-init:1.2.1 as init +# use tini to add graceful shutdown +FROM debian:stable-slim as init +RUN apt-get -qq update \ + && apt-get -qq install -y tini # use the official Bun image # see all versions at https://hub.docker.com/r/oven/bun/tags @@ -9,7 +11,7 @@ WORKDIR /usr/src/app # use the official Node image until Bun fixes bug for static assets # install dependencies into temp directory # this will cache them and speed up future builds -FROM node:20.9.0-slim AS install +FROM node:lts-slim AS install WORKDIR /usr/src/app RUN mkdir -p /temp COPY package.json package-lock.json /temp/ @@ -17,25 +19,24 @@ RUN cd /temp && npm ci # copy node_modules from temp directory # then copy all (non-ignored) project files into the image -FROM base AS prerelease +FROM base AS build COPY --from=install /temp/node_modules node_modules COPY . . # build ENV NODE_ENV=production -RUN bun run build +RUN [ "bun", "run", "build" ] # copy production dependencies and source code into final image FROM base AS release -COPY --from=init /dumb-init /usr/local/bin/ -COPY --from=prerelease /usr/src/app/node_modules node_modules -COPY --from=prerelease /usr/src/app/build ./ -COPY --from=prerelease /usr/src/app/package.json ./ -# switch to nonroot user -USER bun +COPY --from=init /usr/bin/tini /usr/bin/ +COPY --from=build /usr/src/app/node_modules node_modules/ +COPY --from=build /usr/src/app/build ./ +COPY --from=build /usr/src/app/package.json ./ + EXPOSE 3000 # run the app -ENTRYPOINT [ "/usr/local/bin/dumb-init", "--" ] +ENTRYPOINT [ "tini", "--" ] CMD [ "bun", "run", "start" ] \ No newline at end of file