Skip to content

Commit 5bf30fa

Browse files
committed
chore: upgrade docs to docker compose v2
Signed-off-by: Seth Falco <[email protected]>
1 parent 46ecc67 commit 5bf30fa

File tree

5 files changed

+59
-60
lines changed

5 files changed

+59
-60
lines changed

.github/actions/run-tests/test_runner/db.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@ def __init__(self, user='tester', password='tester_pass', db='nc_test'):
55
self.user = user
66
self.password = password
77
self.db = db
8-
8+
99
def getUser(self):
1010
return self.user
1111

1212
def getDb(self):
1313
return self.db
14-
14+
1515
def getPassword(self):
1616
return self.password
17-
17+
1818
def callSQL(self, input, params = [], text=True, capture_output=True, stdin=None):
1919
cmd = [
20-
'docker-compose', 'exec', '-T', 'postgres', 'psql', '-U', self.user, self.db,
20+
'docker', 'compose', 'exec', '-T', 'postgres', 'psql', '-U', self.user, self.db,
2121
'-v', 'ON_ERROR_STOP=1'
2222
]
2323
return p.pr.run(cmd + params, text=text, input=input, capture_output=capture_output, stdin=stdin)
24-
24+
2525
def dumpDb(self, name):
2626
cmd = [
27-
'docker-compose', 'exec', '-T', 'postgres', 'pg_dump', '-U', self.user, self.db, '--clean', '--if-exists'
27+
'docker', 'compose', 'exec', '-T', 'postgres', 'pg_dump', '-U', self.user, self.db, '--clean', '--if-exists'
2828
]
2929
with open(name, 'w') as fp:
3030
p.pr.run(cmd, stdout=fp).check_returncode()
@@ -34,27 +34,27 @@ def __init__(self, user='tester', password='tester_pass', db='nc_test'):
3434
self.user = user
3535
self.password = password
3636
self.db = db
37-
37+
3838
def getUser(self):
3939
return self.user
40-
40+
4141
def getDb(self):
4242
return self.db
43-
43+
4444
def getPassword(self):
4545
return self.password
4646

4747
def callSQL(self, input, params = [], text=True, capture_output=True, stdin=None):
4848
cmd = [
49-
'docker-compose', 'exec', '-T', 'mysql', 'mysql', '-u', self.user,
49+
'docker', 'compose', 'exec', '-T', 'mysql', 'mysql', '-u', self.user,
5050
'-p{pwd}'.format(pwd=self.password), self.db
5151
]
5252
# print('input', input)
5353
return p.pr.run(cmd + params, text=text, input=input, capture_output=capture_output, stdin=stdin)
54-
54+
5555
def dumpDb(self, name):
5656
cmd = [
57-
'docker-compose', 'exec', '-T', 'mysql', 'mysqldump', '-u', self.user,
57+
'docker', 'compose', 'exec', '-T', 'mysql', 'mysqldump', '-u', self.user,
5858
'-p{pwd}'.format(pwd=self.password), '--add-drop-database', '--database', self.db
5959
]
6060
with open(name, 'w') as fp:

.github/actions/run-tests/test_runner/docker_management.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
def pullImages(args, quiet=True):
77
l.logger.printTask('Pulling pre-built images')
8-
cmd = ['docker-compose', 'pull']
8+
cmd = ['docker', 'compose', 'pull']
99
if quiet:
1010
cmd.append('--quiet')
1111
p.pr.run(cmd).check_returncode()
@@ -29,8 +29,8 @@ def runPull(localName, remoteName):
2929

3030
def buildImages(args, pull=True):
3131
l.logger.printTask('Building images')
32-
33-
cmd = ['docker-compose', 'build', '--force-rm']
32+
33+
cmd = ['docker', 'compose', 'build', '--force-rm']
3434
if pull:
3535
cmd.append('--pull')
3636
if args.ci:
@@ -41,7 +41,7 @@ def buildImages(args, pull=True):
4141

4242
p.pr.run(cmd).check_returncode()
4343

44-
p.pr.run(['docker-compose', 'build', '--pull', '--force-rm', 'mysql', 'postgres', 'www']).check_returncode()
44+
p.pr.run(['docker', 'compose', 'build', '--pull', '--force-rm', 'mysql', 'postgres', 'www']).check_returncode()
4545

4646
l.logger.printTask('Building images finished.')
4747

@@ -83,14 +83,14 @@ def handleDockerImages(args):
8383
if args.pull or args.create_images:
8484
pullImages(args, not args.verbose)
8585
t.toc('Pulling done')
86-
86+
8787
if args.create_images:
8888
pull = not args.pull_php_base_image
8989
buildImages(args, pull)
9090
t.toc('Building done')
91-
91+
9292
if args.push_images:
9393
pushImages(args)
94-
94+
9595
l.logger.endGroup()
9696
t.toc()

.github/actions/run-tests/test_runner/runner.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@ def __init__(self):
99
pass
1010

1111
def __buildRunCmd(self, args, subArgs):
12-
cmd = ['docker-compose', 'run', '--rm', 'dut']
12+
cmd = ['docker', 'compose', 'run', '--rm', 'dut']
1313

1414
if args.run_unit_tests:
1515
cmd.append('--run-unit-tests')
16-
16+
1717
if args.run_integration_tests:
1818
cmd.append('--run-integration-tests')
19-
19+
2020
if args.run_migration_tests:
2121
cmd.append('--run-migration-tests')
22-
22+
2323
if args.extract_code_coverage:
2424
cmd.append('--create-coverage-report')
25-
25+
2626
if args.install_composer_deps:
2727
cmd.append('--install-composer-deps')
28-
28+
2929
if args.build_npm:
3030
cmd.append('--build-npm')
3131

@@ -42,7 +42,7 @@ def __getDebugMode(self, args):
4242
modes.append('trace')
4343
if args.enable_profiling:
4444
modes.append('profile')
45-
45+
4646
return ",".join(modes)
4747

4848
def runTests(self, args, subArgs, db):
@@ -64,4 +64,3 @@ def runTests(self, args, subArgs, db):
6464
sp = p.pr.run(cmd, env=env)
6565

6666
return sp.returncode
67-

.github/actions/run-tests/test_runner/test_env.py

+31-31
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def __init__(self):
1313
def ensureFolderStructureExists(self):
1414
if not os.path.isdir('volumes'):
1515
os.mkdir('volumes')
16-
16+
1717
volumeFolders = (
1818
'nextcloud', 'data', 'cookbook', 'mysql', 'postgres', 'www',
1919
'dumps', 'coverage', 'output'
@@ -22,10 +22,10 @@ def ensureFolderStructureExists(self):
2222
p = os.path.join('volumes', f)
2323
if os.path.exists(p) and not os.path.isdir(p):
2424
raise Exception('Cannot create folder structure appropriately. Offending folder is %s' % p)
25-
25+
2626
if not os.path.exists(p):
2727
os.mkdir(os.path.join('volumes', f))
28-
28+
2929
def startDatabase(self, db):
3030
def startMysql():
3131
def checkRunning():
@@ -36,13 +36,13 @@ def checkRunning():
3636
if sp.stdout.strip() == 'healthy':
3737
return
3838
time.sleep(1)
39-
39+
4040
raise Exception('Starting of MySQL container failed.')
4141

4242
l.logger.printDebug('Starting MySQL database container')
43-
p.pr.run(['docker-compose', 'up', '-d', 'mysql']).check_returncode()
43+
p.pr.run(['docker', 'compose', 'up', '-d', 'mysql']).check_returncode()
4444
checkRunning()
45-
45+
4646
def startPostgresql():
4747
def checkRunning(pgCaller):
4848
for i in range(0,20):
@@ -51,10 +51,10 @@ def checkRunning(pgCaller):
5151
return
5252
time.sleep(1)
5353
raise Exception('Starting of PostgreSQL failed.')
54-
54+
5555
l.logger.printDebug('Starting PostgreSQL container')
56-
p.pr.run(['docker-compose', 'up', '-d', 'postgres']).check_returncode()
57-
56+
p.pr.run(['docker', 'compose', 'up', '-d', 'postgres']).check_returncode()
57+
5858
pgCaller = test_runner.db.PostgresConnector()
5959
checkRunning(pgCaller)
6060

@@ -74,7 +74,7 @@ def startSqlite():
7474
def stopDatabase(self, db):
7575
def stopContainer(name):
7676
l.logger.printTask('Stopping container {name}'.format(name=name))
77-
p.pr.run(['docker-compose', 'stop', name]).check_returncode()
77+
p.pr.run(['docker', 'compose', 'stop', name]).check_returncode()
7878

7979
def handleMySql():
8080
stopContainer('mysql')
@@ -91,10 +91,10 @@ def handleSqlite():
9191
'sqlite': handleSqlite,
9292
}
9393
mapping[db]()
94-
94+
9595
def stopContainers(self):
9696
l.logger.printTask('Stopping remaining containers')
97-
p.pr.run(['docker-compose', 'stop']).check_returncode()
97+
p.pr.run(['docker', 'compose', 'stop']).check_returncode()
9898

9999
def __dropEnvironment(self, db):
100100
def cleanMysql():
@@ -106,7 +106,7 @@ def cleanMysql():
106106
sqls = ['DROP TABLE {t};'.format(t=t) for t in tables if t != '']
107107
sql = "\n".join(sqls)
108108
caller.callSQL(sql, capture_output=True).check_returncode()
109-
109+
110110
def cleanPostgres():
111111
caller = test_runner.db.PostgresConnector()
112112
sql = '''DROP SCHEMA public CASCADE;
@@ -115,10 +115,10 @@ def cleanPostgres():
115115
GRANT ALL ON SCHEMA public TO PUBLIC;
116116
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO PUBLIC;'''.format(user=caller.getUser())
117117
caller.callSQL(sql, capture_output=True).check_returncode()
118-
118+
119119
def cleanSqlite():
120120
pass
121-
121+
122122
l.logger.printTask('Dropping the environment')
123123

124124
mappingDb = {
@@ -130,7 +130,7 @@ def cleanSqlite():
130130
l.logger.printTask('Cleaning the database')
131131
mappingDb[db]()
132132
l.logger.printTask('Database has been reset.')
133-
133+
134134
l.logger.printTask('Cleaning out the NC files.')
135135
p.pr.run('rm -rf volumes/{data,nextcloud}/{*,.??*}', shell=True).check_returncode()
136136
l.logger.printTask('Removal of files done.')
@@ -141,12 +141,12 @@ def cleanSqlite():
141141
def __runPhpScript(self, filename):
142142
with open(filename, 'r') as fp:
143143
data = fp.read()
144-
144+
145145
return p.pr.run(
146-
['docker-compose', 'run', '--rm', '-T', 'php'], input=data,
146+
['docker', 'compose', 'run', '--rm', '-T', 'php'], input=data,
147147
capture_output=True, text=True
148148
)
149-
149+
150150
def __setupServer(self, db, branch):
151151
l.logger.printTask('Starting installing the server')
152152

@@ -164,18 +164,18 @@ def __setupServer(self, db, branch):
164164
'git', 'submodule', 'update', '--init', '--depth', '1'
165165
], cwd='volumes/nextcloud').check_returncode()
166166
timer.toc('Checkout of git repos')
167-
167+
168168
l.logger.printTask('Create folder structure for correct permissions')
169169
p.pr.run(['mkdir', '-p', 'custom_apps/cookbook', 'data'], cwd='volumes/nextcloud').check_returncode()
170170

171171
def installGeneric(options):
172172
cmd = [
173-
'docker-compose', 'run', '--rm', '-T', 'occ', 'maintenance:install',
173+
'docker', 'compose', 'run', '--rm', '-T', 'occ', 'maintenance:install',
174174
'--admin-user', 'admin', '--admin-pass', 'admin'
175175
] + options
176176

177177
p.pr.run(cmd).check_returncode()
178-
178+
179179
def installWithMysql():
180180
caller = test_runner.db.MysqlConnector()
181181
installGeneric([
@@ -190,7 +190,7 @@ def installWithPgSQL():
190190
])
191191
def installWithSQLite():
192192
installGeneric(['--database', 'sqlite'])
193-
193+
194194
mappingDb = {
195195
'mysql': installWithMysql,
196196
'pgsql': installWithPgSQL,
@@ -218,7 +218,7 @@ def setupApp(self, installUntested):
218218
if installUntested:
219219
l.logger.printTask('Adding exception for app to be allowed as untested app')
220220
self.__runPhpScript('scripts/enable_app_install_script.php')
221-
221+
222222
l.logger.printTask('Synchronize the app code base to volume')
223223
excludes = ['/.git/', '/.github/actions/run-tests/volumes/', '/node_modules/']
224224
excludePairs = [['--exclude', x] for x in excludes]
@@ -232,7 +232,7 @@ def setupApp(self, installUntested):
232232

233233
l.logger.printTask('Activate the cookbook app in the server')
234234
p.pr.run(
235-
['docker-compose', 'run', '--rm', '-T', 'occ', 'app:enable', 'cookbook']
235+
['docker', 'compose', 'run', '--rm', '-T', 'occ', 'app:enable', 'cookbook']
236236
).check_returncode()
237237

238238
l.logger.printTask('Installation of cookbook finished')
@@ -245,19 +245,19 @@ def prepareBasicEnvironment(self, db, branch):
245245

246246
l.logger.startGroup('Preparing server environment')
247247
totalTimer.tic()
248-
248+
249249
timer.tic()
250250
self.startDatabase(db)
251251
timer.toc('Started database')
252-
252+
253253
timer.tic()
254254
self.__dropEnvironment(db)
255255
timer.toc('Environment cleaned')
256-
256+
257257
timer.tic()
258258
self.__setupServer(db, branch)
259259
timer.toc('Server installed')
260-
260+
261261
totalTimer.toc('Environment preparation')
262262
l.logger.endGroup()
263263

@@ -267,15 +267,15 @@ def __finishEnvironment(self, http_server):
267267
timer.tic()
268268

269269
l.logger.printTask('Start fpm and www containers')
270-
p.pr.run(['docker-compose', 'up', '-d', 'www', 'fpm']).check_returncode()
270+
p.pr.run(['docker', 'compose', 'up', '-d', 'www', 'fpm']).check_returncode()
271271

272272
httpMapper = {
273273
'apache': 'apache',
274274
'nginx': 'nginx',
275275
}
276276
l.logger.printTask('Start HTTP server')
277277
p.pr.run(
278-
['docker-compose', 'up', '-d', httpMapper[http_server]]
278+
['docker', 'compose', 'up', '-d', httpMapper[http_server]]
279279
).check_returncode()
280280

281281
l.logger.printTask('Started all containers')

docs/dev/contributing/setup.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ There are multiple methods to set up the Nextcloud development environment.
1414
Follow the instructions in this repository, noting that the default username/password are admin/admin.<br>
1515
Please pay attention to the warning from that repository:
1616
> :warning: DO NOT USE THIS IN PRODUCTION Various settings in this setup are considered insecure and default passwords and secrets are used all over the place
17-
1. There is also [this repository](https://github.com/christianlupus/nextcloud-docker-debug) that contains a configuration using docker-compose as well. This setup is tailored down to allow easy debugging and profiling of apps. The repository has an extensive documentation attached in form of a README file on how to setup.<br>
17+
1. There is also [this repository](https://github.com/christianlupus/nextcloud-docker-debug) that contains a configuration using Docker Compose as well. This setup is tailored down to allow easy debugging and profiling of apps. The repository has an extensive documentation attached in form of a README file on how to setup.<br>
1818
**This repository is only for development purposes. Do not use for productive usage!**
1919

2020
## Add Cookbook to your Nextcloud environment's apps directory
@@ -39,7 +39,7 @@ The easiest way might be to add a new line in this section after cloning [`nextc
3939
```
4040
You might need to adopt the path specification according to your local setup. Also note that docker-compose needs the correct indentation (spaces and no tabs!) to work well.
4141

42-
Be sure to recreate the containers after modifying `docker-compose.yml` using `docker-compose up -d`.
42+
Be sure to recreate the containers after modifying `docker-compose.yml` using `docker compose up -d`.
4343

4444
## Install PHP dependencies
4545

0 commit comments

Comments
 (0)