mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 02:35:49 +08:00
feat: add run casdoor through docker
Signed-off-by: killer <1533063601@qq.com>
This commit is contained in:
parent
896f8b808f
commit
0fc388d662
12
README.md
12
README.md
@ -47,6 +47,18 @@ Backend | RESTful API backend for Casdoor | Golang + Beego + MySQL | https://git
|
||||
git clone https://github.com/casbin/casdoor
|
||||
```
|
||||
|
||||
## Run through Docker
|
||||
- Install Docker and Docker-compose,you see [docker](https://docs.docker.com/get-docker/) and [docker-compose](https://docs.docker.com/compose/install/)
|
||||
- vi casdoor/conf/app.conf
|
||||
- Modify dataSourceName = root:123@tcp(localhost:3306)/ to dataSourceName = root:123@tcp(db:3306)/
|
||||
- Execute the following command
|
||||
```shell
|
||||
docker-compose up
|
||||
```
|
||||
- Open browser:
|
||||
|
||||
http://localhost:8000/
|
||||
|
||||
## Run (Dev Environment)
|
||||
|
||||
- Run backend (in port 8000):
|
||||
|
19
docker-compose.yml
Normal file
19
docker-compose.yml
Normal file
@ -0,0 +1,19 @@
|
||||
version: '3.1'
|
||||
services:
|
||||
casdoor:
|
||||
build:
|
||||
context: ./
|
||||
dockerfile: go-dockerfile
|
||||
ports:
|
||||
- 8000:8000
|
||||
depends_on:
|
||||
- db
|
||||
db:
|
||||
restart: always
|
||||
image: mysql:8.0.25
|
||||
ports:
|
||||
- 3306:3306
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: 123
|
||||
volumes:
|
||||
- /usr/local/docker/mysql:/var/lib/mysql
|
25
go-dockerfile
Normal file
25
go-dockerfile
Normal file
@ -0,0 +1,25 @@
|
||||
FROM golang:1.17-rc-buster
|
||||
WORKDIR /casdoor
|
||||
COPY ./ /casdoor
|
||||
RUN go env -w CGO_ENABLED=0 GOPROXY=https://goproxy.io,direct GOOS=linux GOARCH=amd64 \
|
||||
&& apt update && apt install sudo \
|
||||
&& wget https://nodejs.org/dist/v12.22.0/node-v12.22.0-linux-x64.tar.gz \
|
||||
&& sudo tar xf node-v12.22.0-linux-x64.tar.gz \
|
||||
&& sudo apt install wait-for-it
|
||||
ENV PATH=$PATH:/casdoor/node-v12.22.0-linux-x64/bin
|
||||
RUN npm install -g yarn \
|
||||
&& cd web \
|
||||
&& yarn install \
|
||||
&& yarn run build \
|
||||
&& rm -rf node_modules \
|
||||
&& cd /casdoor \
|
||||
&& go build main.go
|
||||
FROM alpine:3.7
|
||||
COPY --from=0 /casdoor /
|
||||
COPY --from=0 /usr/bin/wait-for-it /
|
||||
RUN set -eux \
|
||||
&& sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \
|
||||
&& apk update \
|
||||
&& apk upgrade \
|
||||
&& apk add bash
|
||||
CMD ./wait-for-it db:3306 && ./main
|
Loading…
x
Reference in New Issue
Block a user