Skip to content

Commit 87dedfd

Browse files
authored
Merge pull request #4 from LBT-CNRS/feature/enhancement/docker-port-standardization
Feature/enhancement/docker port standardization
2 parents f570964 + 489d762 commit 87dedfd

File tree

7 files changed

+95
-37
lines changed

7 files changed

+95
-37
lines changed

doc/User_Manual.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,20 +113,22 @@ We advice you to try BioSpring with MDDriver and VMD to understand how this inte
113113

114114
To run BioSpring with VMD and MDDriver, start by launching the BioSpring tools with these MDDriver parameters.
115115

116-
biospring -c model.nc -s param.msp --wait --port 3000 --log model.log
116+
biospring -c model.nc -s param.msp --wait --port 8888 --log model.log
117117

118118
Or run the Docker image:
119119

120-
docker run --rm -p 3000:3000 --init -v ./:/data ghcr.io/lbt-cnrs/biospring \
121-
biospring -s model.nc -c param.msp --wait --port 3000
120+
docker run --rm -p 8888:8888 --init -v ./:/data ghcr.io/lbt-cnrs/biospring \
121+
biospring -s model.nc -c param.msp --wait --port 8888
122122

123-
Use an alias for convenience:
123+
Or use an alias for convenience:
124124
You can simplify the command by creating an alias and run the image with a shorter command:
125125

126-
alias biospring-run='docker run --rm -p 3000:3000 --init -v ./:/data ghcr.io/lbt-cnrs/biospring biospring'
126+
alias biospring-run='docker run --rm -p 8888:8888 --init -v ./:/data ghcr.io/lbt-cnrs/biospring biospring'
127127

128-
biospring-run -s model.nc -c param.msp --wait --port 3000
128+
biospring-run -s model.nc -c param.msp --wait --port 8888
129129

130+
Or reuse the Makefile in the example directory:
131+
Copy the file `example/base.mk` and some of other Makefile in example subdir as template for your own system (see README in example directory for usage)
130132

131133
#### Lauching VMD
132134
Start the VMD program (double click on its icon or launch from the command line).

example/README.md

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,52 @@
1-
# Usage:
1+
# Usage
22

3-
## Step 1: Server side
4-
- `make prep`
5-
- `make expose_data`
3+
## Client and server on the same machine
4+
5+
- ```bash
6+
make prep
7+
make run
8+
```
9+
- Check the line in the shell and note the `HOSTNAME` and `PORT`:
10+
```bash
11+
MDDriver > Interactive MD bind to /[HOSTNAME]/[PORT]
12+
```
613

7-
## Step 2: Client side
8-
- `make get_data`
14+
- In VMD: open `model.pdb`
15+
- In UnityMol: open `model.nc` or `model.pdb`
16+
- Connect to the server using the `HOSTNAME` and `PORT`
17+
- CTRL + C to stop the server running the simulation
18+
- ```bash
19+
make clean
20+
```
21+
22+
## Client and server on different machines
23+
24+
- Step 1: Server side ⚙️
25+
26+
make prep
27+
make expose_data
28+
29+
30+
- Step 2: Client side 🖥️
31+
32+
make get_data
933

10-
## Step 3: Server side
11-
- CTRL + C to stop the server exposing the data
12-
- `make run` / `make run_now`
13-
- Check the line in the shell and note the `HOSTNAME` and `PORT`:
34+
- Step 3: Server side ⚙️
35+
- CTRL + C to stop the server exposing the data
36+
- ```bash
37+
make run
38+
```
39+
- Check the line in the shell and note the `HOSTNAME` and `PORT`:
1440
```bash
1541
MDDriver > Interactive MD bind to /[HOSTNAME]/[PORT]
1642
```
1743

18-
## Step 4: Client side
19-
- Open `model.nc` or `model.pdb` in VMD or UnityMol
20-
- Connect to the server using the `HOSTNAME` and `PORT`
44+
- Step 4: Client side 🖥️
45+
- In VMD: open `model.pdb`
46+
- In UnityMol: open `model.nc` or `model.pdb`
47+
- Connect to the server using the `HOSTNAME` and `PORT`
2148

22-
## Step 5: Server side
23-
- CTRL + C to stop the server running the simulation
24-
- `make clean`
49+
- Step 5: Server side ⚙️
50+
- CTRL + C to stop the server running the simulation
51+
- ```bash
52+
make clean

example/base.mk

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,46 @@ clean:
8787
# and restart biospring or tune certain parameters from UnityMol during
8888
# an interactive simulation (for example IMPALA scale or Input Force, or
8989
# even viscosity).
90-
run :
91-
@echo "Run BioSpring"
92-
docker run --network host --rm --init -v $(PWD):/data $(IMAGE) \
93-
$(BIOSPRING) -s $(NC) \
94-
-c $(MSP) \
95-
--wait --port 3000 \
96-
--sasa-classifier biospring
90+
run:
91+
@echo "Starting BioSpring in detached mode..."
92+
@CONTAINER_ID=$$(docker run -d --rm -p 8888:8888 --name biospring-container --init -v $(PWD):/data $(IMAGE) $(BIOSPRING) -s $(NC) -c $(MSP) --wait --port 8888 --sasa-classifier biospring); \
93+
if [ -z "$$CONTAINER_ID" ]; then \
94+
echo "$(RED)❌ Failed to start the container.$(RESET)"; \
95+
exit 1; \
96+
fi; \
97+
HOSTNAME=$$(hostname); \
98+
echo "$(GREEN)✅ BioSpring container started successfully!$(RESET)"; \
99+
echo ""; \
100+
echo "$(YELLOW)⚠️ Before continuing, please note that the BioSpring program is running now in idle mode within the container, waiting for a connection. By proceeding, we will reattach to the container and display BioSpring's logs in real-time. Afterward, you can use the following information to connect:$(RESET)"; \
101+
echo ""; \
102+
echo " - On the local machine: $(GREEN)localhost:8888$(RESET) or $(GREEN)127.0.0.1:8888$(RESET)"; \
103+
echo " - On the network: $(GREEN)$$HOSTNAME:8888$(RESET)"; \
104+
trap 'docker ps -q --filter "id=$$CONTAINER_ID" | grep -q . && docker stop $$CONTAINER_ID || true; \
105+
echo "$(YELLOW)⚠️ Program interrupted manually (SIGINT/SIGTERM).$(RESET)"; exit 130' INT TERM; \
106+
while true; do \
107+
read -p "🟢 Continue (c) or Kill the container (k)? " choice; \
108+
case $$choice in \
109+
[cC]) \
110+
echo "$(GREEN)Showing logs and attaching to the container...$(RESET)"; \
111+
docker logs -f $$CONTAINER_ID & \
112+
DOCKER_LOGS_PID=$$!; \
113+
docker attach $$CONTAINER_ID; \
114+
break;; \
115+
[kK]) \
116+
echo "$(RED)Killing the container...$(RESET)"; \
117+
if docker ps -q --filter "id=$$CONTAINER_ID" | grep -q .; then \
118+
docker stop $$CONTAINER_ID; \
119+
fi; \
120+
exit 0;; \
121+
*) \
122+
echo "$(YELLOW)Invalid input. Enter 'c' to continue or 'k' to kill.$(RESET)";; \
123+
esac; \
124+
done
97125

98126
# Run the BioSpring simulation without waiting for the connection
99127
run_now:
100128
@echo "Run BioSpring NOOOW !!!!"
101-
docker run --network host --rm --init -v $(PWD):/data $(IMAGE) \
129+
docker run -p 8888:8888 --rm --init -v $(PWD):/data $(IMAGE) \
102130
$(BIOSPRING) -s $(NC) \
103131
-c $(MSP) \
104132
--sasa-classifier biospring
@@ -111,7 +139,7 @@ expose_data:
111139
@echo "Host machine: $(GREEN)$(shell hostname)$(RESET)"
112140
@echo "On the client side, you can retrive the data with the following command:"
113141
@echo "\n $(GREEN)make get_data HOSTNAME=$(shell hostname)$(RESET)\n"
114-
@docker run --network host --rm --init -v $(PWD):/data $(IMAGE) python -m http.server 4000 --directory /data
142+
@docker run -p 4000:4000 --rm --init -v $(PWD):/data $(IMAGE) python -m http.server 4000 --directory /data
115143

116144
# Retrieve the data from the host machine
117145
get_data :
@@ -156,4 +184,4 @@ usage:
156184
@echo "Step 5: Server side"
157185
@echo " CTRL + C to stop the server running the simulation"
158186
@echo " make clean"
159-
@echo "------------------------------------------------------------------------------"
187+
@echo "------------------------------------------------------------------------------"

src/cli/biospring-cli.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ CommandLineArguments::CommandLineArguments(const std::string & name, const argpa
164164
.name_long("--port")
165165
.description("Listening and outcoming port for MDDriver.")
166166
.argument_type(argparse::ArgumentType::INTEGER)
167-
.default_value("3000");
167+
.default_value("8888");
168168

169169
argparse::Argument debug = argparse::Argument()
170170
.name_long("--debug")

src/cli/biospring-cli.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const std::string PROGRAM_VERSION = "biospring " + biospring::VERSION_STRING;
1717
struct MDDriverParameters
1818
{
1919
bool wait = true;
20-
unsigned port = 3000;
20+
unsigned port = 8888;
2121
unsigned debug = 0;
2222
std::string logpath = "";
2323
float forcescale = 1.0;

src/interactor/mddriver/InteractorMDDriver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ InteractorMDDriver::InteractorMDDriver()
2222
strcpy(_IMDlogfilename,"");
2323
_IMDlog = NULL;
2424
_IMDwait = 1;
25-
_IMDport = 3000;
25+
_IMDport = 8888;
2626
_IMDmode = 1; //server
2727
_IMDforcescale =1.0;
2828
_IMDenergies.tstep = 0.0;

src/viewer/biospring-viewer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void usage()
3737
#ifdef MDDRIVER_SUPPORT
3838
cout<<"\tMDDriver support MDDriver support is enabled : "<<endl;
3939
cout<<"\t\tMDDriver is a library which extends the IMD protocol used in VMD for simulation and visualisation coupling."<<endl;
40-
cout<<"\t\t[-port portnumber] (Listening and outcoming port for MDDriver with default = 3000)"<<endl;
40+
cout<<"\t\t[-port portnumber] (Listening and outcoming port for MDDriver with default = 8888)"<<endl;
4141
cout<<"\t\t[-wait 0 or 1] (Wait a connection before starting the simulation with default = 1 means wait)"<<endl;
4242
cout<<"\t\t[-debug 0, 1 or 2] (Debug level of the MDDriver simulation with default = 0 means no debug message)"<<endl;
4343
cout<<"\t\t[-log filename] (Filename for MDDriver debug messages with default = stdout)"<<endl;
@@ -54,7 +54,7 @@ int main(int argc, char ** argv)
5454
{
5555
bool openclok=true;
5656
#ifdef MDDRIVER_SUPPORT
57-
unsigned port=3000;
57+
unsigned port=8888;
5858
unsigned wait=1;
5959
unsigned debug=0;
6060
char logfilename[FILENAMEMAXSIZE]="";

0 commit comments

Comments
 (0)