2021-04-02 13:05:23 +00:00
|
|
|
const fs = require('fs').promises
|
|
|
|
|
const { streamEvents, docker } = require('../../libs/docker')
|
|
|
|
|
|
2021-04-04 12:57:42 +00:00
|
|
|
const publishPHPDocker = (configuration) => {
|
|
|
|
|
return [
|
|
|
|
|
'FROM php:apache',
|
|
|
|
|
'WORKDIR /usr/src/app',
|
|
|
|
|
`COPY .${configuration.build.directory} /var/www/html`,
|
|
|
|
|
'EXPOSE 80',
|
|
|
|
|
' CMD ["apache2-foreground"]'
|
|
|
|
|
].join('\n')
|
|
|
|
|
}
|
2021-04-02 13:05:23 +00:00
|
|
|
|
2021-04-04 12:57:42 +00:00
|
|
|
module.exports = async function (configuration) {
|
|
|
|
|
await fs.writeFile(`${configuration.general.workdir}/Dockerfile`, publishPHPDocker(configuration))
|
2021-04-02 13:05:23 +00:00
|
|
|
const stream = await docker.engine.buildImage(
|
|
|
|
|
{ src: ['.'], context: configuration.general.workdir },
|
|
|
|
|
{ t: `${configuration.build.container.name}:${configuration.build.container.tag}` }
|
|
|
|
|
)
|
|
|
|
|
await streamEvents(stream, configuration)
|
|
|
|
|
}
|