const path = require('path'); module.exports = { tags: async (tln) => [], options: async (tln, args) => { args .prefix('TLN_NEXUS') .option('image', { describe: 'Sonatype Nexus image', default: 'sonatype/nexus3', type: 'string' }) .option('port', { describe: 'Sonatype Nexus port mapping ext:int', default: ['8081:8081'], type: 'array' }) .option('volume', { describe: 'Path to location persistent storage', default: '/opt/nexus/nexus-data', type: 'string' }); }, env: async (tln, env) => {}, dotenvs: async (tln) => [], inherits: async (tln) => [], depends: async (tln) => [], steps: async (tln) => [ { id: 'up', filter: 'linux', desc: 'Up Nexus server', builder: (tln, script) => { if (script.env.TLN_NEXUS_IMAGE && script.env.TLN_NEXUS_PORT && script.env.TLN_NEXUS_VOLUME) { const image = script.env.TLN_NEXUS_IMAGE; const ports = script.env.TLN_NEXUS_PORT.map(p => `-p ${p}`).join(' '); const volume = script.env.TLN_NEXUS_VOLUME; if (image && volume) { const secret = path.join(volume, 'admin.password'); script.set([ `mkdir -p ${volume} && chown -R 200 ${volume}`, `docker run --rm -d ${ports} --name sonatype-nexus -v ${volume}:/nexus-data ${image}`, `echo One-time password can be found here: ${secret}`, `echo` ]); } } else { script.logger.error('Please define both --image and --volume'); } } }, { id: 'down', filter: 'linux', desc: 'Down Sonar server', builder: async (tln, script) => { script.set([ `docker stop sonatype-nexus` ]) } } ], components: async (tln) => [] }