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