docker ne s'installe pas dans le conteneur docker de test
This commit is contained in:
parent
278bcec45f
commit
d7d7b08c15
@ -2,6 +2,7 @@
|
|||||||
// Copyright (C) 2024 Jean-Cloud
|
// Copyright (C) 2024 Jean-Cloud
|
||||||
// GNU General Public License v3
|
// GNU General Public License v3
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
#include "DockerModule.h"
|
#include "DockerModule.h"
|
||||||
#include "BashManager.h"
|
#include "BashManager.h"
|
||||||
|
|
||||||
@ -19,19 +20,26 @@ int DockerModule::prepare()
|
|||||||
int DockerModule::deploy (string serviceUsername)
|
int DockerModule::deploy (string serviceUsername)
|
||||||
{
|
{
|
||||||
cout << "docker module deploy" << endl;
|
cout << "docker module deploy" << endl;
|
||||||
/*
|
//test if there is a docker-compose.yml or docker-compose.yaml
|
||||||
//test if there is a docker compose
|
string docker_compose="./services/"+serviceUsername+"/docker-compose.yml";
|
||||||
|
if(!(filesystem::exists(docker_compose))){
|
||||||
|
docker_compose="./services/"+serviceUsername+"/docker-compose.yaml";
|
||||||
|
if(!(filesystem::exists(docker_compose))){
|
||||||
|
cout << "No docker-compose for this service." << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
//pulling images
|
//pulling images
|
||||||
int pulling =BashManager::execute("docker-compose pull")==0;
|
int pulling =BashManager::execute("docker-compose pull")==0;
|
||||||
if(pulling==0){
|
if(pulling==0){
|
||||||
//starting service
|
//starting service
|
||||||
int starting=BashManager::execute("docker-compose up -d --remove-orphans");
|
int starting=BashManager::execute("docker-compose up -d --remove-orphans");
|
||||||
}else{
|
}else{
|
||||||
cerr << "Error in DockerModule deploying "<< serviceUsername << endl;
|
cerr << "Error in "<< name << "deploying "<< serviceUsername << endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int removeContainersCreatedByDockerCompose()
|
int removeContainersCreatedByDockerCompose()
|
||||||
@ -69,4 +77,4 @@ int DockerModule::remove (string serviceUsername)
|
|||||||
int DockerModule::clean()
|
int DockerModule::clean()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,5 @@ class DockerModule : public Module
|
|||||||
int deploy (string serviceUsername);
|
int deploy (string serviceUsername);
|
||||||
int remove(string serviceUsername);
|
int remove(string serviceUsername);
|
||||||
int clean ();
|
int clean ();
|
||||||
string name;
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
@ -1,4 +1,5 @@
|
|||||||
ECHO = @echo
|
ECHO = @echo
|
||||||
|
CP=@cp
|
||||||
GCC = g++
|
GCC = g++
|
||||||
RM = @rm -f
|
RM = @rm -f
|
||||||
CCFLAGS = -c -O3 -g -std=c++20 -pedantic -Wall
|
CCFLAGS = -c -O3 -g -std=c++20 -pedantic -Wall
|
||||||
@ -11,6 +12,7 @@ LIBRARIES = -lstdc++fs
|
|||||||
$(EXE) : $(OBJECTS)
|
$(EXE) : $(OBJECTS)
|
||||||
$(ECHO) "-Linking $(EXE)-"
|
$(ECHO) "-Linking $(EXE)-"
|
||||||
$(GCC) -o $@ $^ $(LIBRARIES)
|
$(GCC) -o $@ $^ $(LIBRARIES)
|
||||||
|
$(CP) $(EXE) ../testenv
|
||||||
|
|
||||||
$(BIN)/%.o:%.cpp
|
$(BIN)/%.o:%.cpp
|
||||||
$(ECHO) "-Compilation $<- "
|
$(ECHO) "-Compilation $<- "
|
||||||
|
@ -24,7 +24,7 @@ int isServiceOnServer(string serviceUsername)
|
|||||||
{
|
{
|
||||||
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" which is the notation for loopback in IpV6
|
||||||
cout << "service on server" << endl;
|
cout << "service on server" << endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ int deployService(string serviceUsername){
|
|||||||
for(Module * mod_ptr : modules){
|
for(Module * mod_ptr : modules){
|
||||||
int modResult = (*mod_ptr).deploy(serviceUsername);
|
int modResult = (*mod_ptr).deploy(serviceUsername);
|
||||||
if (modResult!=0){
|
if (modResult!=0){
|
||||||
cerr << "Error in module " << (*mod_ptr) << " when deploying " << serviceUsername << endl;
|
cerr << "Error in " << (*mod_ptr) << " when deploying " << serviceUsername << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,4 +1,21 @@
|
|||||||
FROM ubuntu:latest
|
FROM ubuntu:22.04
|
||||||
WORKDIR /usr/src/deployer_test
|
WORKDIR /usr/src/deployer_test
|
||||||
CMD ["bash"]
|
RUN mkdir -p /data/mounted && \
|
||||||
|
apt-get -y update && apt-get install -y \
|
||||||
|
ca-certificates \
|
||||||
|
curl \
|
||||||
|
gnupg \
|
||||||
|
lsb-release &&\
|
||||||
|
apt-get -y update &&\
|
||||||
|
apt-get -y install ca-certificates curl && \
|
||||||
|
install -m 0755 -d /etc/apt/keyrings && \
|
||||||
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc && \
|
||||||
|
chmod a+r /etc/apt/keyrings/docker.asc && \
|
||||||
|
echo \
|
||||||
|
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
|
||||||
|
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
|
||||||
|
tee /etc/apt/sources.list.d/docker.list > /dev/null && \
|
||||||
|
apt-get -y update && \
|
||||||
|
apt-get -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
||||||
|
CMD ["sh"]
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
deployer_test:
|
deployer_test:
|
||||||
image: "ubuntu:latest"
|
image: "ubuntu:22.04"
|
||||||
build: .
|
build: .
|
||||||
container_name: deployer_test_container
|
container_name: deployer_test_container
|
||||||
volumes:
|
volumes:
|
||||||
|
1
testenv/services/test.sh8s.sh/.env
Normal file
1
testenv/services/test.sh8s.sh/.env
Normal file
@ -0,0 +1 @@
|
|||||||
|
GIT_SOURCE_REPO=https://git.jean-cloud.net/adrian/velov
|
3
testenv/services/test.sh8s.sh/deploy_user.sh
Executable file
3
testenv/services/test.sh8s.sh/deploy_user.sh
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
git_update.sh -r -d "$HTTP_DIR" "$GIT_SOURCE_REPO"
|
22
testenv/services/test.sh8s.sh/docker-compose.yml
Executable file
22
testenv/services/test.sh8s.sh/docker-compose.yml
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
version: '3'
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
image: php:7.2-fpm-alpine
|
||||||
|
volumes:
|
||||||
|
- $HTTP_DIR:/usr/src/app
|
||||||
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
|
ipv4_address: $NET.100
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpus: '0.50'
|
||||||
|
memory: 100M
|
||||||
|
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
|
ipam:
|
||||||
|
config:
|
||||||
|
- subnet: $NET.0/24
|
||||||
|
|
25
testenv/services/test.sh8s.sh/nginx_server.conf
Normal file → Executable file
25
testenv/services/test.sh8s.sh/nginx_server.conf
Normal file → Executable file
@ -0,0 +1,25 @@
|
|||||||
|
server {
|
||||||
|
listen 443 ssl http2;
|
||||||
|
listen [::]:443 ssl http2;
|
||||||
|
ssl_certificate $JC_CERT/fullchain.pem;
|
||||||
|
ssl_certificate_key $JC_CERT/privkey.pem;
|
||||||
|
server_name velov.jean-cloud.net www.velov.jean-cloud.net;
|
||||||
|
root $HTTP_DIR;
|
||||||
|
|
||||||
|
index index.php;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ =404;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ \.php$ {
|
||||||
|
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||||
|
fastcgi_pass $NET.100:9000;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
include fastcgi_params;
|
||||||
|
fastcgi_param SCRIPT_FILENAME /usr/src/app/$fastcgi_script_name;
|
||||||
|
#fastcgi_param SCRIPT_FILENAME /usr/src/app/index.php;
|
||||||
|
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,10 @@
|
|||||||
127.0.0.1 localhost
|
127.0.0.1 localhost
|
||||||
127.0.1.1 example.net example
|
127.0.1.1 example.net example
|
||||||
|
127.0.0.1 test.sh8s.sh
|
||||||
|
|
||||||
# The following lines are desirable for IPv6 capable hosts
|
# The following lines are desirable for IPv6 capable hosts
|
||||||
::1 localhost ip6-localhost ip6-loopback
|
::1 localhost ip6-localhost ip6-loopback
|
||||||
|
::1 test.sh8s.sh
|
||||||
ff02::1 ip6-allnodes
|
ff02::1 ip6-allnodes
|
||||||
ff02::2 ip6-allrouters
|
ff02::2 ip6-allrouters
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user