Skip to content
Closed
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
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
OPTS:= -it --network ex3_dev_containers_default ex3_dev_containers-gnd

up:
docker compose up -d --build

down:
docker compose down -v

gnd:
docker run $(OPTS) /app/gnd.py

gnd-sh:
docker run $(OPTS) /bin/sh

sub:
docker compose logs sub -f


.PHONY:
up down gnd gnd-sh sub
22 changes: 22 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: '3'

services:
gnd:
build:
context: mocks
dockerfile: gnd.Dockerfile
com:
build:
context: mocks
dockerfile: com.Dockerfile
stop_grace_period: 0.25s
fsw:
build:
context: mocks
dockerfile: fsw.Dockerfile
stop_grace_period: 0.25s
sub:
build:
context: mocks
dockerfile: sub.Dockerfile
stop_grace_period: 0.25s
11 changes: 11 additions & 0 deletions mocks/com.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from python:3.10-alpine

WORKDIR /app

EXPOSE 5000

COPY common.py .

COPY com.py .

CMD ["./com.py"]
7 changes: 3 additions & 4 deletions mocks/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
import sys
from typing import Callable

# TODO: Replace with host names
ADDRESSES: dict[str, tuple[str, int]] = {
"com": ('0.0.0.0', 5000),
"fsw": ('0.0.0.0', 5001),
"sub": ('0.0.0.0', 5002),
"com": ('com', 5000),
"fsw": ('fsw', 5001),
"sub": ('sub', 5002),
}


Expand Down
11 changes: 11 additions & 0 deletions mocks/fsw.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from python:3.10-alpine

WORKDIR /app

EXPOSE 5001

COPY common.py .

COPY fsw.py .

CMD ["./fsw.py"]
7 changes: 7 additions & 0 deletions mocks/gnd.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from python:3.10-alpine

WORKDIR /app

COPY common.py .

COPY gnd.py .
9 changes: 8 additions & 1 deletion mocks/gnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,11 @@ def send_message(msg: str):

if __name__ == "__main__":
while True:
send_message(input("> "))
try:
s = input("> ")
except EOFError:
break
try:
send_message(s)
except Exception as e:
print(e, file=sys.stderr)
11 changes: 11 additions & 0 deletions mocks/sub.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from python:3.10-alpine

WORKDIR /app

EXPOSE 5002

COPY common.py .

COPY sub.py .

CMD ["./sub.py"]