Skip to content

Commit 9b0e1c9

Browse files
authored
Merge pull request #26 from cupen/develop
修正 docker 容器构建
2 parents c1ef3b9 + 67c63e2 commit 9b0e1c9

File tree

3 files changed

+56
-2
lines changed

3 files changed

+56
-2
lines changed

Dockerfile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
FROM node:14.16.1-alpine AS build
22

3-
RUN npm config set registry https://registry.npm.taobao.org/
3+
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
4+
RUN apk add --no-cache ca-certificates python3 py3-pip
5+
RUN apk add --no-cache tzdata \
6+
&& cp /usr/share/zoneinfo/Asia/Chongqing /etc/localtime \
7+
&& echo "Asia/Chongqing" > /etc/timezone
8+
RUN apk add --no-cache make g++
9+
10+
11+
12+
RUN npm config set registry https://registry.npmmirror.com
413
# 设置目录
514
RUN mkdir -p /app/data /app/server /app/client/dist /app/docker
615

@@ -16,7 +25,6 @@ ADD client/dist /app/client/dist
1625
WORKDIR /app/server
1726
ADD server /app/server
1827
RUN npm install
19-
2028
EXPOSE 8081/tcp
2129

2230
ENTRYPOINT ["/app/docker/docker-entrypoint.sh"]

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,23 @@ npm run start #本地运行可以使用该命令
8080

8181
4.使用浏览器打开进入http://localhost:8081即可进入应用
8282

83+
# Docker部署
84+
### 构建镜像
85+
```
86+
docker build . -t appspace
87+
```
8388

89+
### 使用 compose 运行
90+
```
91+
# 启动
92+
docker compose up -d
8493
94+
# 停止
95+
docker compose stop
96+
97+
# 停止并删除容器(包括数据)
98+
docker compose down --remove-orphans
99+
```
85100

86101
### 项目配置说明
87102

compose.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
services:
2+
appspace-mongo:
3+
container_name: appspace-mongo
4+
image: mongo:6.0
5+
restart: unless-stopped
6+
ports:
7+
- 127.0.0.1:27017:27017
8+
environment:
9+
- MONGO_INITDB_ROOT_USERNAME=root
10+
- MONGO_INITDB_ROOT_PASSWORD=root
11+
12+
appspace:
13+
container_name: appspace
14+
image: appspace
15+
restart: always
16+
ports:
17+
- '8081:8081'
18+
environment:
19+
APP_SPA_DOMAIN: http://example.com
20+
APP_SPA_SECRET: abcdefg
21+
APP_SPA_DBUSER: root
22+
APP_SPA_DBPWD: root
23+
APP_SPA_DB_NAME: app_space
24+
APP_SPA_DB_HOST: appspace-mongo
25+
APP_SPA_DB_PORT: 27017
26+
APP_SPA_ADMIN_ACCOUNT: admin
27+
APP_SPA_ADMIN_PASSWORD: "app@space"
28+
29+
30+
# volumes:
31+
# dbdata:

0 commit comments

Comments
 (0)