fix: some minor bugs and make Dockerfile more productive. (#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.
This commit is contained in:
Atom Pi 2022-06-29 23:21:18 +08:00 committed by GitHub
parent fe0ab0aa6f
commit cd902a21ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 47 additions and 28 deletions

View File

@ -114,6 +114,7 @@ jobs:
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
if: github.repository == 'casdoor/casdoor' && github.event_name == 'push' && steps.should_push.outputs.push=='true' if: github.repository == 'casdoor/casdoor' && github.event_name == 'push' && steps.should_push.outputs.push=='true'
with: with:
target: STANDARD
push: true push: true
tags: casbin/casdoor:${{steps.get-current-tag.outputs.tag }},casbin/casdoor:latest tags: casbin/casdoor:${{steps.get-current-tag.outputs.tag }},casbin/casdoor:latest

View File

@ -1,8 +1,3 @@
FROM golang:1.17.5 AS BACK
WORKDIR /go/src/casdoor
COPY . .
RUN ./build.sh && apt update && apt install wait-for-it && chmod +x /usr/bin/wait-for-it
FROM node:16.13.0 AS FRONT FROM node:16.13.0 AS FRONT
WORKDIR /web WORKDIR /web
COPY ./web . COPY ./web .
@ -10,28 +5,43 @@ RUN yarn config set registry https://registry.npmmirror.com
RUN yarn install && yarn run build RUN yarn install && yarn run build
FROM debian:latest AS ALLINONE FROM golang:1.17.5 AS BACK
RUN apt update WORKDIR /go/src/casdoor
RUN apt install -y ca-certificates && update-ca-certificates COPY . .
RUN apt install -y mariadb-server mariadb-client && mkdir -p web/build && chmod 777 /tmp RUN ./build.sh
LABEL MAINTAINER="https://casdoor.org/"
COPY --from=BACK /go/src/casdoor/ ./
COPY --from=BACK /usr/bin/wait-for-it ./
COPY --from=FRONT /web/build /web/build
CMD chmod 777 /tmp && service mariadb start&&\
if [ "${MYSQL_ROOT_PASSWORD}" = "" ] ;then MYSQL_ROOT_PASSWORD=123456 ; fi&&\
mysqladmin -u root password ${MYSQL_ROOT_PASSWORD} &&\
./wait-for-it localhost:3306 -- ./server --createDatabase=true
FROM alpine:latest FROM alpine:latest AS STANDARD
RUN sed -i 's/https/http/' /etc/apk/repositories
RUN apk add curl
RUN apk add ca-certificates && update-ca-certificates
LABEL MAINTAINER="https://casdoor.org/" LABEL MAINTAINER="https://casdoor.org/"
COPY --from=BACK /go/src/casdoor/ ./ WORKDIR /app
COPY --from=BACK /usr/bin/wait-for-it ./ COPY --from=BACK /go/src/casdoor/server ./server
RUN mkdir -p web/build && apk add --no-cache bash coreutils COPY --from=BACK /go/src/casdoor/swagger ./swagger
COPY --from=FRONT /web/build /web/build COPY --from=BACK /go/src/casdoor/conf/app.conf ./conf/app.conf
CMD ./server COPY --from=FRONT /web/build ./web/build
VOLUME /app/files /app/logs
ENTRYPOINT ["/app/server"]
FROM debian:latest AS db
RUN apt update \
&& apt install -y \
mariadb-server \
mariadb-client \
&& rm -rf /var/lib/apt/lists/*
FROM db AS ALLINONE
LABEL MAINTAINER="https://casdoor.org/"
ENV MYSQL_ROOT_PASSWORD=123456
WORKDIR /app
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=FRONT /web/build ./web/build
ENTRYPOINT ["/bin/bash"]
CMD ["/docker-entrypoint.sh"]

View File

@ -5,6 +5,7 @@ services:
build: build:
context: ./ context: ./
dockerfile: Dockerfile dockerfile: Dockerfile
target: STANDARD
entrypoint: /bin/sh -c './server --createDatabase=true' entrypoint: /bin/sh -c './server --createDatabase=true'
ports: ports:
- "8000:8000" - "8000:8000"

7
docker-entrypoint.sh Normal file
View File

@ -0,0 +1,7 @@
#!/bin/bash
service mariadb start
mysqladmin -u root password ${MYSQL_ROOT_PASSWORD}
exec /app/server --createDatabase=true

View File

@ -104,7 +104,7 @@ func initBuiltInUser() {
IsGlobalAdmin: true, IsGlobalAdmin: true,
IsForbidden: false, IsForbidden: false,
IsDeleted: false, IsDeleted: false,
SignupApplication: "built-in-app", SignupApplication: "app-built-in",
CreatedIp: "127.0.0.1", CreatedIp: "127.0.0.1",
Properties: make(map[string]string), Properties: make(map[string]string),
} }

View File

@ -93,7 +93,7 @@ class PermissionListPage extends BaseListPage {
...this.getColumnSearchProps('name'), ...this.getColumnSearchProps('name'),
render: (text, record, index) => { render: (text, record, index) => {
return ( return (
<Link to={`/permissions/${text}`}> <Link to={`/permissions/${record.owner}/${text}`}>
{text} {text}
</Link> </Link>
) )