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.2 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
  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. RUN --mount=type=cache,target=/app/.npm \
  16. npm set cache /app/.npm && \
  17. npm ci
  18. COPY --link --chown=1000 . .
  19. RUN npm run build
  20. # mongo image
  21. FROM mongo:latest as mongo
  22. # image to be used if INCLUDE_DB is false
  23. FROM node:20-slim as local_db_false
  24. # image to be used if INCLUDE_DB is true
  25. FROM node:20-slim as local_db_true
  26. RUN apt-get update
  27. RUN apt-get install gnupg curl -y
  28. # copy mongo from the other stage
  29. COPY --from=mongo /usr/bin/mongo* /usr/bin/
  30. ENV MONGODB_URL=mongodb://localhost:27017
  31. RUN mkdir -p /data/db
  32. RUN chown -R 1000:1000 /data/db
  33. # final image
  34. FROM local_db_${INCLUDE_DB} as final
  35. # build arg to determine if the database should be included
  36. ARG INCLUDE_DB=false
  37. ENV INCLUDE_DB=${INCLUDE_DB}
  38. # svelte requires APP_BASE at build time so it must be passed as a build arg
  39. ARG APP_BASE=
  40. # tailwind requires the primary theme to be known at build time so it must be passed as a build arg
  41. ARG PUBLIC_APP_COLOR=blue
  42. # install dotenv-cli
  43. RUN npm install -g dotenv-cli
  44. # switch to a user that works for spaces
  45. RUN userdel -r node
  46. RUN useradd -m -u 1000 user
  47. USER user
  48. ENV HOME=/home/user \
  49. PATH=/home/user/.local/bin:$PATH
  50. WORKDIR /app
  51. # add a .env.local if the user doesn't bind a volume to it
  52. RUN touch /app/.env.local
  53. # get the default config, the entrypoint script and the server script
  54. COPY --chown=1000 package.json /app/package.json
  55. COPY --chown=1000 .env /app/.env
  56. COPY --chown=1000 entrypoint.sh /app/entrypoint.sh
  57. COPY --chown=1000 gcp-*.json /app/
  58. #import the build & dependencies
  59. COPY --from=builder --chown=1000 /app/build /app/build
  60. COPY --from=builder --chown=1000 /app/node_modules /app/node_modules
  61. RUN chmod +x /app/entrypoint.sh
  62. 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...