@hotwyl/init-docker-minimal-dev 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +0 -0
- package/bin/cli.js +82 -0
- package/package.json +27 -0
- package/template/.env +22 -0
- package/template/Dockerfile +73 -0
- package/template/README.md +532 -0
- package/template/apache/.gitkeep +1 -0
- package/template/config/apache/000-default.conf +39 -0
- package/template/config/mysql/init/01-init.sql +42 -0
- package/template/config/mysql/my.cnf +33 -0
- package/template/config/php/php.ini +95 -0
- package/template/docker-compose.yml +89 -0
- package/template/www/.htaccess +181 -0
- package/template/www/errors/403.html +48 -0
- package/template/www/errors/404.html +48 -0
- package/template/www/errors/500.html +48 -0
- package/template/www/index.php +501 -0
- package/template/www/phpinfo.php +10 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 hotwyl
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
Binary file
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
|
|
6
|
+
const args = process.argv.slice(2);
|
|
7
|
+
const force = args.includes("--force");
|
|
8
|
+
|
|
9
|
+
const targetDir = path.join(process.cwd(), "");
|
|
10
|
+
const templateDir = path.join(__dirname, "../template/");
|
|
11
|
+
|
|
12
|
+
function copyRecursive(src, dest) {
|
|
13
|
+
if (!fs.existsSync(dest)) {
|
|
14
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
18
|
+
|
|
19
|
+
for (const entry of entries) {
|
|
20
|
+
const srcPath = path.join(src, entry.name);
|
|
21
|
+
const destPath = path.join(dest, entry.name);
|
|
22
|
+
|
|
23
|
+
if (entry.isDirectory()) {
|
|
24
|
+
copyRecursive(srcPath, destPath);
|
|
25
|
+
} else {
|
|
26
|
+
if (!fs.existsSync(destPath) || force) {
|
|
27
|
+
fs.copyFileSync(srcPath, destPath);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function createReadmeHint() {
|
|
34
|
+
const readmePath = path.join(process.cwd(), "README-DOCKER.md");
|
|
35
|
+
|
|
36
|
+
if (!fs.existsSync(readmePath)) {
|
|
37
|
+
fs.writeFileSync(
|
|
38
|
+
readmePath,
|
|
39
|
+
`# Docker Minimal Dev Environment
|
|
40
|
+
|
|
41
|
+
Este projeto utiliza containers Docker para o ambiente de desenvolvimento.
|
|
42
|
+
|
|
43
|
+
## Como iniciar
|
|
44
|
+
|
|
45
|
+
1. Verifique se o Docker e o Docker Compose estão instalados
|
|
46
|
+
2. Execute o comando abaixo para construir e subir os containers:
|
|
47
|
+
\`\`\`bash
|
|
48
|
+
docker-compose up -d --build
|
|
49
|
+
\`\`\`
|
|
50
|
+
3. Verifique os logs:
|
|
51
|
+
\`\`\`bash
|
|
52
|
+
docker-compose logs -f
|
|
53
|
+
\`\`\`
|
|
54
|
+
|
|
55
|
+
## Estrutura principal gerada:
|
|
56
|
+
|
|
57
|
+
- \`docker-compose.yml\`: Orquestração
|
|
58
|
+
- \`Dockerfile\`: Configuração de build da imagem principal
|
|
59
|
+
- \`www/\`: Código-fonte e ponto de entrada da aplicação
|
|
60
|
+
- \`config/\`: Arquivos de configuração dos serviços (Apache, PHP, MySQL, etc.)
|
|
61
|
+
- \`logs/\`: Diretório de saída de logs do ambiente
|
|
62
|
+
`
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function run() {
|
|
68
|
+
const composePath = path.join(targetDir, "docker-compose.yml");
|
|
69
|
+
if (fs.existsSync(composePath) && !force) {
|
|
70
|
+
console.log("⚠️ Arquivos Docker já existem neste diretório.");
|
|
71
|
+
console.log("Use: npx init-docker-dev --force para sobrescrever.");
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
copyRecursive(templateDir, targetDir);
|
|
76
|
+
createReadmeHint();
|
|
77
|
+
|
|
78
|
+
console.log("✅ Estrutura Docker inicializada com sucesso!");
|
|
79
|
+
console.log("👉 Execute 'docker-compose up -d --build' para iniciar o ambiente.");
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
run();
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hotwyl/init-docker-minimal-dev",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
|
+
},
|
|
8
|
+
"description": "Automatize a configuração do seu ambiente Docker inicial de desenvolvimento (PHP/Apache/MySQL).",
|
|
9
|
+
"bin": {
|
|
10
|
+
"init-docker-minimal-dev": "./bin/cli.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"bin",
|
|
14
|
+
"template"
|
|
15
|
+
],
|
|
16
|
+
"keywords": [
|
|
17
|
+
"docker",
|
|
18
|
+
"docker-compose",
|
|
19
|
+
"php",
|
|
20
|
+
"apache",
|
|
21
|
+
"mysql",
|
|
22
|
+
"web-app",
|
|
23
|
+
"developer tools"
|
|
24
|
+
],
|
|
25
|
+
"author": "hotwyl",
|
|
26
|
+
"license": "MIT"
|
|
27
|
+
}
|
package/template/.env
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# ============================================
|
|
2
|
+
# MinimalDev - Configurações do Ambiente
|
|
3
|
+
# ============================================
|
|
4
|
+
|
|
5
|
+
# Nome do Projeto
|
|
6
|
+
PROJECT_NAME=minimaldev
|
|
7
|
+
|
|
8
|
+
# ============================================
|
|
9
|
+
# MySQL
|
|
10
|
+
# ============================================
|
|
11
|
+
MYSQL_ROOT_PASSWORD=root
|
|
12
|
+
MYSQL_DATABASE=minimaldev
|
|
13
|
+
MYSQL_USER=developer
|
|
14
|
+
MYSQL_PASSWORD=developer123
|
|
15
|
+
|
|
16
|
+
# ============================================
|
|
17
|
+
# Portas dos Serviços
|
|
18
|
+
# ============================================
|
|
19
|
+
WEB_PORT=80
|
|
20
|
+
HTTPS_PORT=443
|
|
21
|
+
MYSQL_PORT=3306
|
|
22
|
+
PHPMYADMIN_PORT=8080
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Imagem base PHP 8 (Latest Current) com Apache
|
|
2
|
+
FROM php:8-apache
|
|
3
|
+
|
|
4
|
+
# Argumentos de build
|
|
5
|
+
ARG DEBIAN_FRONTEND=noninteractive
|
|
6
|
+
|
|
7
|
+
# Instalar dependências do sistema
|
|
8
|
+
RUN apt-get update && apt-get install -y \
|
|
9
|
+
git \
|
|
10
|
+
curl \
|
|
11
|
+
libpng-dev \
|
|
12
|
+
libonig-dev \
|
|
13
|
+
libxml2-dev \
|
|
14
|
+
libzip-dev \
|
|
15
|
+
libicu-dev \
|
|
16
|
+
libfreetype6-dev \
|
|
17
|
+
libjpeg62-turbo-dev \
|
|
18
|
+
libwebp-dev \
|
|
19
|
+
libxpm-dev \
|
|
20
|
+
zip \
|
|
21
|
+
unzip \
|
|
22
|
+
nano \
|
|
23
|
+
vim \
|
|
24
|
+
htop \
|
|
25
|
+
&& apt-get clean \
|
|
26
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
27
|
+
|
|
28
|
+
# Instalar extensões PHP
|
|
29
|
+
RUN docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp --with-xpm \
|
|
30
|
+
&& docker-php-ext-install -j$(nproc) \
|
|
31
|
+
pdo \
|
|
32
|
+
pdo_mysql \
|
|
33
|
+
mysqli \
|
|
34
|
+
mbstring \
|
|
35
|
+
exif \
|
|
36
|
+
pcntl \
|
|
37
|
+
bcmath \
|
|
38
|
+
gd \
|
|
39
|
+
zip \
|
|
40
|
+
intl \
|
|
41
|
+
opcache \
|
|
42
|
+
soap \
|
|
43
|
+
xml
|
|
44
|
+
|
|
45
|
+
# Instalar extensões adicionais via PECL
|
|
46
|
+
RUN pecl install redis xdebug \
|
|
47
|
+
&& docker-php-ext-enable redis xdebug
|
|
48
|
+
|
|
49
|
+
# Instalar Composer
|
|
50
|
+
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
|
51
|
+
|
|
52
|
+
# Instalar Node.js e npm (última versão LTS)
|
|
53
|
+
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \
|
|
54
|
+
&& apt-get install -y nodejs \
|
|
55
|
+
&& npm install -g npm@latest \
|
|
56
|
+
&& apt-get clean \
|
|
57
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
58
|
+
|
|
59
|
+
# Habilitar módulos do Apache
|
|
60
|
+
RUN a2enmod rewrite headers ssl expires deflate
|
|
61
|
+
|
|
62
|
+
# Configurar diretório de trabalho
|
|
63
|
+
WORKDIR /var/www/html
|
|
64
|
+
|
|
65
|
+
# Ajustar permissões
|
|
66
|
+
RUN chown -R www-data:www-data /var/www/html \
|
|
67
|
+
&& chmod -R 755 /var/www/html
|
|
68
|
+
|
|
69
|
+
# Expor portas
|
|
70
|
+
EXPOSE 80 443
|
|
71
|
+
|
|
72
|
+
# Comando de inicialização
|
|
73
|
+
CMD ["apache2-foreground"]
|