-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
172 lines (160 loc) · 5.03 KB
/
Dockerfile
File metadata and controls
172 lines (160 loc) · 5.03 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# Build base with dependencies
FROM golang:1.24-alpine AS base
WORKDIR /src
COPY go.mod go.sum ./
RUN GOPROXY=https://goproxy.cn GO111MODULE=on go mod download
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \
apk add --no-cache make git
# Define build arguments
ARG GIT_COMMIT=unknown
ARG SERVICE=all
# Admin service builder
FROM base AS admin-builder
ARG SERVICE
COPY . /src
WORKDIR /src/app/admin/admin
RUN if [ "$SERVICE" = "all" ] || [ "$SERVICE" = "admin" ]; then \
make build && \
echo "${GIT_COMMIT}" > /git_commit.txt; \
else \
echo "Skipping admin build" && \
mkdir -p /src/app/admin/admin/bin && \
touch /git_commit.txt; \
fi
# Contest service builder
FROM base AS contest-builder
ARG SERVICE
COPY . /src
WORKDIR /src/app/user/contest
RUN if [ "$SERVICE" = "all" ] || [ "$SERVICE" = "contest" ]; then \
make build && \
echo "${GIT_COMMIT}" > /git_commit.txt; \
else \
echo "Skipping contest build" && \
mkdir -p /src/app/user/contest/bin && \
touch /git_commit.txt; \
fi
# Auth service builder
FROM base AS auth-builder
ARG SERVICE
COPY . /src
WORKDIR /src/app/public/auth
RUN if [ "$SERVICE" = "all" ] || [ "$SERVICE" = "auth" ]; then \
make build && \
echo "${GIT_COMMIT}" > /git_commit.txt; \
else \
echo "Skipping auth build" && \
mkdir -p /src/app/public/auth/bin && \
touch /git_commit.txt; \
fi
# Gojudge service builder
FROM base AS gojudge-builder
ARG SERVICE
COPY . /src
WORKDIR /src/app/judge/gojudge
RUN if [ "$SERVICE" = "all" ] || [ "$SERVICE" = "gojudge" ]; then \
make build && \
echo "${GIT_COMMIT}" > /git_commit.txt; \
else \
echo "Skipping gojudge build" && \
mkdir -p /src/app/judge/gojudge/bin && \
touch /git_commit.txt; \
fi
# Freshcup service builder
FROM base AS freshcup-builder
ARG SERVICE
COPY . /src
WORKDIR /src/app/judge/freshcup
RUN if [ "$SERVICE" = "all" ] || [ "$SERVICE" = "freshcup" ]; then \
make build && \
echo "${GIT_COMMIT}" > /git_commit.txt; \
else \
echo "Skipping freshcup build" && \
mkdir -p /src/app/judge/freshcup/bin && \
touch /git_commit.txt; \
fi
# Admin service image
FROM alpine:edge AS admin
COPY --from=admin-builder /src/app/admin/admin/bin/admin /
COPY --from=admin-builder /git_commit.txt /git_commit.txt
EXPOSE 8000
EXPOSE 9000
VOLUME /data/conf
CMD ["/admin", "-conf", "/data/conf/config.yaml"]
# Contest service image
FROM alpine:edge AS contest
COPY --from=contest-builder /src/app/user/contest/bin/contest /
COPY --from=contest-builder /git_commit.txt /git_commit.txt
EXPOSE 8000
EXPOSE 9000
VOLUME /data/conf
CMD ["/contest", "-conf", "/data/conf/config.yaml"]
# Auth service image
FROM alpine:edge AS public-auth
COPY --from=auth-builder /src/app/public/auth/bin/auth /
COPY --from=auth-builder /git_commit.txt /git_commit.txt
EXPOSE 8000
EXPOSE 9000
VOLUME /data/conf
CMD ["/auth", "-conf", "/data/conf/config.yaml"]
# Freshcup service image
FROM alpine:edge AS freshcup-server
COPY --from=freshcup-builder /src/app/judge/freshcup/bin/freshcup /
COPY --from=freshcup-builder /git_commit.txt /git_commit.txt
VOLUME /data/conf
CMD ["/freshcup", "-conf", "/data/conf/config.yaml"]
# Go-judge builder
FROM golang:1.24-alpine AS go-judge-build
ARG SERVICE
WORKDIR /go/judge
RUN if [ "$SERVICE" = "all" ] || [ "$SERVICE" = "gojudge" ]; then \
apk update && apk add git bash && \
git clone https://ghfast.top/https://github.com/criyle/go-judge.git . && \
git checkout v1.11.3 && \
go mod download -x && \
go generate ./cmd/go-judge/version && \
CGO_ENABLE=0 go build -v -tags grpcnotrace,nomsgpack -o go-judge ./cmd/go-judge; \
else \
echo "Skipping go-judge build" && \
mkdir -p /go/judge && \
touch /go/judge/go-judge; \
fi
# Gojudge service image
FROM alpine:3.17 AS gojudge-server
USER root
ARG SERVICE
RUN if [ "$SERVICE" = "all" ] || [ "$SERVICE" = "gojudge" ]; then \
sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \
apk update && apk add --no-cache \
wget \
py3-pip \
gcc \
g++ \
musl-dev \
libtool \
rust \
ruby \
go=1.19.9-r0 \
#mono \
ghc \
openjdk17 \
#php7 \
#php7-cli \
#php7-common \
#php7-openssl \
#php7-mbstring \
#php7-json \
#php7-phar \
#php7-tokenizer \
#php7-xml \
#php7-curl \
#php7-fileinfo \
#fpc \
webkit2gtk-4.1; \
fi
COPY --from=go-judge-build /go/judge/go-judge /usr/bin/sandbox
RUN chmod +x /usr/bin/sandbox || true
COPY --from=gojudge-builder /src/app/judge/gojudge/bin/gojudge /
COPY --from=gojudge-builder /git_commit.txt /git_commit.txt
VOLUME /data/conf
CMD sh -c "/usr/bin/sandbox -enable-grpc -grpc-addr 127.0.0.1:5051 & /gojudge -conf /data/conf/config.yaml"