Skip to content

Commit e0982f8

Browse files
committed
docker images optimization + docker-compose adjustment
1 parent 0383aa2 commit e0982f8

11 files changed

+160
-87
lines changed

docker-compose-config-a.yaml

+18-18
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ services:
148148
image: sv2-roles-builder-image
149149
labels:
150150
logging: "config-a"
151-
command: ["/bin/bash", "-c", "/usr/local/bin/monitor_and_apply_latency.sh 10.5.0.6 2 & exec ./target/release/pool_sv2 -c pool/config-examples/pool-config-a-docker-example.toml"]
151+
command: ["/bin/sh", "-c", "./monitor_and_apply_latency.sh 10.5.0.6 2 & exec ./pool_sv2 -c pool/config-examples/pool-config-a-docker-example.toml"]
152152
ports:
153153
- "34254:34254"
154154
container_name: sv2-pool
@@ -159,7 +159,7 @@ services:
159159
sv2-roles-builder:
160160
condition: service_started
161161
volumes:
162-
- ./custom-configs/sri-roles/config-a:/usr/src/stratum/roles/pool/config-examples/
162+
- ./custom-configs/sri-roles/config-a:/usr/local/bin/pool/config-examples/
163163
restart: unless-stopped
164164
networks:
165165
sv2-net:
@@ -173,9 +173,9 @@ services:
173173
logging: "config-a"
174174
command:
175175
[
176-
"/bin/bash",
176+
"/bin/sh",
177177
"-c",
178-
"/usr/local/bin/monitor_and_apply_latency.sh 10.5.0.6 2 & exec ./target/release/jd_server -c jd-server/config-examples/jds-config-a-docker-example.toml",
178+
"./monitor_and_apply_latency.sh 10.5.0.6 2 & exec ./jd_server -c jd-server/config-examples/jds-config-a-docker-example.toml",
179179
]
180180
ports:
181181
- "34264:34264"
@@ -187,7 +187,7 @@ services:
187187
sv2-roles-builder:
188188
condition: service_started
189189
volumes:
190-
- ./custom-configs/sri-roles/config-a:/usr/src/stratum/roles/jd-server/config-examples/
190+
- ./custom-configs/sri-roles/config-a:/usr/local/bin/jd-server/config-examples/
191191
restart: unless-stopped
192192
networks:
193193
sv2-net:
@@ -201,15 +201,15 @@ services:
201201
logging: "config-a"
202202
command:
203203
[
204-
"/bin/bash",
204+
"/bin/sh",
205205
"-c",
206-
"/usr/local/bin/monitor_and_apply_latency.sh 10.5.0.4 2 10.5.0.5 & exec ./target/release/jd_client -c jd-client/config-examples/jdc-config-a-docker-example.toml",
206+
"./monitor_and_apply_latency.sh 10.5.0.4 2 10.5.0.5 & exec ./jd_client -c jd-client/config-examples/jdc-config-a-docker-example.toml",
207207
]
208208
ports:
209209
- "34265:34265"
210210
container_name: sv2-jdc
211211
volumes:
212-
- ./custom-configs/sri-roles/config-a:/usr/src/stratum/roles/jd-client/config-examples/
212+
- ./custom-configs/sri-roles/config-a:/usr/local/bin/jd-client/config-examples/
213213
restart: unless-stopped
214214
depends_on:
215215
- jd-server
@@ -227,7 +227,7 @@ services:
227227
logging: "config-a"
228228
command:
229229
[
230-
"./target/release/translator_sv2",
230+
"./translator_sv2",
231231
"-c",
232232
"translator/config-examples/tproxy-config-a-docker-example.toml",
233233
]
@@ -237,7 +237,7 @@ services:
237237
depends_on:
238238
- sv2-jdc-translator-proxy
239239
volumes:
240-
- ./custom-configs/sri-roles/config-a:/usr/src/stratum/roles/translator/config-examples/
240+
- ./custom-configs/sri-roles/config-a:/usr/local/bin/translator/config-examples/
241241
restart: unless-stopped
242242
networks:
243243
sv2-net:
@@ -247,7 +247,7 @@ services:
247247
image: sv2-custom-proxy-builder-image
248248
labels:
249249
logging: "config-a"
250-
command: ["./target/release/sv2-custom-proxy"]
250+
command: ["./sv2-custom-proxy"]
251251
ports:
252252
- "34253:34254"
253253
- "34251:34251"
@@ -270,7 +270,7 @@ services:
270270
image: sv2-custom-proxy-builder-image
271271
labels:
272272
logging: "config-a"
273-
command: ["./target/release/sv2-custom-proxy"]
273+
command: ["./sv2-custom-proxy"]
274274
ports:
275275
- "8440:8440"
276276
- "5678:5678"
@@ -298,7 +298,7 @@ services:
298298
image: sv1-custom-proxy-builder-image
299299
labels:
300300
logging: "config-a"
301-
command: ["./target/release/sv1-custom-proxy"]
301+
command: ["./sv1-custom-proxy"]
302302
ports:
303303
- "34255:34255"
304304
- "5676:5676"
@@ -347,9 +347,9 @@ services:
347347
logging: "config-a"
348348
command:
349349
[
350-
"/bin/bash",
350+
"/bin/sh",
351351
"-c",
352-
"/usr/local/bin/monitor_and_apply_latency.sh 10.5.0.8 2 & exec ./target/release/sv1-custom-proxy",
352+
"./monitor_and_apply_latency.sh 10.5.0.8 2 & exec ./sv1-custom-proxy",
353353
]
354354
ports:
355355
- "3333:3333"
@@ -374,7 +374,7 @@ services:
374374
image: sv1-custom-proxy-builder-image
375375
labels:
376376
logging: "config-a"
377-
command: ["./target/release/sv1-custom-proxy"]
377+
command: ["./sv1-custom-proxy"]
378378
ports:
379379
- "48330:48330"
380380
- "4567:4567"
@@ -533,7 +533,7 @@ services:
533533

534534
pools-latency-calculator:
535535
image: pools-latency-calculator-builder-image
536-
command: ["./target/release/pools-latency-calculator"]
536+
command: ["./pools-latency-calculator"]
537537
ports:
538538
- "1234:1234"
539539
container_name: pools-latency-calculator
@@ -577,7 +577,7 @@ services:
577577

578578
log-server:
579579
image: log-server-builder-image
580-
command: ["./target/release/log-server"]
580+
command: ["./log-server"]
581581
volumes:
582582
- /var/run/docker.sock:/var/run/docker.sock
583583
ports:

docker-compose-config-c.yaml

+15-15
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ services:
5252

5353
pools-latency-calculator-builder:
5454
build:
55-
dockerfile: pools-latency-calculator.dockerfile
55+
dockerfile: ./pools-latency-calculator/Dockerfile
5656
container_name: pools-latency-calculator-builder
5757
image: pools-latency-calculator-builder-image
5858
command: echo "pools-latency-calculator build completed"
@@ -122,7 +122,7 @@ services:
122122
logging: "config-c"
123123
command:
124124
[
125-
"./target/release/pool_sv2",
125+
"./pool_sv2",
126126
"-c",
127127
"pool/config-examples/pool-config-c-docker-example.toml",
128128
]
@@ -133,7 +133,7 @@ services:
133133
- sv2-roles-builder
134134
- sv2-tp-pool-proxy
135135
volumes:
136-
- ./custom-configs/sri-roles/config-c:/usr/src/stratum/roles/pool/config-examples/
136+
- ./custom-configs/sri-roles/config-c:/usr/local/bin/pool/config-examples/
137137
restart: unless-stopped
138138
networks:
139139
sv2-net:
@@ -147,17 +147,17 @@ services:
147147
logging: "config-c"
148148
command:
149149
[
150-
"/bin/bash",
150+
"/bin/sh",
151151
"-c",
152-
"/usr/local/bin/monitor_and_apply_latency.sh 10.5.0.23 2 & exec ./target/release/translator_sv2 -c translator/config-examples/tproxy-config-c-docker-example.toml",
152+
"./monitor_and_apply_latency.sh 10.5.0.23 2 & exec ./translator_sv2 -c translator/config-examples/tproxy-config-c-docker-example.toml",
153153
]
154154
ports:
155155
- "34256:34256"
156156
container_name: sv2-translator
157157
depends_on:
158158
- sv2-pool-translator-proxy
159159
volumes:
160-
- ./custom-configs/sri-roles/config-c:/usr/src/stratum/roles/translator/config-examples/
160+
- ./custom-configs/sri-roles/config-c:/usr/local/bin/translator/config-examples/
161161
restart: unless-stopped
162162
networks:
163163
sv2-net:
@@ -171,9 +171,9 @@ services:
171171
logging: "config-c"
172172
command:
173173
[
174-
"/bin/bash",
174+
"/bin/sh",
175175
"-c",
176-
"/usr/local/bin/monitor_and_apply_latency.sh 10.5.0.4 2 -proxy-type=pool-translator & exec ./target/release/sv2-custom-proxy",
176+
"./monitor_and_apply_latency.sh 10.5.0.4 2 -proxy-type=pool-translator & exec ./sv2-custom-proxy",
177177
]
178178
ports:
179179
- "34253:34254"
@@ -199,7 +199,7 @@ services:
199199
image: sv2-custom-proxy-builder-image
200200
labels:
201201
logging: "config-c"
202-
command: ["./target/release/sv2-custom-proxy"]
202+
command: ["./sv2-custom-proxy"]
203203
ports:
204204
- "8441:8441"
205205
- "5678:5678"
@@ -227,7 +227,7 @@ services:
227227
image: sv1-custom-proxy-builder-image
228228
labels:
229229
logging: "config-c"
230-
command: ["./target/release/sv1-custom-proxy"]
230+
command: ["./sv1-custom-proxy"]
231231
ports:
232232
- "34255:34255"
233233
- "5676:5676"
@@ -276,9 +276,9 @@ services:
276276
logging: "config-c"
277277
command:
278278
[
279-
"/bin/bash",
279+
"/bin/sh",
280280
"-c",
281-
"/usr/local/bin/monitor_and_apply_latency.sh 10.5.0.8 2 & exec ./target/release/sv1-custom-proxy",
281+
"./monitor_and_apply_latency.sh 10.5.0.8 2 & exec ./sv1-custom-proxy",
282282
]
283283
ports:
284284
- "3333:3333"
@@ -303,7 +303,7 @@ services:
303303
image: sv1-custom-proxy-builder-image
304304
labels:
305305
logging: "config-c"
306-
command: ["./target/release/sv1-custom-proxy"]
306+
command: ["./sv1-custom-proxy"]
307307
ports:
308308
- "48330:48330"
309309
- "4567:4567"
@@ -463,7 +463,7 @@ services:
463463

464464
pools-latency-calculator:
465465
image: pools-latency-calculator-builder-image
466-
command: ["./target/release/pools-latency-calculator"]
466+
command: ["./pools-latency-calculator"]
467467
ports:
468468
- "1234:1234"
469469
container_name: pools-latency-calculator
@@ -506,7 +506,7 @@ services:
506506

507507
log-server:
508508
image: log-server-builder-image
509-
command: ["./target/release/log-server"]
509+
command: ["./log-server"]
510510
volumes:
511511
- /var/run/docker.sock:/var/run/docker.sock
512512
ports:

log-server/Dockerfile

+18-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
FROM rust:1.75 as builder
2-
WORKDIR usr/src/log-server
3-
COPY ./log-server .
1+
# Build stage
2+
FROM rust:1.75-alpine AS builder
3+
4+
WORKDIR /usr/src/log-server
5+
COPY . .
6+
7+
# Install necessary dependencies
8+
RUN apk add musl-dev pkgconfig libressl-dev
9+
10+
# Build the project in release mode
411
RUN cargo build --release
512

6-
FROM rust:1.75
7-
COPY --from=builder usr/src/log-server/ usr/src/log-server/
8-
RUN apt-get update && apt-get install -y --no-install-recommends \
9-
iproute2 \
10-
iputils-ping \
11-
iptables \
12-
curl
13-
WORKDIR /usr/src/log-server/
13+
# Final stage
14+
FROM alpine:latest
15+
16+
# Copy only the binary from the builder image
17+
COPY --from=builder /usr/src/log-server/target/release/log-server /usr/local/bin/log-server
18+
19+
# Set the working directory
20+
WORKDIR /usr/local/bin/

pools-latency-calculator.dockerfile

-9
This file was deleted.

pools-latency-calculator/Dockerfile

+27-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
1-
FROM rust:1.75 as builder
2-
WORKDIR usr/src/pools-latency-calculator
3-
COPY ./pools-latency-calculator/ .
1+
# Build stage
2+
FROM rust:1.75-alpine AS builder
3+
4+
WORKDIR /usr/src/pools-latency-calculator
5+
6+
# Install necessary dependencies for building
7+
RUN apk add --no-cache musl-dev pkgconfig libressl-dev
8+
9+
# Copy the source code into the container
10+
COPY pools-latency-calculator/ .
11+
12+
# Build the project in release mode
413
RUN cargo build --release
514

6-
FROM rust:1.75
7-
COPY --from=builder /usr/src/pools-latency-calculator/ /usr/src/pools-latency-calculator/
8-
WORKDIR /usr/src/pools-latency-calculator/
15+
# Final stage
16+
FROM alpine:latest
17+
18+
# Install necessary runtime dependencies
19+
RUN apk update && apk add --no-cache \
20+
iproute2 \
21+
iputils-ping \
22+
iptables \
23+
curl
24+
25+
# Copy the compiled binary from the builder stage
26+
COPY --from=builder /usr/src/pools-latency-calculator/target/release/pools-latency-calculator /usr/local/bin/pools-latency-calculator
27+
28+
# Set the working directory
29+
WORKDIR /usr/local/bin/

pools-latency-calculator/monitor_and_apply_latency.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/sh
22

33
if [ -z "$1" ] || [ -z "$2" ]; then
44
echo "Usage: $0 <TARGET_IP1> <DIVISOR> [TARGET_IP2] [-proxy-type=pool-translator]"

sv1-custom-proxy/Dockerfile

+23-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
1-
FROM rust:1.75 as builder
2-
WORKDIR usr/src/sv1-custom-proxy
1+
# Build stage
2+
FROM rust:1.75-alpine AS builder
3+
4+
WORKDIR /usr/src/sv1-custom-proxy
35
COPY ./sv1-custom-proxy .
6+
7+
# Install necessary dependencies for building
8+
RUN apk add musl-dev pkgconfig libressl-dev
9+
10+
# Build the project in release mode
411
RUN cargo build --release
512

6-
FROM rust:1.75
7-
COPY --from=builder usr/src/sv1-custom-proxy/ usr/src/sv1-custom-proxy/
8-
RUN apt-get update && apt-get install -y --no-install-recommends \
13+
# Final stage
14+
FROM alpine:latest
15+
16+
# Install necessary runtime dependencies
17+
RUN apk update && apk add --no-cache \
918
iproute2 \
1019
iputils-ping \
1120
iptables \
12-
curl
13-
WORKDIR /usr/src/sv1-custom-proxy/
21+
curl
22+
23+
# Copy the binary from the builder stage
24+
COPY --from=builder /usr/src/sv1-custom-proxy/target/release/sv1-custom-proxy /usr/local/bin/sv1-custom-proxy
25+
26+
# Set the working directory
27+
WORKDIR /usr/local/bin/
28+
29+
# Copy the script and make it executable
1430
COPY ./pools-latency-calculator/monitor_and_apply_latency.sh /usr/local/bin/monitor_and_apply_latency.sh
1531
RUN chmod +x /usr/local/bin/monitor_and_apply_latency.sh

0 commit comments

Comments
 (0)