Skip to content

Commit

Permalink
refactor to 99nil
Browse files Browse the repository at this point in the history
  • Loading branch information
zc2638 committed Feb 5, 2024
1 parent c481960 commit 47602b3
Show file tree
Hide file tree
Showing 51 changed files with 140 additions and 256 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: casdoor
MYSQL_DATABASE: user
MYSQL_ROOT_PASSWORD: 123456
ports:
- 3306:3306
Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: casdoor
MYSQL_DATABASE: user
MYSQL_ROOT_PASSWORD: 123456
ports:
- 3306:3306
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ commentsRouter*.go
# ignore build result
casdoor
server
.DS_Store
67 changes: 19 additions & 48 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,31 @@ WORKDIR /web
COPY ./web .
RUN yarn install --frozen-lockfile --network-timeout 1000000 && yarn run build


FROM golang:1.20.12 AS BACK
WORKDIR /go/src/casdoor
FROM golang:1.21 AS BACK
WORKDIR /work
COPY . .
RUN ./build.sh
RUN go test -v -run TestGetVersionInfo ./util/system_test.go ./util/system.go > version_info.txt

FROM alpine:latest AS STANDARD
LABEL MAINTAINER="https://casdoor.org/"
ARG USER=casdoor

RUN sed -i 's/https/http/' /etc/apk/repositories
RUN apk add --update sudo
RUN apk add curl
RUN apk add ca-certificates && update-ca-certificates

RUN adduser -D $USER -u 1000 \
&& echo "$USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USER \
&& chmod 0440 /etc/sudoers.d/$USER \
&& mkdir logs \
&& chown -R $USER:$USER logs

USER 1000
WORKDIR /
COPY --from=BACK --chown=$USER:$USER /go/src/casdoor/server ./server
COPY --from=BACK --chown=$USER:$USER /go/src/casdoor/swagger ./swagger
COPY --from=BACK --chown=$USER:$USER /go/src/casdoor/conf/app.conf ./conf/app.conf
COPY --from=BACK --chown=$USER:$USER /go/src/casdoor/version_info.txt ./go/src/casdoor/version_info.txt
COPY --from=FRONT --chown=$USER:$USER /web/build ./web/build

ENTRYPOINT ["/server"]


FROM debian:latest AS db
RUN apt update \
&& apt install -y \
mariadb-server \
mariadb-client \
&& rm -rf /var/lib/apt/lists/*
FROM alpine:3.18 as alpine
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \
apk update && \
apk add -U --no-cache ca-certificates tzdata

FROM alpine:3.18
LABEL MAINTAINER="https://github.com/99nil"
ENV TZ="Asia/Shanghai"

FROM db AS ALLINONE
LABEL MAINTAINER="https://casdoor.org/"
WORKDIR /work

RUN apt update
RUN apt install -y ca-certificates && update-ca-certificates
COPY --from=alpine /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=BACK /work/server /usr/local/bin/server
COPY --from=BACK /work/conf/app.conf /work/conf/app.conf
COPY --from=BACK /work/swagger /work/swagger
COPY --from=BACK /work/version_info.txt /work/version_info.txt
COPY --from=FRONT /web/build /work/web/build

WORKDIR /
COPY --from=BACK /go/src/casdoor/server ./server
COPY --from=BACK /go/src/casdoor/swagger ./swagger
COPY --from=BACK /go/src/casdoor/docker-entrypoint.sh /docker-entrypoint.sh
COPY --from=BACK /go/src/casdoor/conf/app.conf ./conf/app.conf
COPY --from=BACK /go/src/casdoor/version_info.txt ./go/src/casdoor/version_info.txt
COPY --from=FRONT /web/build ./web/build
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

ENTRYPOINT ["/bin/bash"]
CMD ["/docker-entrypoint.sh"]
CMD ["server"]
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

# Image URL to use all building/pushing image targets
REGISTRY ?= casbin
IMG ?= casdoor
REGISTRY ?= 99nil
IMG ?= user
IMG_TAG ?=$(shell git --no-pager log -1 --format="%ad" --date=format:"%Y%m%d")-$(shell git describe --tags --always --dirty --abbrev=6)
NAMESPACE ?= casdoor
APP ?= casdoor
NAMESPACE ?= 99nil
APP ?= user
HOST ?= test.com


Expand Down
10 changes: 5 additions & 5 deletions conf/app.conf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
appname = casdoor
appname = user
httpport = 8000
runmode = dev
copyrequestbody = true
driverName = mysql
dataSourceName = root:123456@tcp(localhost:3306)/
dbName = casdoor
dbName = user
tableNamePrefix =
showSql = false
redisEndpoint =
Expand All @@ -15,7 +15,7 @@ socks5Proxy = "127.0.0.1:10808"
verificationCodeTimeout = 10
initScore = 0
logPostOnly = true
origin =
origin = user.99nil.com
originFrontend =
staticBaseUrl = "https://cdn.casbin.org"
isDemoMode = false
Expand All @@ -25,6 +25,6 @@ ldapServerPort = 389
radiusServerPort = 1812
radiusSecret = "secret"
quota = {"organization": -1, "user": -1, "application": -1, "provider": -1}
logConfig = {"filename": "logs/casdoor.log", "maxdays":99999, "perm":"0770"}
logConfig = {"filename": "logs/user.log", "maxdays":99999, "perm":"0770"}
initDataFile = "./init_data.json"
frontendBaseDir = "../casdoor"
frontendBaseDir = ""
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
version: '3.1'
services:
casdoor:
user:
restart: always
build:
context: ./
dockerfile: Dockerfile
target: STANDARD
entrypoint: /bin/sh -c './server --createDatabase=true'
ports:
- "8000:8000"
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func main() {
beego.InsertFilter("*", beego.BeforeRouter, routers.RecordMessage)

beego.BConfig.WebConfig.Session.SessionOn = true
beego.BConfig.WebConfig.Session.SessionName = "casdoor_session_id"
beego.BConfig.WebConfig.Session.SessionName = "user_session_id"
if conf.GetConfigString("redisEndpoint") == "" {
beego.BConfig.WebConfig.Session.SessionProvider = "file"
beego.BConfig.WebConfig.Session.SessionProviderConfig = "./tmp"
Expand Down
6 changes: 3 additions & 3 deletions object/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ func initBuiltInApplication() {
Owner: "admin",
Name: "app-built-in",
CreatedTime: util.GetCurrentTime(),
DisplayName: "Casdoor",
Logo: fmt.Sprintf("%s/img/casdoor-logo_1185x256.png", conf.GetConfigString("staticBaseUrl")),
HomepageUrl: "https://casdoor.org",
DisplayName: "99nil",
Logo: "https://raw.githubusercontent.com/99nil/material/main/logo/logo2.png",
HomepageUrl: "",
Organization: "built-in",
Cert: "cert-built-in",
EnablePassword: true,
Expand Down
4 changes: 2 additions & 2 deletions routers/static_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ func StaticFilter(ctx *context.Context) {
}
dir = strings.ReplaceAll(dir, "\\", "/")
ctx.ResponseWriter.WriteHeader(http.StatusNotFound)
errorText := fmt.Sprintf("The Casdoor frontend HTML file: \"index.html\" was not found, it should be placed at: \"%s/web/build/index.html\". For more information, see: https://casdoor.org/docs/basic/server-installation/#frontend-1", dir)
http.ServeContent(ctx.ResponseWriter, ctx.Request, "Casdoor frontend has encountered error...", time.Now(), strings.NewReader(errorText))
errorText := fmt.Sprintf("The frontend HTML file: \"index.html\" was not found, it should be placed at: \"%s/web/build/index.html\".", dir)
http.ServeContent(ctx.ResponseWriter, ctx.Request, "frontend has encountered error...", time.Now(), strings.NewReader(errorText))
return
}

Expand Down
2 changes: 1 addition & 1 deletion swagger/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -5070,7 +5070,7 @@
}
}
},
"/apiapi/login/oauth/access_token": {
"/api/login/oauth/access_token": {
"post": {
"tags": [
"Token API"
Expand Down
16 changes: 7 additions & 9 deletions swagger/swagger.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
swagger: "2.0"
info:
title: Casdoor RESTful API
description: Swagger Docs of Casdoor Backend API
title: 99nil User RESTful API
description: Swagger Docs of 99nil User API
version: 1.376.1
contact:
email: [email protected]
basePath: /
schemes:
- https
Expand Down Expand Up @@ -504,7 +502,7 @@ paths:
post:
tags:
- Service API
description: This API is not for Casdoor frontend to call, it is for Casdoor SDKs.
description: This API is not for 99nil User frontend to call, it is for 99nil User SDKs.
operationId: ApiController.SendEmail
parameters:
- in: query
Expand Down Expand Up @@ -532,7 +530,7 @@ paths:
post:
tags:
- Service API
description: This API is not for Casdoor frontend to call, it is for Casdoor SDKs.
description: This API is not for 99nil User frontend to call, it is for 99nil User SDKs.
operationId: ApiController.SendNotification
parameters:
- in: body
Expand All @@ -550,7 +548,7 @@ paths:
post:
tags:
- Service API
description: This API is not for Casdoor frontend to call, it is for Casdoor SDKs.
description: This API is not for 99nil User frontend to call, it is for 99nil User SDKs.
operationId: ApiController.SendSms
parameters:
- in: query
Expand Down Expand Up @@ -2240,7 +2238,7 @@ paths:
get:
tags:
- System API
description: get version info like Casdoor release version and commit ID
description: get version info like 99nil User release version and commit ID
operationId: ApiController.GetVersionInfo
responses:
"200":
Expand Down Expand Up @@ -3310,7 +3308,7 @@ paths:
description: '"The Response object"'
schema:
$ref: '#/definitions/controllers.Response'
/apiapi/login/oauth/access_token:
/api/login/oauth/access_token:
post:
tags:
- Token API
Expand Down
8 changes: 4 additions & 4 deletions web/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Casdoor - An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS"
content="99nil User - An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS"
/>
<link rel="apple-touch-icon" href="https://cdn.casbin.org/img/favicon.png" />
<link rel="apple-touch-icon" href="https://raw.githubusercontent.com/99nil/material/main/logo/logo2.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="https://cdn.casbin.org/site/casdoor/manifest.json" />
<!-- <link rel="manifest" href="https://cdn.casbin.org/site/casdoor/manifest.json" />-->
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Expand All @@ -24,7 +24,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Casdoor</title>
<title>99nil</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
Loading

0 comments on commit 47602b3

Please sign in to comment.