This repository has been archived by the owner on Jan 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes: - use `require.resolve` for loaders - various fixes to make docker run
- Loading branch information
Showing
18 changed files
with
3,162 additions
and
3,319 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,44 @@ | ||
const fs = require('fs') | ||
const path = require('path') | ||
const tar = require('tar-fs') | ||
const {Docker} = require('node-docker-api') | ||
|
||
const promisifyStream = (stream) => new Promise((resolve, reject) => { | ||
stream.on('data', (d) => console.log(d.toString())) | ||
stream.on('end', resolve) | ||
stream.on('error', (e) => { console.log(e.toString()); reject(e) }) | ||
}) | ||
|
||
module.exports = async clipped => { | ||
if (!clipped.config.name) throw new Error('Need to provide image name') | ||
|
||
clipped.hook('pre-build:docker') | ||
.add('build', async clipped => clipped.execHook('build')) | ||
.add('build-native', async clipped => clipped.execHook('build')) | ||
clipped.hook('build:docker') | ||
.add('default', async clipped => { | ||
await clipped.copy([ | ||
{src: clipped.config.dockerTemplate, dest: clipped.config.dist} | ||
]) | ||
.prepend('build-docker', async clipped => { | ||
try { | ||
await clipped.copy([ | ||
{src: clipped.config.dockerTemplate, dest: clipped.config.dist} | ||
]) | ||
|
||
let docker = new Docker({ socketPath: '/var/run/docker.sock' }) | ||
|
||
await clipped.docker.build( | ||
{ | ||
context: clipped.config.context, | ||
src: fs.readdirSync(clipped.config.dist) | ||
}, | ||
{ | ||
t: clipped.config.name | ||
} | ||
) | ||
// const stream = await tar.pack(clipped.config.dist) | ||
const files = fs.readdirSync(clipped.config.dist) | ||
console.log(`name is ${clipped.config.name}, ${files}`) | ||
await clipped.docker.build( | ||
{ | ||
context: clipped.config.dist, | ||
src: files | ||
}, | ||
{ | ||
t: clipped.config.name, | ||
// dockerfile: path.join(clipped.config.dist, 'Dockerfile') | ||
} | ||
).then(stream => promisifyStream(stream)) | ||
} catch (e) { | ||
console.error(e) | ||
} | ||
}) | ||
// console.log(Object.keys(clipped.hooks).map(hook => clipped.hooks[hook].tasks.map(task => task.callback.toString()))) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
{ | ||
"name": "clipped-preset-docker", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "", | ||
"main": "clipped.config.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC" | ||
"license": "ISC", | ||
"dependencies": { | ||
"node-docker-api": "^1.1.18", | ||
"tar-fs": "^1.16.0" | ||
} | ||
} |
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
Oops, something went wrong.