File tree Expand file tree Collapse file tree 2 files changed +57
-1
lines changed Expand file tree Collapse file tree 2 files changed +57
-1
lines changed Original file line number Diff line number Diff line change 1+
2+ # Use a base image for building
3+ FROM node:18-slim AS base
4+
5+ # Install git
6+ RUN apt-get update && apt-get install -y git
7+
8+ # Clone the repository and navigate to the sveltekit folder
9+ WORKDIR /app
10+ RUN git clone -b sveltekit https://github.com/huggingface/transformers.js-examples .
11+
12+ # Set the working directory to the sveltekit folder
13+ WORKDIR /app/sveltekit
14+
15+ # Install dependencies only when needed
16+ FROM base AS deps
17+
18+ # Install dependencies based on the preferred package manager
19+ RUN \
20+ if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
21+ elif [ -f package-lock.json ]; then npm ci; \
22+ elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
23+ else echo "Lockfile not found." && exit 1; \
24+ fi
25+
26+ # Rebuild the source code only when needed
27+ FROM base AS builder
28+ WORKDIR /app/sveltekit
29+ COPY --from=deps /app/sveltekit/node_modules ./node_modules
30+ COPY . .
31+
32+ RUN \
33+ if [ -f yarn.lock ]; then yarn run build; \
34+ elif [ -f package-lock.json ]; then npm run build; \
35+ elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
36+ else echo "Lockfile not found." && exit 1; \
37+ fi
38+
39+ # Production image, copy all the files and run sveltekit
40+ FROM base AS runner
41+ WORKDIR /app/sveltekit
42+
43+ ENV NODE_ENV=production
44+
45+ RUN addgroup --system --gid 1001 nodejs
46+ RUN adduser --system --uid 1001 sveltekit
47+
48+ COPY --from=builder --chown=nextjs:nodejs /app/sveltekit .
49+
50+ USER sveltekit
51+
52+ EXPOSE 3000
53+
54+ ENV PORT=3000
55+ ENV HOSTNAME="0.0.0.0"
56+ CMD ["node" , "build" ]
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ colorFrom: yellow
55colorTo : red
66sdk : docker
77pinned : false
8- app_port : 4173
8+ app_port : 3000
99---
1010
1111# sveltekit
You can’t perform that action at this time.
0 commit comments