Skip to content

Commit

Permalink
Add casdoor (#7)
Browse files Browse the repository at this point in the history
* add casdoor
* update docker-compose
  • Loading branch information
haobibo authored Apr 12, 2024
1 parent 74a2215 commit 316d463
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 10 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ jobs:
- run: |
source ./tool.sh && build_image app-clash latest docker_app_clash/Dockerfile && push_image
## Casdoor
docker_casdoor:
name: 'casdoor'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
source ./tool.sh && build_image casdoor latest docker_casdoor/Dockerfile && push_image
## Keycloak
docker_keycloak:
name: 'keycloak'
Expand Down Expand Up @@ -83,15 +92,15 @@ jobs:
--build-arg "ARG_PROFILE_VSCODE=base"
alias_image base-dev latest developer latest && push_image dev
## DevBox - full stack
qpod_full-stack-dev:
name: 'full-stack-dev'
qpod_data-science-dev:
name: 'data-science-dev'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
source ./tool.sh && free_diskspace
build_image full-stack-dev latest docker_dev_box/Dockerfile \
--build-arg "BASE_IMG=full-stack" \
build_image data-science-dev latest docker_dev_box/Dockerfile \
--build-arg "BASE_IMG=data-science-stack" \
--build-arg "ARG_PROFILE_JUPYTER=base,kernels,extensions" \
--build-arg "ARG_PROFILE_VSCODE=base"
push_image
Expand Down
21 changes: 21 additions & 0 deletions docker_casdoor/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Distributed under the terms of the Modified BSD License.

ARG BASE_NAMESPACE
ARG BASE_IMG_BUILD="go-stack"
ARG BASE_IMG="node"

FROM ${BASE_NAMESPACE:+$BASE_NAMESPACE/}${BASE_IMG_BUILD} as builder
COPY work /opt/utils/
RUN source /opt/utils/script-setup-casdoor.sh \
&& setup_casdoor


FROM ${BASE_NAMESPACE:+$BASE_NAMESPACE/}${BASE_IMG}
COPY --from=builder /opt/casdoor /opt/casdoor
COPY work/app.conf /opt/casdoor/conf/app.conf
RUN mkdir -pv /root/web && ln -sf /opt/casdoor/web/build /root/web/

LABEL maintainer="haobibo@gmail.com"
ENV RUNNING_IN_DOCKER true
WORKDIR /opt/casdoor
EXPOSE 8000
15 changes: 15 additions & 0 deletions docker_casdoor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Casdoor

## debug

```shell
docker build -t qpod0dev/casdoor \
-f docker_casdoor/Dockerfile \
--build-arg="BASE_NAMESPACE=qpod0dev" \
docker_casdoor

docker run -it \
-p 8000:8000 \
qpod0dev/casdoor \
bash
```
41 changes: 41 additions & 0 deletions docker_casdoor/demo/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
version: '3.7'

services:
db-postgres:
# su postgres && psql -d casdoor -U pg-casdoor-username
image: postgres:15
container_name: db-postgres
environment:
POSTGRES_DB: casdoor
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres

svc-casdoor:
image: qpod/casdoor
# build:
# context: ../
# dockerfile: Dockerfile
# args:
# BASE_NAMESPACE: qpod0dev
container_name: svc-casdoor
# command: ["/bin/bash", "--login", "/opt/casdoor/server", "--createDatabase=true"]
command: |
/bin/bash -l -c '
ls -alh /opt/casdoor
echo "driverName = postgres" >> /opt/casdoor/conf/app.conf
echo "dataSourceName = \"user=postgres password=postgres host=db-postgres port=5432 sslmode=disable dbname=casdoor\"" >> /opt/casdoor/conf/app.conf
sleep 8s
cat /opt/casdoor/conf/app.conf
/opt/casdoor/server -createDatabase=true'
environment:
RUNNING_IN_DOCKER: "true"
ports:
- 8000:8000
depends_on:
- db-postgres
healthcheck:
test: ["CMD-SHELL", "curl", "--head", "-fsSk", "https://localhost:8000/health/ready" ]
interval: 30s
timeout: 30s
start_period: 5s
retries: 3
31 changes: 31 additions & 0 deletions docker_casdoor/work/app.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
appname = casdoor
authState = "casdoor"
batchSize = 100
copyrequestbody = true
dbName = casdoor
defaultStorageProvider =
enableGzip = true
frontendBaseDir = "../casdoor"
httpport = 8000
initDataFile = "./init_data.json"
initScore = 0
isCloudIntranet = false
isDemoMode = false
isUsernameLowered = false
ldapServerPort = 389
logConfig = {"filename": "logs/casdoor.log", "maxdays":99999, "perm":"0770"}
logPostOnly = true
origin =
originFrontend =
quota = {"organization": -1, "user": -1, "application": -1, "provider": -1}
radiusSecret = "secret"
radiusServerPort = 1812
redisEndpoint =
runmode = dev
showSql = false
socks5Proxy = "127.0.0.1:10808"
staticBaseUrl = "https://cdn.casbin.org"
tableNamePrefix =
verificationCodeTimeout = 10
# driverName = postgres
# dataSourceName = "user=postgres password=postgres host=localhost port=5432 sslmode=disable dbname=casdoor"
29 changes: 29 additions & 0 deletions docker_casdoor/work/script-setup-casdoor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
source /opt/utils/script-utils.sh

setup_casdoor() {
# ref: https://github.com/casdoor/casdoor/blob/master/Dockerfile
# Install the latest release of casdoor
VER_CASDOOR=$(curl -sL https://github.com/casdoor/casdoor/releases.atom | grep 'releases/tag' | head -1 | grep -Po '\d[\d.]+' ) \
&& URL_CASDOOR="https://github.com/casdoor/casdoor/archive/refs/tags/v${VER_CASDOOR}.tar.gz" \
&& echo "Downloading casdoor version ${VER_CASDOOR} from: ${URL_CASDOOR}" \
&& install_tar_gz $URL_CASDOOR \
&& mv /opt/casdoor-* /tmp/casdoor && mkdir -pv /opt/casdoor/web /opt/casdoor/conf

echo "--> Building Backend..." \
&& cd /tmp/casdoor && ./build.sh \
&& echo "${VER_CASDOOR}" > version_info.txt \
&& mv ./server ./swagger ./version_info.txt /opt/casdoor/ \
&& cat ./conf/app.conf | sort > /opt/casdoor/conf/app.conf
# && go test -v -run TestGetVersionInfo ./util/system_test.go ./util/system.go > version_info.txt \

echo "--> Building Frontend..." \
&& cd /tmp && corepack enable && yarn -v \
&& cd /tmp/casdoor/web \
&& yarn set version berry && yarn install && yarn run build \
&& mv ./build /opt/casdoor/web/
# && yarn install --frozen-lockfile && yarn run build \

echo "--> Finished building casdoor to /opt/casdoor!" \
&& rm -rf /tmp/casdoor \
&& echo "@ Version of Casdoor $(cat /opt/casdoor/version_info.txt)"
}
12 changes: 6 additions & 6 deletions docker_keycloak/demo/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ services:
POSTGRES_PASSWORD: pg-keycloak-password

svc-keycloak:
# image: qpod/keycloak
build:
context: ../
dockerfile: Dockerfile
args:
BASE_NAMESPACE: qpod
image: qpod/keycloak
# build:
# context: ../
# dockerfile: Dockerfile
# args:
# BASE_NAMESPACE: qpod0dev
container_name: svc-keycloak
# command: ["/bin/bash", "--login", "bin/kc.sh", "start-dev", "--verbose"]
command: |
Expand Down

0 comments on commit 316d463

Please sign in to comment.