Dockerfile 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. # RUN bun test
  22. # RUN bun run build # Removido: não há script build, e Bun executa TS diretamente
  23. # copy production dependencies and source code into final image
  24. FROM base AS release
  25. COPY --from=install /temp/prod/node_modules node_modules
  26. COPY --from=prerelease /usr/src/app/* .
  27. # run the app
  28. USER bun
  29. EXPOSE 3000/tcp
  30. ENTRYPOINT [ "bun", "run", "api.ts" ]