v1.0.3 - Simple PHP support! 🎉 (#15)
- Basic PHP support. - Cosmetic things here and there. - Fix publish directory option.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const static = require('./static')
|
||||
const nodejs = require('./nodejs')
|
||||
const php = require('./php')
|
||||
|
||||
module.exports = { static, nodejs }
|
||||
module.exports = { static, nodejs, php }
|
||||
|
||||
@@ -10,9 +10,13 @@ module.exports = async function (configuration) {
|
||||
WORKDIR /usr/src/app
|
||||
`
|
||||
if (configuration.build.command.build) {
|
||||
dockerFile += `COPY --from=${configuration.build.container.name}:${configuration.build.container.tag} /usr/src/app/${configuration.build.directory} /usr/src/app`
|
||||
dockerFile += `COPY --from=${configuration.build.container.name}:${configuration.build.container.tag} /usr/src/app/${configuration.publish.directory} /usr/src/app`
|
||||
} else {
|
||||
dockerFile += 'COPY . ./'
|
||||
if (configuration.publish.directory) {
|
||||
dockerFile += `COPY .${configuration.publish.directory} ./`
|
||||
} else {
|
||||
dockerFile += 'COPY ./'
|
||||
}
|
||||
}
|
||||
if (configuration.build.command.installation) {
|
||||
dockerFile += `
|
||||
|
||||
24
api/packs/php/index.js
Normal file
24
api/packs/php/index.js
Normal file
@@ -0,0 +1,24 @@
|
||||
const fs = require('fs').promises
|
||||
const { streamEvents, docker } = require('../../libs/docker')
|
||||
|
||||
module.exports = async function (configuration) {
|
||||
let dockerFile = `# production stage
|
||||
FROM php:apache
|
||||
`
|
||||
if (configuration.publish.directory) {
|
||||
dockerFile += `COPY ${configuration.publish.directory} /var/www/html`
|
||||
} else {
|
||||
dockerFile += 'COPY . /var/www/html'
|
||||
}
|
||||
|
||||
dockerFile += `
|
||||
EXPOSE 80
|
||||
CMD ["apache2-foreground"]`
|
||||
await fs.writeFile(`${configuration.general.workdir}/Dockerfile`, dockerFile)
|
||||
|
||||
const stream = await docker.engine.buildImage(
|
||||
{ src: ['.'], context: configuration.general.workdir },
|
||||
{ t: `${configuration.build.container.name}:${configuration.build.container.tag}` }
|
||||
)
|
||||
await streamEvents(stream, configuration)
|
||||
}
|
||||
@@ -10,9 +10,13 @@ module.exports = async function (configuration) {
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
`
|
||||
if (configuration.build.command.build) {
|
||||
dockerFile += `COPY --from=${configuration.build.container.name}:${configuration.build.container.tag} /usr/src/app/${configuration.build.directory} /usr/share/nginx/html`
|
||||
dockerFile += `COPY --from=${configuration.build.container.name}:${configuration.build.container.tag} /usr/src/app/${configuration.publish.directory} /usr/share/nginx/html`
|
||||
} else {
|
||||
dockerFile += 'COPY . /usr/share/nginx/html'
|
||||
if (configuration.publish.directory) {
|
||||
dockerFile += `COPY .${configuration.publish.directory} /usr/share/nginx/html`
|
||||
} else {
|
||||
dockerFile += 'COPY . /usr/share/nginx/html'
|
||||
}
|
||||
}
|
||||
|
||||
dockerFile += `
|
||||
|
||||
Reference in New Issue
Block a user