Skip to content

Commit

Permalink
fix docker image and reduce build time
Browse files Browse the repository at this point in the history
  • Loading branch information
HashWarlock committed Nov 30, 2024
1 parent d188824 commit 2a4607a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 68 deletions.
81 changes: 14 additions & 67 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,83 +1,30 @@
# Stage 1: Build dependencies in a temporary stage
FROM node:23.3.0 AS builder

# Install required global dependencies
RUN apt-get update && apt-get install -y \
python3 \
build-essential \
git \
curl \
sqlite3 && \
apt-get clean \
&& npm install -g pnpm@9.4.0
FROM node:23.3.0
RUN npm install -g pnpm@9.4.0

# Set working directory
# Set the working directory
WORKDIR /app

# Add configuration files and install dependencies
ADD pnpm-workspace.yaml /app/pnpm-workspace.yaml
ADD package.json /app/package.json
ADD .npmrc /app/.npmrc
ADD tsconfig.json /app/tsconfig.json
ADD pnpm-lock.yaml /app/pnpm-lock.yaml

# Install dependencies
RUN pnpm install
ADD turbo.json /app/turbo.json

# Copy source code
# Add the documentation
ADD docs /app/docs

# Add the rest of the application code
ADD agent /app/agent
ADD packages /app/packages

# Add the environment variables
ADD scripts /app/scripts
ADD characters /app/characters
ADD agent /app/agent

# Add dependencies to workspace root
RUN pnpm add -w -D ts-node typescript @types/node

WORKDIR /app/packages/agent
ADD .env /app/.env

# Add dependencies to the agent package specifically
RUN pnpm add -D ts-node typescript @types/node --filter "@ai16z/agent"

WORKDIR /app/packages/core
RUN pnpm add -D ts-node typescript @types/node --filter "@ai16z/eliza"

WORKDIR /app

# Optional: build step if using TypeScript or other build process
RUN pnpm i
RUN pnpm build

# Stage 2: Production image
FROM node:23.3.0

# Install dependencies required for the final runtime
RUN apt-get update && apt-get install -y \
python3 \
build-essential \
git \
curl \
sqlite3 && \
apt-get clean \
&& npm install -g pnpm@9.4.0

# Set working directory
WORKDIR /app

# Copy built files from the builder stage
COPY --from=builder /app /app

# install playwright
RUN pnpm exec playwright install
RUN pnpm exec playwright install-deps

# Expose application port if running a web server
EXPOSE 3000

# Add health check to ensure the app is running
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s CMD curl -f http://localhost:3000 || exit 1

# Set environment variables to configure runtime model settings
ENV NODE_ENV=production

# Default command to run the application
CMD ["pnpm", "start"]
# Command to run the container
CMD ["tail", "-f", "/dev/null"]
4 changes: 3 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
services:
tee:
command: ["pnpm", "start"]
image: hashwarlock/tee-agent:latest
build:
context: .
dockerfile: Dockerfile
stdin_open: true
tty: true
volumes:
Expand Down

0 comments on commit 2a4607a

Please sign in to comment.