Skip to content

Commit

Permalink
Merge pull request #26 from cupen/develop
Browse files Browse the repository at this point in the history
修正 docker 容器构建
  • Loading branch information
treexi authored Aug 8, 2024
2 parents c1ef3b9 + 67c63e2 commit 9b0e1c9
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
FROM node:14.16.1-alpine AS build

RUN npm config set registry https://registry.npm.taobao.org/
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
RUN apk add --no-cache ca-certificates python3 py3-pip
RUN apk add --no-cache tzdata \
&& cp /usr/share/zoneinfo/Asia/Chongqing /etc/localtime \
&& echo "Asia/Chongqing" > /etc/timezone
RUN apk add --no-cache make g++



RUN npm config set registry https://registry.npmmirror.com
# 设置目录
RUN mkdir -p /app/data /app/server /app/client/dist /app/docker

Expand All @@ -16,7 +25,6 @@ ADD client/dist /app/client/dist
WORKDIR /app/server
ADD server /app/server
RUN npm install

EXPOSE 8081/tcp

ENTRYPOINT ["/app/docker/docker-entrypoint.sh"]
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,23 @@ npm run start #本地运行可以使用该命令

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

# Docker部署
### 构建镜像
```
docker build . -t appspace
```

### 使用 compose 运行
```
# 启动
docker compose up -d
# 停止
docker compose stop
# 停止并删除容器(包括数据)
docker compose down --remove-orphans
```

### 项目配置说明

Expand Down
31 changes: 31 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
services:
appspace-mongo:
container_name: appspace-mongo
image: mongo:6.0
restart: unless-stopped
ports:
- 127.0.0.1:27017:27017
environment:
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=root

appspace:
container_name: appspace
image: appspace
restart: always
ports:
- '8081:8081'
environment:
APP_SPA_DOMAIN: http://example.com
APP_SPA_SECRET: abcdefg
APP_SPA_DBUSER: root
APP_SPA_DBPWD: root
APP_SPA_DB_NAME: app_space
APP_SPA_DB_HOST: appspace-mongo
APP_SPA_DB_PORT: 27017
APP_SPA_ADMIN_ACCOUNT: admin
APP_SPA_ADMIN_PASSWORD: "app@space"


# volumes:
# dbdata:

0 comments on commit 9b0e1c9

Please sign in to comment.