From 0a7859bf74cdcc7e924dcaf0aaafe4cd6f8c4fcc Mon Sep 17 00:00:00 2001 From: swiftugandan Date: Tue, 3 Dec 2024 05:45:29 +0000 Subject: [PATCH] Add Docker support for Srcbook (#455) --- Dockerfile | 24 ++++++++++++++++++++++++ README.md | 17 +++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..5e0b0e3a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM node:22.7.0-alpine3.20 +WORKDIR /app + +RUN corepack enable && corepack prepare pnpm@9.12.1 --activate + +# Copy all package files first +COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ +COPY packages packages/ +COPY srcbook srcbook/ +COPY turbo.json ./ + +# Install dependencies +RUN pnpm install + +# Build the application +RUN pnpm build + +# Create necessary directories for volumes +RUN mkdir -p /root/.srcbook /root/.npm + +# Source code will be mounted at runtime +CMD [ "pnpm", "start" ] + +EXPOSE 2150 \ No newline at end of file diff --git a/README.md b/README.md index d77c3170..3a78f91c 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,23 @@ pnpm dlx srcbook@latest start > You can instead use a global install with ` i -g srcbook` > and then directly call srcbook with `srcbook start` +### Using Docker + +You can also run Srcbook using Docker: + +```bash +# Build the Docker image +docker build -t srcbook . + +# Run the container +# The -p flag maps port 2150 from the container to your host machine +# First -v flag mounts your local .srcbook directory to persist data +# Second -v flag shares your npm cache for better performance +docker run -p 2150:2150 -v ~/.srcbook:/root/.srcbook -v ~/.npm:/root/.npm srcbook +``` + +Make sure to set up your API key after starting the container. You can do this through the web interface at `http://localhost:2150`. + ### Current Commands ```bash