Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

Dockerfile 2.3 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
  1. # syntax=docker/dockerfile:1
  2. # read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
  3. # you will also find guides on how best to write your Dockerfile
  4. ARG INCLUDE_DB=false
  5. # stage that install the dependencies
  6. FROM node:20 AS builder-production
  7. WORKDIR /app
  8. COPY --link --chown=1000 package-lock.json package.json ./
  9. RUN --mount=type=cache,target=/app/.npm \
  10. npm set cache /app/.npm && \
  11. npm ci --omit=dev
  12. FROM builder-production AS builder
  13. ARG APP_BASE=
  14. ARG PUBLIC_APP_COLOR=blue
  15. ENV BODY_SIZE_LIMIT=15728640
  16. RUN --mount=type=cache,target=/app/.npm \
  17. npm set cache /app/.npm && \
  18. npm ci
  19. COPY --link --chown=1000 . .
  20. RUN npm run build
  21. # mongo image
  22. FROM mongo:latest AS mongo
  23. # image to be used if INCLUDE_DB is false
  24. FROM node:20-slim AS local_db_false
  25. # image to be used if INCLUDE_DB is true
  26. FROM node:20-slim AS local_db_true
  27. RUN apt-get update
  28. RUN apt-get install gnupg curl -y
  29. # copy mongo from the other stage
  30. COPY --from=mongo /usr/bin/mongo* /usr/bin/
  31. ENV MONGODB_URL=mongodb://localhost:27017
  32. RUN mkdir -p /data/db
  33. RUN chown -R 1000:1000 /data/db
  34. # final image
  35. FROM local_db_${INCLUDE_DB} AS final
  36. # build arg to determine if the database should be included
  37. ARG INCLUDE_DB=false
  38. ENV INCLUDE_DB=${INCLUDE_DB}
  39. # svelte requires APP_BASE at build time so it must be passed as a build arg
  40. ARG APP_BASE=
  41. # tailwind requires the primary theme to be known at build time so it must be passed as a build arg
  42. ARG PUBLIC_APP_COLOR=blue
  43. ENV BODY_SIZE_LIMIT=15728640
  44. # install dotenv-cli
  45. RUN npm install -g dotenv-cli
  46. # switch to a user that works for spaces
  47. RUN userdel -r node
  48. RUN useradd -m -u 1000 user
  49. USER user
  50. ENV HOME=/home/user \
  51. PATH=/home/user/.local/bin:$PATH
  52. WORKDIR /app
  53. # add a .env.local if the user doesn't bind a volume to it
  54. RUN touch /app/.env.local
  55. # get the default config, the entrypoint script and the server script
  56. COPY --chown=1000 package.json /app/package.json
  57. COPY --chown=1000 .env /app/.env
  58. COPY --chown=1000 entrypoint.sh /app/entrypoint.sh
  59. COPY --chown=1000 gcp-*.json /app/
  60. #import the build & dependencies
  61. COPY --from=builder --chown=1000 /app/build /app/build
  62. COPY --from=builder --chown=1000 /app/node_modules /app/node_modules
  63. RUN npx playwright install
  64. USER root
  65. RUN npx playwright install-deps
  66. USER user
  67. RUN chmod +x /app/entrypoint.sh
  68. CMD ["/bin/bash", "-c", "/app/entrypoint.sh"]
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...