Skip to content

Commit cc46d0f

Browse files
authored
feat: add dockerfile (#91)
1 parent c2a954f commit cc46d0f

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

Dockerfile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
FROM node:20 AS builder
2+
3+
ENV WORKSPACE_DIR=/workspace
4+
ENV EXTENSION_DIR=/extensions
5+
ENV NODE_ENV=production
6+
ENV WS_PATH=ws://localhost:8000
7+
8+
RUN mkdir -p ${WORKSPACE_DIR} &&\
9+
mkdir -p ${EXTENSION_DIR}
10+
11+
RUN apt-get update && apt-get install -y libsecret-1-dev
12+
13+
RUN npm config set registry https://registry.npmmirror.com
14+
15+
# 设置工作目录
16+
WORKDIR /build
17+
18+
COPY . /build
19+
20+
# 清理全局安装的包并安装 yarn
21+
RUN npm cache clean --force && \
22+
rm -rf /usr/local/lib/node_modules/yarn* && \
23+
rm -rf /usr/local/bin/yarn* && \
24+
npm install -g yarn
25+
26+
# 配置yarn为国内源
27+
RUN yarn config set npmRegistryServer https://registry.npmmirror.com
28+
29+
# 安装依赖$构建项目
30+
RUN yarn install && \
31+
yarn run build-web && \
32+
yarn run web-rebuild
33+
34+
FROM node:20 AS app
35+
36+
ENV WORKSPACE_DIR=/workspace
37+
ENV EXTENSION_DIR=/root/.sumi/extensions
38+
39+
RUN mkdir -p ${WORKSPACE_DIR} &&\
40+
mkdir -p ${EXTENSION_DIR} &&\
41+
mkdir -p /extensions
42+
43+
# 设置工作目录
44+
WORKDIR /release
45+
46+
COPY --from=builder /build/out /release/out
47+
COPY --from=builder /build/node_modules /release/node_modules
48+
49+
EXPOSE 8000
50+
51+
CMD [ "node", "./out/node/index.js"]

0 commit comments

Comments
 (0)