1
- FROM golang:1.17-rc-buster
2
- WORKDIR /casdoor
3
- COPY ./ /casdoor
4
- RUN go env -w CGO_ENABLED=0 GOPROXY=https://goproxy.io,direct GOOS=linux GOARCH=amd64 \
5
- && apt update && apt install sudo \
6
- && wget https://nodejs.org/dist/v12.22.0/node-v12.22.0-linux-x64.tar.gz \
7
- && sudo tar xf node-v12.22.0-linux-x64.tar.gz \
8
- && sudo apt install wait-for-it
9
- ENV PATH=$PATH:/casdoor/node-v12.22.0-linux-x64/bin
10
- RUN npm install -g yarn \
11
- && cd web \
12
- && yarn install \
13
- && yarn run build \
14
- && rm -rf node_modules \
15
- && cd /casdoor \
16
- && go build main.go
17
- FROM alpine:3.7
18
- COPY --from=0 /casdoor /
19
- COPY --from=0 /usr/bin/wait-for-it /
20
- RUN set -eux \
21
- && sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \
22
- && apk update \
23
- && apk upgrade \
24
- && apk add bash
25
- CMD ./wait-for-it db:3306 && ./main
1
+ FROM golang:1.16 AS BACK
2
+ WORKDIR /go/src/casdoor
3
+ COPY . .
4
+ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o server . \
5
+ && apt update && apt install wait-for-it && chmod +x /usr/bin/wait-for-it
6
+
7
+ FROM node:14.17.4 AS FRONT
8
+ WORKDIR /web
9
+ COPY ./web .
10
+ RUN npm install && npm run build
11
+
12
+ FROM alpine:latest
13
+ LABEL MAINTAINER="https://casdoor.org/"
14
+
15
+ COPY --from=BACK /go/src/casdoor/ ./
16
+ COPY --from=BACK /usr/bin/wait-for-it ./
17
+ RUN mkdir -p web/build && apk add --no-cache bash coreutils
18
+ COPY --from=FRONT /web/build /web/build
19
+ ENTRYPOINT ["./wait-for-it" , "db:3306 " , "--" , "./server" ]
0 commit comments