Update Dockerfile
Browse files- Dockerfile +41 -40
Dockerfile
CHANGED
@@ -1,41 +1,42 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
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 |
-
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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" ]
|