Closed DavesCodeMusings closed 2 years ago
Node Lite image has git built in. It would not be difficult to clone files from a git repo into the container-central/compose directory. Kind of like this...
docker exec -it container-central bash cd /app/compose git clone http://git.mypi.home/docker-compose-files.git .
process.cwd() + '/compose'
#!/usr/bin/env node const { exec } = require('child_process'); const fs = require('fs'); const composeDir = '/home/pi/compose'; const gitUrl = 'http://git.home:3000/pi/docker-compose.git'; if (!fs.existsSync(composeDir)) { console.error(`No such directory: ${composeDir}`); } else { if (fs.existsSync(`${composeDir}/.git`)) { console.log('Pulling compose files.'); exec(`git pull`, { cwd: composeDir }, (err, stdout, stderr) => { if (err) { console.error('Error 1201'); } }); } else { console.log('Cloning compose files.'); exec(`git clone ${gitUrl} .`, { cwd: composeDir }, (err, stdout, stderr) => { if (err) { console.error('Error 1202'); } }); } }
Implemented, but requires manual git clone for initial set up. Could be improved with automatic git clone when directory is empty.
Added ability to configure git URL. Updated Git Integration document.
Node Lite image has git built in. It would not be difficult to clone files from a git repo into the container-central/compose directory. Kind of like this...
process.cwd() + '/compose'