-
-
Notifications
You must be signed in to change notification settings - Fork 102
/
Dockerfile
53 lines (42 loc) · 1.34 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
FROM golang:1.19 as BACK
RUN apt-get update && \
apt-get -y install unzip build-essential autoconf libtool
WORKDIR /go/src
COPY . .
# Install protobuf from source
RUN curl -LjO https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.17.3.zip && \
unzip v3.17.3.zip && \
cd protobuf-3.17.3 && \
./autogen.sh && \
./configure && \
make && \
make install && \
ldconfig && \
make clean && \
cd .. && \
rm -r protobuf-3.17.3 && \
rm v3.17.3.zip
# Go environment variable to enable Go modules
ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64
# Download dependencies
RUN go mod download
# Install protoc-gen-go
RUN go install google.golang.org/protobuf/cmd/[email protected]
RUN go install google.golang.org/grpc/cmd/[email protected]
# Copy the source and generate the .proto file
ADD . /go/src/github.com/casbin/casbin-server
WORKDIR $GOPATH/src/github.com/casbin/casbin-server
RUN protoc --go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=require_unimplemented_servers=false \
--go-grpc_opt=paths=source_relative proto/casbin.proto
# Install app
RUN go install .
RUN cd /go/src && go build -o casbin-server
FROM alpine:latest as STANDARD
WORKDIR /app
COPY --from=BACK /go/src/casbin-server /app/
ENTRYPOINT ./casbin-server
EXPOSE 50051