Skip to content

Commit

Permalink
Add Docker support for Srcbook (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
swiftugandan authored Dec 3, 2024
1 parent a236470 commit 0a7859b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM node:22.7.0-alpine3.20
WORKDIR /app

RUN corepack enable && corepack prepare [email protected] --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
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,23 @@ pnpm dlx srcbook@latest start
> You can instead use a global install with `<pkg manager> 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
Expand Down

0 comments on commit 0a7859b

Please sign in to comment.