정민우

[Add] dockerfile Admin 추가

......@@ -170,7 +170,31 @@ exports.adminListDockerfile = async (req, res) => {
}
}
exports.adminDeleteDockerfile = async (req, res) => {
const requiredKey = ['id']
const required = checkRequiredExist(req.body, requiredKey)
if (required) {
logging('dockerfile', 'error', { code: 400, message: 'missingKey:${required}' }, req)
return sendError(res, 400, `missingKey:${required}`)
}
try {
const dockerfileId = req.body.id
let dockerfile = await Dockerfile.findByPk(dockerfileId)
if (!dockerfile) {
logging('dockerfile', 'error', { code: 404, message: 'NoDockerfileFound' }, req)
return sendError(res, 404, 'NoDockerfileFound')
}
await Dockerfile.destroy({
where: {
id: dockerfile.id
}
})
logging('dockerfile', 'delete', null, req)
return sendResponse(res, true, 201)
} catch (error) {
logging('dockerfile', 'error', { code: 500, message: error.message }, req)
return sendError(res, 500, error.message)
}
}
exports.adminListImage = async (req, res) => {
......
var Docker = require('dockerode')
var docker = new Docker({socketPath: '/var/run/docker.sock'})
docker.buildImage({
context: '../dockerfiles/sk2jsif92jajsdi1',
src: ['Dockerfile']
}, {t: 'testimage1337'}, function (err, response) {
console.log(response)
})