creation du conteneur de test

This commit is contained in:
eleonore12345 2024-08-07 18:16:21 +02:00
parent 667ee25133
commit 278bcec45f
6 changed files with 23 additions and 2 deletions

View File

@ -20,7 +20,6 @@ int DockerModule::deploy (string serviceUsername)
{ {
cout << "docker module deploy" << endl; cout << "docker module deploy" << endl;
/* /*
//test if there is a docker compose //test if there is a docker compose
//pulling images //pulling images
int pulling =BashManager::execute("docker-compose pull")==0; int pulling =BashManager::execute("docker-compose pull")==0;

Binary file not shown.

View File

@ -21,7 +21,7 @@ void help(char * argv0)
int isServiceOnServer(string serviceUsername) int isServiceOnServer(string serviceUsername)
//this method tests if a certain service is on the current server //this method tests if a certain service is on the current server
//it looks into the /etc/hosts file thanks to a pipe to a separate bash process //it looks into the /etc/hosts file thanks to a pipe to a separate bash process
{ {
string cmd ="getent hosts " +serviceUsername; string cmd ="getent hosts " +serviceUsername;
string result = BashManager::executeAndReadResult(cmd); string result = BashManager::executeAndReadResult(cmd);
if(result.find("::1")!=string::npos){ //if result contains "::1" if(result.find("::1")!=string::npos){ //if result contains "::1"
@ -30,6 +30,7 @@ int isServiceOnServer(string serviceUsername)
} }
cout << "service not on server" << endl; cout << "service not on server" << endl;
return 1; return 1;
return 0;
} }
int createUser(string serviceUsername){ int createUser(string serviceUsername){

4
testenv/Dockerfile Normal file
View File

@ -0,0 +1,4 @@
FROM ubuntu:latest
WORKDIR /usr/src/deployer_test
CMD ["bash"]

View File

@ -0,0 +1,10 @@
services:
deployer_test:
image: "ubuntu:latest"
build: .
container_name: deployer_test_container
volumes:
- .:/usr/src/deployer_test
- ./test_hosts:/etc/hosts
stdin_open: true
tty: true

7
testenv/test_hosts Normal file
View File

@ -0,0 +1,7 @@
127.0.0.1 localhost
127.0.1.1 example.net example
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters