Created
December 12, 2020 04:50
-
-
Save eshnil2000/abe98a04a67c4f9cdc2042423fb8aac5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:latest | |
WORKDIR /usr/src/app | |
COPY test.js /usr/src/app | |
RUN apt update && apt install nano | |
RUN npm install --save-dev composefile | |
RUN npm install --save-dev docker-compose | |
const composefile = require('composefile'); | |
const dockercompose = require('docker-compose'); | |
//var docker = new Docker({socketPath: '/var/run/docker.sock'}); | |
var servicename="whoami3" ; | |
var options = '{'+ | |
'outputFolder:'+ '"'+ __dirname + '"'+ ','+ | |
'filename: "custom-docker-compose.yml",' + | |
'services: {' + | |
servicename+ ': {' + | |
'image: "traefik/whoami",'+ | |
'},'+ | |
'networks: ["web"],'+ | |
'labels: ["traefik.http.routers.whoami.rule=Host(`whoami.codenovator.net`)","traefik.http.routers.whoami.tls=true","traefik.http.routers.whoami.tls.certresolver=lets-encrypt","traefik.port=80"]'+ | |
'},'+ | |
'volumes: ["/var/run/docker.sock:/var/run/docker.sock"]'+ | |
'}'; | |
options = '{'+ | |
'"outputFolder":'+ '"'+ __dirname + '"'+ ','+ | |
'"filename": "custom-docker-compose.yml",' + | |
'"services": {' + | |
'"'+servicename+ '"' +': {' + | |
'"image": "traefik/whoami"'+ | |
'}'+'}'+'}'; | |
options= JSON.parse(options); | |
console.log(options); | |
/*options = { | |
outputFolder: __dirname, | |
filename: 'custom-docker-compose.yml', | |
services: { | |
nginx: { | |
image: 'nginx:latest', | |
ports: [ '8080:8080' ] | |
}, | |
app: { | |
build: '../app', | |
ports: [ '80:80' ] | |
} | |
}, | |
networks: { | |
outside: { | |
external: true | |
} | |
}, | |
volumes: { | |
data: { | |
external: true | |
} | |
} | |
}; | |
console.log(options);*/ | |
composefile(options, err => { console.log('done'); }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment