forked from casdoor/casdoor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
6 changed files
with
48 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,47 @@ | ||
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 | ||
WORKDIR /web | ||
COPY ./web . | ||
RUN yarn config set registry https://registry.npmmirror.com | ||
RUN yarn install && yarn run build | ||
|
||
|
||
FROM debian:latest AS ALLINONE | ||
RUN apt update | ||
RUN apt install -y ca-certificates && update-ca-certificates | ||
RUN apt install -y mariadb-server mariadb-client && mkdir -p web/build && chmod 777 /tmp | ||
FROM golang:1.17.5 AS BACK | ||
WORKDIR /go/src/casdoor | ||
COPY . . | ||
RUN ./build.sh | ||
|
||
|
||
FROM alpine:latest AS STANDARD | ||
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 | ||
RUN sed -i 's/https/http/' /etc/apk/repositories | ||
RUN apk add curl | ||
RUN apk add ca-certificates && update-ca-certificates | ||
|
||
WORKDIR /app | ||
COPY --from=BACK /go/src/casdoor/server ./server | ||
COPY --from=BACK /go/src/casdoor/swagger ./swagger | ||
COPY --from=BACK /go/src/casdoor/conf/app.conf ./conf/app.conf | ||
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/" | ||
|
||
COPY --from=BACK /go/src/casdoor/ ./ | ||
COPY --from=BACK /usr/bin/wait-for-it ./ | ||
RUN mkdir -p web/build && apk add --no-cache bash coreutils | ||
COPY --from=FRONT /web/build /web/build | ||
CMD ./server | ||
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
service mariadb start | ||
|
||
mysqladmin -u root password ${MYSQL_ROOT_PASSWORD} | ||
|
||
exec /app/server --createDatabase=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters