(可选) 使用 Docker 运行
安装要求
Hardware
If you want to build the Docker image by yourself, please ensure that your machine has at least 2GB memory. Casdoor's frontend is a NPM project of React. Building the frontend requires at least 2GB memory. Less than 2GB memory may lead to frontend build failure.
If you just need to run the pre-built image, please ensure that your machine has at least 100MB memory.
OS
All OSes (Linux, Windows and macOS) are supported.
Docker
You can use docker (docker-engine version >= 17.05) in Linux or Docker Desktop in Windows and macOS.
Users of all OSes must ensure that the docker-engine version >= 17.05. It is because that we use multi-stage build feature in docker-compose.yml, which was supported in 17.05 and above versions. See https://docs.docker.com/develop/develop-images/multistage-build/ for more information.
If you also use docker-compose, please ensure that docker-compose version >= 2.2. For Linux users, you also need to make sure that docker-compose is installed, given that it is seperated from docker-engine.
获取镜像
We have provided two DockerHub images:
名称 | 描述 | 建议 |
---|---|---|
casdoor-all-in-one | Casdoor 和 MySQL 数据库都在镜像内 | 已经包含示例数据库,仅用于测试 |
casdoor | 只有casdoor在镜像里 | 可以连接到您自己的数据库并用于生产 |
- 在casbin/casdoor-all-in-one中,casdoor二进制文件、mysql数据库和所有必要的配置都打包在一起。 这个图像是为了让新用户能够快速在户口上试用。 通过这个镜像,您可以立即通过一个单个命令(或两个命令)启动一个没有任何复杂配置 的Casdoor。 注意:我们不建议您在生产环境中使用此镜像
Option-1: Use the toy database
Run the container with port 8000
exposed to host. It will automatically pull the image if it doesn't exist in the local host.
docker run -p 8000:8000 casbin/casdoor-all-in-one
Visit: http://localhost:8000 in your browser. Log into Casdoor dashboard with the default global admin account: built-in/admin
admin
123
Option-2: Try with docker-compose
Create a sepereate database by docker-compose
docker-compose up
That's it! 🛩️
Visit: http://localhost:8000 in your browser. Log into Casdoor dashboard with the default global admin account: built-in/admin
admin
123
Note: if you dive deeper into the docker-compose.yml, you may be puzzled by the environment variable we created in it called "RUNNING_IN_DOCKER". When database 'db' is created via docker-compose, it is available on localhost of your pc but not localhost of the casdoor container. To prevent you from the troubles caused by modifying app.conf which are pretty difficult for a new user, we provided this environment variable and pre-assigned it in docker-compose.yml. When this environment variable is true, localhost will be replaced with host.docker.internal so that you casdoor can visit the db.
Option-3 Try directly with standard image
Modify the following items in conf/app.conf
like a normal Casdoor installation:
driverName = mysql
dataSourceName = root:123456@tcp(localhost:3306)/
dbName = casdoor
This is merely a sample and you need to modify them according to your own database
Note: if it is not convenient to mount the configuration file to a container, using environment variables is also a possible solution see Via Environment Variables for details
Then run
docker run -p 8000:8000 -v <path to directory containing app.conf>:/conf casbin/casdoor:latest
Anyway just mount the app.conf to /conf/app.conf and start it.
Visit: http://localhost:8000 in your browser. Log into Casdoor dashboard with the default global admin account: built-in/admin
admin
123