Open aliuq opened 2 weeks ago
Hey @aliuq thanks for this. We may support docker eventually but it's not a priority at this time.
Are you interested in docker for running this locally, developing against the repo, or are you trying to host srcbook?
@benjreinhart Hi, I tried a rebuild and during the process I found that the @srcbook/api
package has a few packages that cannot be packaged into the esm output type, and also after the build, when accessing the portal using the separate SRCBOOK_CONFIG.api.host
, there is a websocket connectivity error, so it is a bit tricky to split the web and api into two images at the moment.
On the contrary, building the container with the official npm package is much easier, the only problem is that some extra files are bundled with the container, resulting in a large image size.
I've built an image aliuq/srcbook
, which is not fully tested for functionality and may be missing relevant dependencies.
FROM node:22.7.0-alpine3.20 AS builder
WORKDIR /app
RUN yarn add srcbook && \
mv node_modules/srcbook . && \
rm node_modules yarn.lock package.json -rf && \
mv srcbook/* . && \
rm node_modules -rf && \
yarn install --prod && \
find ./node_modules -type f \( -name "*.d.ts" -o -name "*.log" -o -name "*.bak" -o -name "DS_Store" -o -name "LICENSE" -o -name "*.d.mts" -o -name "*.txt" \) -delete
FROM node:22.7.0-alpine3.20 AS runner
WORKDIR /app
COPY --from=builder /app .
CMD [ "node", "bin/cli.mjs", "start" ]
EXPOSE 2150
VOLUME /root/.srcbook
VOLUME /root/.npm
Usage
# Start
docker run -p 2150:2150 -v $PWD/srcbookData:/root/.srcbook --name srcbook aliuq/srcbook
# Stop
docker rm srcbook -f
# Exec
docker exec -it srcbook /bin/sh
It would be nice to start building from web and api!
srcbook is a great project
The current
api
andshared
build methods will cause theimage
size to be too large, it contains some devDependencies for start works, I don’t know if there is any reason for this design.Some thoughts on containers, there should be two images, one
web
and oneapi
. After the web image is built, usenginx/apache
to run it. After the api image is built, usenode
to run it.Useful library building tools,tsup and unbuild