Skip to content

Commit cd902a2

Browse files
authored
fix: some minor bugs and make Dockerfile more productive. (casdoor#831)
* fix: some minor bugs and make Dockerfile more productive. * fix: make GitHub CI configuration support build image with STANDARD target. * fix: Naming the base stage in multi-stage builds with lowercase letters to support various operating systems. * fix: copy swagger to the image as well.
1 parent fe0ab0a commit cd902a2

File tree

6 files changed

+48
-29
lines changed

6 files changed

+48
-29
lines changed

.github/workflows/build.yml

+1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ jobs:
114114
uses: docker/build-push-action@v2
115115
if: github.repository == 'casdoor/casdoor' && github.event_name == 'push' && steps.should_push.outputs.push=='true'
116116
with:
117+
target: STANDARD
117118
push: true
118119
tags: casbin/casdoor:${{steps.get-current-tag.outputs.tag }},casbin/casdoor:latest
119120

Dockerfile

+37-27
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,47 @@
1-
FROM golang:1.17.5 AS BACK
2-
WORKDIR /go/src/casdoor
3-
COPY . .
4-
RUN ./build.sh && apt update && apt install wait-for-it && chmod +x /usr/bin/wait-for-it
5-
61
FROM node:16.13.0 AS FRONT
72
WORKDIR /web
83
COPY ./web .
94
RUN yarn config set registry https://registry.npmmirror.com
105
RUN yarn install && yarn run build
116

127

13-
FROM debian:latest AS ALLINONE
14-
RUN apt update
15-
RUN apt install -y ca-certificates && update-ca-certificates
16-
RUN apt install -y mariadb-server mariadb-client && mkdir -p web/build && chmod 777 /tmp
8+
FROM golang:1.17.5 AS BACK
9+
WORKDIR /go/src/casdoor
10+
COPY . .
11+
RUN ./build.sh
12+
13+
14+
FROM alpine:latest AS STANDARD
1715
LABEL MAINTAINER="https://casdoor.org/"
18-
COPY --from=BACK /go/src/casdoor/ ./
19-
COPY --from=BACK /usr/bin/wait-for-it ./
20-
COPY --from=FRONT /web/build /web/build
21-
CMD chmod 777 /tmp && service mariadb start&&\
22-
if [ "${MYSQL_ROOT_PASSWORD}" = "" ] ;then MYSQL_ROOT_PASSWORD=123456 ; fi&&\
23-
mysqladmin -u root password ${MYSQL_ROOT_PASSWORD} &&\
24-
./wait-for-it localhost:3306 -- ./server --createDatabase=true
25-
26-
27-
FROM alpine:latest
28-
RUN sed -i 's/https/http/' /etc/apk/repositories
29-
RUN apk add curl
30-
RUN apk add ca-certificates && update-ca-certificates
16+
17+
WORKDIR /app
18+
COPY --from=BACK /go/src/casdoor/server ./server
19+
COPY --from=BACK /go/src/casdoor/swagger ./swagger
20+
COPY --from=BACK /go/src/casdoor/conf/app.conf ./conf/app.conf
21+
COPY --from=FRONT /web/build ./web/build
22+
VOLUME /app/files /app/logs
23+
ENTRYPOINT ["/app/server"]
24+
25+
26+
FROM debian:latest AS db
27+
RUN apt update \
28+
&& apt install -y \
29+
mariadb-server \
30+
mariadb-client \
31+
&& rm -rf /var/lib/apt/lists/*
32+
33+
34+
FROM db AS ALLINONE
3135
LABEL MAINTAINER="https://casdoor.org/"
3236

33-
COPY --from=BACK /go/src/casdoor/ ./
34-
COPY --from=BACK /usr/bin/wait-for-it ./
35-
RUN mkdir -p web/build && apk add --no-cache bash coreutils
36-
COPY --from=FRONT /web/build /web/build
37-
CMD ./server
37+
ENV MYSQL_ROOT_PASSWORD=123456
38+
39+
WORKDIR /app
40+
COPY --from=BACK /go/src/casdoor/server ./server
41+
COPY --from=BACK /go/src/casdoor/swagger ./swagger
42+
COPY --from=BACK /go/src/casdoor/docker-entrypoint.sh /docker-entrypoint.sh
43+
COPY --from=BACK /go/src/casdoor/conf/app.conf ./conf/app.conf
44+
COPY --from=FRONT /web/build ./web/build
45+
46+
ENTRYPOINT ["/bin/bash"]
47+
CMD ["/docker-entrypoint.sh"]

docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ services:
55
build:
66
context: ./
77
dockerfile: Dockerfile
8+
target: STANDARD
89
entrypoint: /bin/sh -c './server --createDatabase=true'
910
ports:
1011
- "8000:8000"

docker-entrypoint.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
service mariadb start
4+
5+
mysqladmin -u root password ${MYSQL_ROOT_PASSWORD}
6+
7+
exec /app/server --createDatabase=true

object/init.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func initBuiltInUser() {
104104
IsGlobalAdmin: true,
105105
IsForbidden: false,
106106
IsDeleted: false,
107-
SignupApplication: "built-in-app",
107+
SignupApplication: "app-built-in",
108108
CreatedIp: "127.0.0.1",
109109
Properties: make(map[string]string),
110110
}

web/src/PermissionListPage.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class PermissionListPage extends BaseListPage {
9393
...this.getColumnSearchProps('name'),
9494
render: (text, record, index) => {
9595
return (
96-
<Link to={`/permissions/${text}`}>
96+
<Link to={`/permissions/${record.owner}/${text}`}>
9797
{text}
9898
</Link>
9999
)

0 commit comments

Comments
 (0)