Skip to content

Commit

Permalink
bug fix in docker app with docker compose
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Dec 20, 2023
1 parent 0ee01e1 commit 9e2a94b
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions plogical/DockerSites.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def run(self):

except BaseException as msg:
logging.writeToFile(str(msg) + ' [Docker_Sites.run]')

def InstallDocker(self):

command = 'apt install docker-compose -y'
Expand Down Expand Up @@ -286,11 +287,22 @@ def DeployWPContainer(self):

### WriteConfig to compose-file

command = f"mkdir -p /home/docker/{self.data['finalURL']}"
ProcessUtilities.executioner(command)

TempCompose = f'/home/cyberpanel/{self.data["finalURL"]}-docker-compose.yml'


WriteToFile = open(self.data['ComposePath'], 'w')
WriteToFile.write(WPSite)
WriteToFile.close()

command = f"mv {TempCompose} {self.data['ComposePath']}"
ProcessUtilities.executioner(command)

command = f"chmod 600 {self.data['ComposePath']} && chown root:root {self.data['ComposePath']}"
ProcessUtilities.executioner(command, 'root', True)

####

command = f"docker-compose -f {self.data['ComposePath']} -p '{self.data['SiteName']}' up -d"
Expand Down Expand Up @@ -447,7 +459,7 @@ def SubmitDockersiteCreation(self):
MySQLRootPass = randomPassword.generate_pass()
f_data = {
"JobID": tempStatusPath,
"ComposePath": f"/home/{Domain}/docker-compose.yml",
"ComposePath": f"/home/docker/{Domain}/docker-compose.yml",
"MySQLPath": f'/home/{Domain}/public_html/sqldocker',
"MySQLRootPass": MySQLRootPass,
"MySQLDBName": dbname,
Expand Down Expand Up @@ -498,9 +510,9 @@ def Main():
args = parser.parse_args()

if args.function == "SetupProxy":
DockerSites.SetupProxy(args.port)
Docker_Sites.SetupProxy(args.port)
elif args.function == 'SetupHTAccess':
DockerSites.SetupHTAccess(args.port, args.htaccess)
Docker_Sites.SetupHTAccess(args.port, args.htaccess)
elif args.function == 'DeployWPDocker':
# Takes
# ComposePath, MySQLPath, MySQLRootPass, MySQLDBName, MySQLDBNUser, MySQLPassword, CPUsMySQL, MemoryMySQL,
Expand Down Expand Up @@ -530,7 +542,7 @@ def Main():
"externalApp": 'docke8463',
"docRoot": "/home/docker.cyberpanel.net"
}
ds = Docker_Sites(data)
ds = Docker_Sites('', data)
ds.DeployWPContainer()


Expand Down

0 comments on commit 9e2a94b

Please sign in to comment.