Skip to content

Commit 50a44cc

Browse files
authored
Merge pull request #68 from browserbase/kj/docker
[Fix]: Docker deployment
2 parents 1077d37 + 228f453 commit 50a44cc

File tree

1 file changed

+21
-24
lines changed

1 file changed

+21
-24
lines changed

browserbase/Dockerfile

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,43 @@
11
# Build stage
2-
FROM node:20-slim AS builder
2+
FROM node:18-alpine AS builder
33

4+
# Set the working directory
45
WORKDIR /app
56

6-
# Copy package files first for better layer caching
7-
COPY package.json package-lock.json ./
7+
# Copy package.json and package-lock.json
8+
COPY package*.json ./
89

9-
# Install all dependencies including dev dependencies for building
10-
# --ignore-scripts prevents the prepare script from running prematurely
11-
RUN npm ci --ignore-scripts
10+
# Copy TSConfig
11+
COPY tsconfig.json ./
1212

13-
# Copy all source files
13+
# Copy the source code first
1414
COPY . .
1515

16-
# Build the TypeScript source code manually instead of using the npm script
17-
RUN npx tsc && npx shx chmod +x dist/*.js 2>/dev/null || echo "No executable JS files found"
16+
# Install dependencies
17+
RUN npm install
18+
19+
# Build the TypeScript source code
20+
RUN npm run build
1821

19-
# Production stage
22+
# Create the final image from a smaller Node.js runtime
2023
FROM node:18-alpine
2124

2225
# Set the working directory
2326
WORKDIR /app
2427

25-
# Copy package files
26-
COPY package.json package-lock.json ./
27-
28-
# Install only production dependencies
29-
# --ignore-scripts prevents the prepare script from running
30-
RUN npm ci --omit=dev --ignore-scripts
31-
3228
# Copy built files from builder stage
3329
COPY --from=builder /app/dist /app/dist
3430
COPY --from=builder /app/cli.js /app/cli.js
3531
COPY --from=builder /app/index.js /app/index.js
3632
COPY --from=builder /app/index.d.ts /app/index.d.ts
3733
COPY --from=builder /app/config.d.ts /app/config.d.ts
34+
COPY --from=builder /app/package.json /app/package.json
35+
COPY --from=builder /app/package-lock.json /app/package-lock.json
36+
COPY --from=builder /app/node_modules /app/node_modules
3837

39-
# Define environment variables (will be provided by Smithery)
40-
ENV NODE_ENV=production
41-
42-
# Expose a default port (useful if deploying as a service)
43-
EXPOSE 8931
38+
# Set environment variables (to be configured at runtime)
39+
ENV BROWSERBASE_API_KEY=
40+
ENV BROWSERBASE_PROJECT_ID=
4441

45-
# Command to run the application
46-
CMD [ "node", "cli.js", "--port", "8931" ]
42+
# Command to run the application with absolute path
43+
ENTRYPOINT [ "node", "/app/cli.js" ]

0 commit comments

Comments
 (0)