Skip to content

Commit 0a7859b

Browse files
authored
Add Docker support for Srcbook (#455)
1 parent a236470 commit 0a7859b

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

Dockerfile

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM node:22.7.0-alpine3.20
2+
WORKDIR /app
3+
4+
RUN corepack enable && corepack prepare [email protected] --activate
5+
6+
# Copy all package files first
7+
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
8+
COPY packages packages/
9+
COPY srcbook srcbook/
10+
COPY turbo.json ./
11+
12+
# Install dependencies
13+
RUN pnpm install
14+
15+
# Build the application
16+
RUN pnpm build
17+
18+
# Create necessary directories for volumes
19+
RUN mkdir -p /root/.srcbook /root/.npm
20+
21+
# Source code will be mounted at runtime
22+
CMD [ "pnpm", "start" ]
23+
24+
EXPOSE 2150

README.md

+17
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,23 @@ pnpm dlx srcbook@latest start
8080
> You can instead use a global install with `<pkg manager> i -g srcbook`
8181
> and then directly call srcbook with `srcbook start`
8282
83+
### Using Docker
84+
85+
You can also run Srcbook using Docker:
86+
87+
```bash
88+
# Build the Docker image
89+
docker build -t srcbook .
90+
91+
# Run the container
92+
# The -p flag maps port 2150 from the container to your host machine
93+
# First -v flag mounts your local .srcbook directory to persist data
94+
# Second -v flag shares your npm cache for better performance
95+
docker run -p 2150:2150 -v ~/.srcbook:/root/.srcbook -v ~/.npm:/root/.npm srcbook
96+
```
97+
98+
Make sure to set up your API key after starting the container. You can do this through the web interface at `http://localhost:2150`.
99+
83100
### Current Commands
84101

85102
```bash

0 commit comments

Comments
 (0)