Dockerfile 1.2 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. # 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/index.ts .
  27. COPY --from=prerelease /usr/src/app/package.json .
  28. COPY --from=prerelease /usr/src/app/academia.sqlite3 .
  29. # run the app
  30. USER bun
  31. EXPOSE 3000/tcp
  32. ENTRYPOINT [ "bun", "run", "index.ts" ]