This commit is contained in:
Zheyuan Wu
2026-02-04 14:01:52 -06:00
parent 9f6fba4fc1
commit 8260b1962a
19 changed files with 674 additions and 144 deletions

View File

@@ -1,27 +1,21 @@
services:
server:
image: gcc:13
image: debian:bookworm-slim
container_name: hw1-server
working_dir: /app
volumes:
- ./:/app:rw
env_file:
- .env
networks:
net-hw1:
ipv4_address: ${SERVER_IP}
command: >
bash -lc "
set -euo pipefail;
g++ -std=c++17 -O2 -Wall -Wextra -pedantic /app/server.cpp -o /tmp/server;
echo '[server] IP='$(hostname -i)' SERVER_IP='${SERVER_IP}' SERVER_PORT='${APP_PORT};
exec /tmp/server
"
volumes:
- ./bin/server:/usr/local/bin/server:ro
entrypoint: ["bash", "-lc", "apt-get update && apt-get install -y --no-install-recommends libstdc++6 iproute2; exec stdbuf -oL -eL /usr/local/bin/server"]
client:
image: gcc:13
image: debian:bookworm-slim
container_name: hw1-client
working_dir: /app
volumes:
- ./:/app:rw
env_file:
- .env
networks:
@@ -31,13 +25,9 @@ services:
- server
stdin_open: true
tty: true
command: >
bash -lc "
set -euo pipefail;
g++ -std=c++17 -O2 -Wall -Wextra -pedantic /app/client.cpp -o /tmp/client;
echo '[client] IP='$(hostname -i)' CLIENT_IP='${CLIENT_IP}' SERVER_IP='${SERVER_IP}' APP_PORT='${APP_PORT};
exec /tmp/client
"
volumes:
- ./bin/client:/usr/local/bin/client:ro
entrypoint: ["bash", "-lc", "apt-get update && apt-get install -y --no-install-recommends libstdc++6 iproute2; exec stdbuf -oL -eL /usr/local/bin/client"]
networks:
net-hw1: