Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker images optimization + docker-compose adjustment #62

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions docker-compose-config-a.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ services:
image: sv2-roles-builder-image
labels:
logging: "config-a"
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"]
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"]
ports:
- "34254:34254"
container_name: sv2-pool
Expand All @@ -159,7 +159,7 @@ services:
sv2-roles-builder:
condition: service_started
volumes:
- ./custom-configs/sri-roles/config-a:/usr/src/stratum/roles/pool/config-examples/
- ./custom-configs/sri-roles/config-a:/usr/local/bin/pool/config-examples/
restart: unless-stopped
networks:
sv2-net:
Expand All @@ -173,9 +173,9 @@ services:
logging: "config-a"
command:
[
"/bin/bash",
"/bin/sh",
"-c",
"/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",
"./monitor_and_apply_latency.sh 10.5.0.6 2 & exec ./jd_server -c jd-server/config-examples/jds-config-a-docker-example.toml",
]
ports:
- "34264:34264"
Expand All @@ -187,7 +187,7 @@ services:
sv2-roles-builder:
condition: service_started
volumes:
- ./custom-configs/sri-roles/config-a:/usr/src/stratum/roles/jd-server/config-examples/
- ./custom-configs/sri-roles/config-a:/usr/local/bin/jd-server/config-examples/
restart: unless-stopped
networks:
sv2-net:
Expand All @@ -201,15 +201,15 @@ services:
logging: "config-a"
command:
[
"/bin/bash",
"/bin/sh",
"-c",
"/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",
"./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",
]
ports:
- "34265:34265"
container_name: sv2-jdc
volumes:
- ./custom-configs/sri-roles/config-a:/usr/src/stratum/roles/jd-client/config-examples/
- ./custom-configs/sri-roles/config-a:/usr/local/bin/jd-client/config-examples/
restart: unless-stopped
depends_on:
- jd-server
Expand All @@ -227,7 +227,7 @@ services:
logging: "config-a"
command:
[
"./target/release/translator_sv2",
"./translator_sv2",
"-c",
"translator/config-examples/tproxy-config-a-docker-example.toml",
]
Expand All @@ -237,7 +237,7 @@ services:
depends_on:
- sv2-jdc-translator-proxy
volumes:
- ./custom-configs/sri-roles/config-a:/usr/src/stratum/roles/translator/config-examples/
- ./custom-configs/sri-roles/config-a:/usr/local/bin/translator/config-examples/
restart: unless-stopped
networks:
sv2-net:
Expand All @@ -247,7 +247,7 @@ services:
image: sv2-custom-proxy-builder-image
labels:
logging: "config-a"
command: ["./target/release/sv2-custom-proxy"]
command: ["./sv2-custom-proxy"]
ports:
- "34253:34254"
- "34251:34251"
Expand All @@ -270,7 +270,7 @@ services:
image: sv2-custom-proxy-builder-image
labels:
logging: "config-a"
command: ["./target/release/sv2-custom-proxy"]
command: ["./sv2-custom-proxy"]
ports:
- "8440:8440"
- "5678:5678"
Expand Down Expand Up @@ -298,7 +298,7 @@ services:
image: sv1-custom-proxy-builder-image
labels:
logging: "config-a"
command: ["./target/release/sv1-custom-proxy"]
command: ["./sv1-custom-proxy"]
ports:
- "34255:34255"
- "5676:5676"
Expand Down Expand Up @@ -347,9 +347,9 @@ services:
logging: "config-a"
command:
[
"/bin/bash",
"/bin/sh",
Shourya742 marked this conversation as resolved.
Show resolved Hide resolved
"-c",
"/usr/local/bin/monitor_and_apply_latency.sh 10.5.0.8 2 & exec ./target/release/sv1-custom-proxy",
"./monitor_and_apply_latency.sh 10.5.0.8 2 & exec ./sv1-custom-proxy",
]
ports:
- "3333:3333"
Expand All @@ -374,7 +374,7 @@ services:
image: sv1-custom-proxy-builder-image
labels:
logging: "config-a"
command: ["./target/release/sv1-custom-proxy"]
command: ["./sv1-custom-proxy"]
ports:
- "48330:48330"
- "4567:4567"
Expand Down Expand Up @@ -533,7 +533,7 @@ services:

pools-latency-calculator:
image: pools-latency-calculator-builder-image
command: ["./target/release/pools-latency-calculator"]
command: ["./pools-latency-calculator"]
ports:
- "1234:1234"
container_name: pools-latency-calculator
Expand Down Expand Up @@ -577,7 +577,7 @@ services:

log-server:
image: log-server-builder-image
command: ["./target/release/log-server"]
command: ["./log-server"]
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
Expand Down
30 changes: 15 additions & 15 deletions docker-compose-config-c.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ services:

pools-latency-calculator-builder:
build:
dockerfile: pools-latency-calculator.dockerfile
dockerfile: ./pools-latency-calculator/Dockerfile
container_name: pools-latency-calculator-builder
image: pools-latency-calculator-builder-image
command: echo "pools-latency-calculator build completed"
Expand Down Expand Up @@ -122,7 +122,7 @@ services:
logging: "config-c"
command:
[
"./target/release/pool_sv2",
"./pool_sv2",
"-c",
"pool/config-examples/pool-config-c-docker-example.toml",
]
Expand All @@ -133,7 +133,7 @@ services:
- sv2-roles-builder
- sv2-tp-pool-proxy
volumes:
- ./custom-configs/sri-roles/config-c:/usr/src/stratum/roles/pool/config-examples/
- ./custom-configs/sri-roles/config-c:/usr/local/bin/pool/config-examples/
restart: unless-stopped
networks:
sv2-net:
Expand All @@ -147,17 +147,17 @@ services:
logging: "config-c"
command:
[
"/bin/bash",
"/bin/sh",
"-c",
"/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",
"./monitor_and_apply_latency.sh 10.5.0.23 2 & exec ./translator_sv2 -c translator/config-examples/tproxy-config-c-docker-example.toml",
]
ports:
- "34256:34256"
container_name: sv2-translator
depends_on:
- sv2-pool-translator-proxy
volumes:
- ./custom-configs/sri-roles/config-c:/usr/src/stratum/roles/translator/config-examples/
- ./custom-configs/sri-roles/config-c:/usr/local/bin/translator/config-examples/
restart: unless-stopped
networks:
sv2-net:
Expand All @@ -171,9 +171,9 @@ services:
logging: "config-c"
command:
[
"/bin/bash",
"/bin/sh",
"-c",
"/usr/local/bin/monitor_and_apply_latency.sh 10.5.0.4 2 -proxy-type=pool-translator & exec ./target/release/sv2-custom-proxy",
"./monitor_and_apply_latency.sh 10.5.0.4 2 -proxy-type=pool-translator & exec ./sv2-custom-proxy",
]
ports:
- "34253:34254"
Expand All @@ -199,7 +199,7 @@ services:
image: sv2-custom-proxy-builder-image
labels:
logging: "config-c"
command: ["./target/release/sv2-custom-proxy"]
command: ["./sv2-custom-proxy"]
ports:
- "8441:8441"
- "5678:5678"
Expand Down Expand Up @@ -227,7 +227,7 @@ services:
image: sv1-custom-proxy-builder-image
labels:
logging: "config-c"
command: ["./target/release/sv1-custom-proxy"]
command: ["./sv1-custom-proxy"]
ports:
- "34255:34255"
- "5676:5676"
Expand Down Expand Up @@ -276,9 +276,9 @@ services:
logging: "config-c"
command:
[
"/bin/bash",
"/bin/sh",
"-c",
"/usr/local/bin/monitor_and_apply_latency.sh 10.5.0.8 2 & exec ./target/release/sv1-custom-proxy",
"./monitor_and_apply_latency.sh 10.5.0.8 2 & exec ./sv1-custom-proxy",
]
ports:
- "3333:3333"
Expand All @@ -303,7 +303,7 @@ services:
image: sv1-custom-proxy-builder-image
labels:
logging: "config-c"
command: ["./target/release/sv1-custom-proxy"]
command: ["./sv1-custom-proxy"]
ports:
- "48330:48330"
- "4567:4567"
Expand Down Expand Up @@ -463,7 +463,7 @@ services:

pools-latency-calculator:
image: pools-latency-calculator-builder-image
command: ["./target/release/pools-latency-calculator"]
command: ["./pools-latency-calculator"]
ports:
- "1234:1234"
container_name: pools-latency-calculator
Expand Down Expand Up @@ -506,7 +506,7 @@ services:

log-server:
image: log-server-builder-image
command: ["./target/release/log-server"]
command: ["./log-server"]
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
Expand Down
29 changes: 18 additions & 11 deletions log-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
FROM rust:1.75 as builder
WORKDIR usr/src/log-server
COPY ./log-server .
# Build stage
FROM rust:1.75-alpine AS builder

WORKDIR /usr/src/log-server
COPY . .

# Install necessary dependencies
RUN apk add musl-dev pkgconfig libressl-dev

# Build the project in release mode
RUN cargo build --release

FROM rust:1.75
COPY --from=builder usr/src/log-server/ usr/src/log-server/
RUN apt-get update && apt-get install -y --no-install-recommends \
iproute2 \
iputils-ping \
iptables \
curl
WORKDIR /usr/src/log-server/
# Final stage
FROM alpine:latest

# Copy only the binary from the builder image
COPY --from=builder /usr/src/log-server/target/release/log-server /usr/local/bin/log-server

# Set the working directory
WORKDIR /usr/local/bin/
9 changes: 0 additions & 9 deletions pools-latency-calculator.dockerfile

This file was deleted.

33 changes: 27 additions & 6 deletions pools-latency-calculator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
FROM rust:1.75 as builder
WORKDIR usr/src/pools-latency-calculator
COPY ./pools-latency-calculator/ .
# Build stage
FROM rust:1.75-alpine AS builder

WORKDIR /usr/src/pools-latency-calculator

# Install necessary dependencies for building
RUN apk add --no-cache musl-dev pkgconfig libressl-dev

# Copy the source code into the container
COPY pools-latency-calculator/ .

# Build the project in release mode
RUN cargo build --release

FROM rust:1.75
COPY --from=builder /usr/src/pools-latency-calculator/ /usr/src/pools-latency-calculator/
WORKDIR /usr/src/pools-latency-calculator/
# Final stage
FROM alpine:latest

# Install necessary runtime dependencies
RUN apk update && apk add --no-cache \
iproute2 \
iputils-ping \
iptables \
curl

# Copy the compiled binary from the builder stage
COPY --from=builder /usr/src/pools-latency-calculator/target/release/pools-latency-calculator /usr/local/bin/pools-latency-calculator

# Set the working directory
WORKDIR /usr/local/bin/
2 changes: 1 addition & 1 deletion pools-latency-calculator/monitor_and_apply_latency.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: $0 <TARGET_IP1> <DIVISOR> [TARGET_IP2] [-proxy-type=pool-translator]"
Expand Down
30 changes: 23 additions & 7 deletions sv1-custom-proxy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
FROM rust:1.75 as builder
WORKDIR usr/src/sv1-custom-proxy
# Build stage
FROM rust:1.75-alpine AS builder

WORKDIR /usr/src/sv1-custom-proxy
COPY ./sv1-custom-proxy .

# Install necessary dependencies for building
RUN apk add musl-dev pkgconfig libressl-dev

# Build the project in release mode
RUN cargo build --release

FROM rust:1.75
COPY --from=builder usr/src/sv1-custom-proxy/ usr/src/sv1-custom-proxy/
RUN apt-get update && apt-get install -y --no-install-recommends \
# Final stage
FROM alpine:latest

# Install necessary runtime dependencies
RUN apk update && apk add --no-cache \
iproute2 \
iputils-ping \
iptables \
curl
WORKDIR /usr/src/sv1-custom-proxy/
curl

# Copy the binary from the builder stage
COPY --from=builder /usr/src/sv1-custom-proxy/target/release/sv1-custom-proxy /usr/local/bin/sv1-custom-proxy

# Set the working directory
WORKDIR /usr/local/bin/

# Copy the script and make it executable
COPY ./pools-latency-calculator/monitor_and_apply_latency.sh /usr/local/bin/monitor_and_apply_latency.sh
RUN chmod +x /usr/local/bin/monitor_and_apply_latency.sh
Loading
Loading