coteerratu commited on
Commit
b960834
·
verified ·
1 Parent(s): 1583df9

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +41 -40
Dockerfile CHANGED
@@ -1,41 +1,42 @@
1
- # 使用基础镜像 Ubuntu
2
- FROM ubuntu:latest
3
-
4
- # 设置环境变量 DEBIAN_FRONTEND=noninteractive 防止安装过程中弹出交互式配置
5
- ENV DEBIAN_FRONTEND=noninteractive
6
-
7
- # 安装必要的软件包
8
- RUN apt-get update && \
9
- apt-get install -y \
10
- sudo \
11
- curl \
12
- git \
13
- nodejs \
14
- npm \
15
- && rm -rf /var/lib/apt/lists/*
16
-
17
- # 创建 /app 目录并授权给 online-terminal 用户
18
- RUN mkdir /app && \
19
- groupadd -r online-terminal && \
20
- useradd -r -g online-terminal -d /app -s /bin/bash online-terminal && \
21
- chown -R online-terminal:online-terminal /app
22
-
23
- # 在 /app 目录中使用 online-terminal 用户运行接下来的命令
24
- WORKDIR /app
25
- USER online-terminal
26
-
27
- # 克隆 Wetty 仓库
28
- RUN git clone https://github.com/krishnasrinivas/wetty.git . && \
29
- npm install
30
-
31
- # 在容器启动时使用特权用户 online-terminal
32
- USER online-terminal
33
-
34
- # 将 online-terminal 用户添加到 sudoers 文件并允许其使用 sudo 无需密码
35
- RUN echo "online-terminal ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
36
-
37
- # 暴露端口 3000
38
  EXPOSE 3000
39
-
40
- # 容器启动时运行 Wetty
41
- CMD ["npm", "start"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM node:current-alpine as builder
2
+ RUN apk add -U build-base python3 python2
3
+ WORKDIR /usr/src/app
4
+ COPY wetty /usr/src/app
5
+ RUN yarn && \
6
+ yarn build && \
7
+ yarn install --production --ignore-scripts --prefer-offline
8
+
9
+ FROM node:current-alpine
10
+ LABEL maintainer="[email protected]"
11
+ WORKDIR /usr/src/app
12
+ ENV NODE_ENV=production
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  EXPOSE 3000
14
+ COPY --from=builder /usr/src/app/build /usr/src/app/build
15
+ COPY --from=builder /usr/src/app/node_modules /usr/src/app/node_modules
16
+ COPY wetty/package.json /usr/src/app
17
+
18
+ COPY entrypoint.sh /entrypoint.sh
19
+
20
+ RUN apk update && \
21
+ apk add --no-cache \
22
+ coreutils \
23
+ openssh-client \
24
+ sshpass \
25
+ curl \
26
+ openssl && \
27
+ rm -rf /var/cache/apk/* && \
28
+ mkdir /home/node/.ssh && \
29
+ chown node:node /home/node/.ssh && \
30
+ chmod +x /entrypoint.sh && \
31
+ chown root:root -R /usr/src/app && \
32
+ chmod u=rwX,og=rX -R /usr/src/app
33
+
34
+ # setup healthcheck
35
+ HEALTHCHECK --interval=15s --timeout=20s \
36
+ CMD curl -sS --fail --insecure https://localhost:3000${BASEURL} || exit 1
37
+
38
+ VOLUME /home/node
39
+
40
+ USER node
41
+
42
+ ENTRYPOINT [ "/entrypoint.sh" ]