Dockerfile 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # docker pull oven/bun:1.3.8-debian
  2. FROM oven/bun:1.3.8-debian AS base
  3. WORKDIR /usr/src/app
  4. # install dependencies into temp directory
  5. # this will cache them and speed up future builds
  6. FROM base AS install
  7. RUN mkdir -p /temp/dev
  8. COPY package.json bun.lock /temp/dev/
  9. RUN cd /temp/dev && bun install --frozen-lockfile
  10. # install with --production (exclude devDependencies)
  11. RUN mkdir -p /temp/prod
  12. COPY package.json bun.lock /temp/prod/
  13. RUN cd /temp/prod && bun install --frozen-lockfile --production
  14. # copy node_modules from temp directory
  15. # then copy all (non-ignored) project files into the image
  16. FROM base AS prerelease
  17. COPY --from=install /temp/dev/node_modules node_modules
  18. COPY . .
  19. # [optional] tests & build
  20. ENV NODE_ENV=production
  21. ENV PORT=3000
  22. # RUN bun test
  23. # RUN bun run build # Removido: não há script build, e Bun executa TS diretamente
  24. # copy production dependencies and source code into final image
  25. FROM base AS release
  26. COPY --from=install /temp/prod/node_modules node_modules
  27. COPY --from=prerelease /usr/src/app/* .
  28. # run the app
  29. USER bun
  30. EXPOSE 3000/tcp
  31. ENTRYPOINT [ "bun", "run", "index.ts" ]