Spaces:
Build error
Build error
Commit
•
74532d2
1
Parent(s):
9658717
Add incremental build + multi layer docker for size reduction (#259)
Browse files* Add incremental build + multi layer docker for size reduction
* Update .dockerignore
* fix cache miss
* pr comment .gitignore
---------
Co-authored-by: Eliott C <coyotte508@gmail.com>
- .dockerignore +8 -0
- Dockerfile +21 -8
.dockerignore
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Dockerfile
|
2 |
+
.vscode/
|
3 |
+
.idea
|
4 |
+
.gitignore
|
5 |
+
LICENSE
|
6 |
+
README.md
|
7 |
+
node_modules/
|
8 |
+
.svelte-kit/
|
Dockerfile
CHANGED
@@ -1,18 +1,31 @@
|
|
1 |
# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
2 |
# you will also find guides on how best to write your Dockerfile
|
3 |
-
|
4 |
-
FROM node:19
|
5 |
-
|
6 |
-
RUN npm install -g pm2
|
7 |
|
8 |
WORKDIR /app
|
9 |
|
10 |
-
COPY --link --chown=1000 package.json package
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
RUN npm
|
|
|
|
|
13 |
|
14 |
COPY --link --chown=1000 . .
|
15 |
|
16 |
-
RUN --mount=type=secret,id=DOTENV_LOCAL,dst=.env.local
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
CMD pm2 start build/index.js -i $CPU_CORES --no-daemon
|
|
|
1 |
# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
2 |
# you will also find guides on how best to write your Dockerfile
|
3 |
+
FROM node:19 as builder-production
|
|
|
|
|
|
|
4 |
|
5 |
WORKDIR /app
|
6 |
|
7 |
+
COPY --link --chown=1000 package-lock.json package.json ./
|
8 |
+
RUN --mount=type=cache,target=/app/.npm \
|
9 |
+
npm set cache /app/.npm && \
|
10 |
+
npm ci --omit=dev
|
11 |
+
|
12 |
+
FROM builder-production as builder
|
13 |
|
14 |
+
RUN --mount=type=cache,target=/app/.npm \
|
15 |
+
npm set cache /app/.npm && \
|
16 |
+
npm ci
|
17 |
|
18 |
COPY --link --chown=1000 . .
|
19 |
|
20 |
+
RUN --mount=type=secret,id=DOTENV_LOCAL,dst=.env.local \
|
21 |
+
npm run build
|
22 |
+
|
23 |
+
FROM node:19-slim
|
24 |
+
|
25 |
+
RUN npm install -g pm2
|
26 |
+
|
27 |
+
COPY --from=builder-production /app/node_modules /app/node_modules
|
28 |
+
COPY --link --chown=1000 package.json /app/package.json
|
29 |
+
COPY --from=builder /app/build /app/build
|
30 |
|
31 |
+
CMD pm2 start /app/build/index.js -i $CPU_CORES --no-daemon
|