forked from elizaOS/eliza
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request elizaOS#2347 from JoeyKhd/fix-dockerimage
fix: docker images+compose and broken documentation
- Loading branch information
Showing
6 changed files
with
433 additions
and
686 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Ignore node_modules from the build context | ||
node_modules | ||
|
||
# Ignore logs and temporary files | ||
*.log | ||
*.tmp | ||
.DS_Store | ||
|
||
# Ignore Git files and metadata | ||
.gitignore | ||
|
||
# Ignore IDE and editor config files | ||
.vscode | ||
.idea | ||
*.swp | ||
|
||
# Ignore build artifacts from the host | ||
dist | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,62 @@ | ||
# Use a specific Node.js version for better reproducibility | ||
FROM node:23.3.0-slim AS builder | ||
|
||
# Install pnpm globally and install necessary build tools | ||
# Install pnpm globally and necessary build tools | ||
RUN npm install -g [email protected] && \ | ||
apt-get update && \ | ||
apt-get install -y git python3 make g++ && \ | ||
apt-get upgrade -y && \ | ||
apt-get install -y \ | ||
git \ | ||
python3 \ | ||
python3-pip \ | ||
curl \ | ||
node-gyp \ | ||
ffmpeg \ | ||
libtool-bin \ | ||
autoconf \ | ||
automake \ | ||
libopus-dev \ | ||
make \ | ||
g++ \ | ||
build-essential \ | ||
libcairo2-dev \ | ||
libjpeg-dev \ | ||
libpango1.0-dev \ | ||
libgif-dev \ | ||
openssl \ | ||
libssl-dev && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Set Python 3 as the default python | ||
RUN ln -s /usr/bin/python3 /usr/bin/python | ||
RUN ln -sf /usr/bin/python3 /usr/bin/python | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Copy package.json and other configuration files | ||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc turbo.json ./ | ||
# Copy application code | ||
COPY . . | ||
|
||
# Copy the rest of the application code | ||
COPY agent ./agent | ||
COPY packages ./packages | ||
COPY scripts ./scripts | ||
COPY characters ./characters | ||
# Install dependencies | ||
RUN pnpm install --no-frozen-lockfile | ||
|
||
# Install dependencies and build the project | ||
RUN pnpm install \ | ||
&& pnpm build-docker \ | ||
&& pnpm prune --prod | ||
# Build the project | ||
RUN pnpm run build && pnpm prune --prod | ||
|
||
# Create a new stage for the final image | ||
# Final runtime image | ||
FROM node:23.3.0-slim | ||
|
||
# Install runtime dependencies if needed | ||
# Install runtime dependencies | ||
RUN npm install -g [email protected] && \ | ||
apt-get update && \ | ||
apt-get install -y git python3 && \ | ||
apt-get install -y \ | ||
git \ | ||
python3 \ | ||
ffmpeg && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Copy built artifacts and production dependencies from the builder stage | ||
|
@@ -47,9 +66,14 @@ COPY --from=builder /app/.npmrc ./ | |
COPY --from=builder /app/turbo.json ./ | ||
COPY --from=builder /app/node_modules ./node_modules | ||
COPY --from=builder /app/agent ./agent | ||
COPY --from=builder /app/client ./client | ||
COPY --from=builder /app/lerna.json ./ | ||
COPY --from=builder /app/packages ./packages | ||
COPY --from=builder /app/scripts ./scripts | ||
COPY --from=builder /app/characters ./characters | ||
|
||
# Set the command to run the application | ||
CMD ["pnpm", "start"] | ||
# Expose necessary ports | ||
EXPOSE 3000 5173 | ||
|
||
# Command to start the application | ||
CMD ["sh", "-c", "pnpm start & pnpm start:client"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,43 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
## Modified version of https://docusaurus.community/knowledge/deployment/docker/ | ||
|
||
# Stage 1: Base image. | ||
## Start with a base image containing NodeJS so we can build Docusaurus. | ||
FROM node:23.3.0-slim AS base | ||
## Disable colour output from yarn to make logs easier to read. | ||
|
||
## https://pnpm.io/docker | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
|
||
ENV FORCE_COLOR=0 | ||
## Enable corepack. | ||
RUN corepack enable | ||
## Set the working directory to `/opt/docusaurus`. | ||
WORKDIR /opt/docusaurus | ||
|
||
## Required by docusaurus: [ERROR] Loading of version failed for version current | ||
RUN apt-get update && apt-get install -y git | ||
|
||
# Stage 2a: Development mode. | ||
FROM base AS dev | ||
## Set the working directory to `/opt/docusaurus`. | ||
WORKDIR /opt/docusaurus | ||
## Expose the port that Docusaurus will run on. | ||
EXPOSE 3000 | ||
## Run the development server. | ||
CMD [ -d "node_modules" ] && npm run start -- --host 0.0.0.0 --poll 1000 || pnpm install && pnpm run start -- --host 0.0.0.0 --poll 1000 | ||
CMD [ -d "node_modules" ] && pnpm start -- --host 0.0.0.0 --poll 1000 || pnpm install && pnpm start -- --host 0.0.0.0 --poll 1000 | ||
|
||
# Stage 2b: Production build mode. | ||
FROM base AS preprod | ||
FROM base AS prod | ||
## Set the working directory to `/opt/docusaurus`. | ||
WORKDIR /opt/docusaurus | ||
|
||
## This is in case someone needs to build the lock file | ||
#RUN apt install python-is-python3 g++ make -y | ||
|
||
COPY docs/package.json /opt/docusaurus/package.json | ||
COPY docs/package-lock.json /opt/docusaurus/package-lock.json | ||
|
||
FROM preprod AS prod | ||
|
||
## Install dependencies with `--immutable` to ensure reproducibility. | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install | ||
|
||
## Copy over the source code. | ||
COPY docs/ /opt/docusaurus/ | ||
COPY packages/ /opt/packages/ | ||
|
||
## Required buy docusaurus [ERROR] Loading of version failed for version current | ||
COPY .git/ /opt/.git/ | ||
|
||
# Build from sources | ||
RUN pnpm run build | ||
## Install dependencies with `--frozen-lockfile` to ensure reproducibility. | ||
RUN pnpm install --no-frozen-lockfile | ||
## Build the static site. | ||
RUN pnpm build | ||
|
||
# Stage 3a: Serve with `docusaurus serve`. | ||
FROM prod AS serve | ||
## Expose the port that Docusaurus will run on. | ||
EXPOSE 3000 | ||
## Run the production server. | ||
CMD ["npm", "run", "serve", "--", "--host", "0.0.0.0", "--no-open"] | ||
|
||
CMD ["pnpm", "run", "serve", "--host", "0.0.0.0", "--no-open"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.