-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
87 lines (56 loc) · 1.57 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# syntax=docker/dockerfile:1
# Compile Go binary
FROM golang:1.17-buster as gobuild
WORKDIR /app
RUN apt-get update
RUN apt install -y protobuf-compiler
RUN GO111MODULE=on \
go get google.golang.org/protobuf/cmd/protoc-gen-go \
google.golang.org/grpc/cmd/protoc-gen-go-grpc
COPY go.mod ./
COPY go.sum ./
RUN go mod download
COPY . .
# make ent is checked in, so no need to run here
RUN make proto
RUN make graphql
RUN CGO_ENABLED=0 GOOS=linux go build -v -o /webserver ./cmd/site/
RUN CGO_ENABLED=0 GOOS=linux go build -v -o /judge ./cmd/judge/
RUN CGO_ENABLED=0 GOOS=linux go build -v -o /scaler ./cmd/scaler/
# Compile frontend
FROM node:16 as jsbuild
ENV NODE_ENV=production
WORKDIR /app/frontend
COPY ["frontend/package.json", "frontend/yarn.lock", "./"]
RUN yarn
COPY frontend/ ./
COPY schema/schema.graphql ../schema/schema.graphql
RUN yarn relay
RUN yarn build
# Start webserver
FROM alpine AS webserver
RUN apk add --no-cache ca-certificates
WORKDIR /
COPY --from=gobuild /webserver /webserver
COPY --from=jsbuild /app/frontend/build/ /frontend/build/
EXPOSE 8080
RUN adduser -D nonroot
USER nonroot
ENTRYPOINT ["/webserver"]
# Start judge
FROM alpine AS judge
RUN apk add --no-cache ca-certificates
RUN apk update && apk add python3-dev gcc g++ libc-dev
WORKDIR /
COPY --from=gobuild /judge /judge
RUN adduser -D nonroot
USER nonroot
ENTRYPOINT ["/judge"]
# Start judge scaler
FROM alpine AS judge-scaler
RUN apk add --no-cache ca-certificates
WORKDIR /
COPY --from=gobuild /scaler /scaler
RUN adduser -D nonroot
USER nonroot
ENTRYPOINT ["/scaler"]