├── .gitignore.git ├── .gitignore ├── env_laravel1 ├── app │ ├── sample │ │ ├── public │ │ │ ├── favicon.ico │ │ │ ├── robots.txt │ │ │ ├── index.php │ │ │ └── .htaccess │ │ ├── database │ │ │ ├── .gitignore │ │ │ ├── seeders │ │ │ │ └── DatabaseSeeder.php │ │ │ ├── migrations │ │ │ │ ├── 0001_01_01_000001_create_cache_table.php │ │ │ │ ├── 0001_01_01_000000_create_users_table.php │ │ │ │ └── 0001_01_01_000002_create_jobs_table.php │ │ │ └── factories │ │ │ │ └── UserFactory.php │ │ ├── bootstrap │ │ │ ├── cache │ │ │ │ └── .gitignore │ │ │ ├── providers.php │ │ │ └── app.php │ │ ├── resources │ │ │ ├── js │ │ │ │ ├── app.js │ │ │ │ └── bootstrap.js │ │ │ ├── css │ │ │ │ └── app.css │ │ │ └── views │ │ │ │ └── book │ │ │ │ └── index.blade.php │ │ ├── storage │ │ │ ├── logs │ │ │ │ └── .gitignore │ │ │ ├── app │ │ │ │ ├── private │ │ │ │ │ └── .gitignore │ │ │ │ ├── public │ │ │ │ │ └── .gitignore │ │ │ │ └── .gitignore │ │ │ └── framework │ │ │ │ ├── sessions │ │ │ │ └── .gitignore │ │ │ │ ├── testing │ │ │ │ └── .gitignore │ │ │ │ ├── views │ │ │ │ └── .gitignore │ │ │ │ ├── cache │ │ │ │ ├── data │ │ │ │ │ └── .gitignore │ │ │ │ └── .gitignore │ │ │ │ └── .gitignore │ │ ├── app │ │ │ ├── Http │ │ │ │ └── Controllers │ │ │ │ │ ├── Controller.php │ │ │ │ │ └── BookController.php │ │ │ ├── Models │ │ │ │ ├── Book.php │ │ │ │ └── User.php │ │ │ └── Providers │ │ │ │ └── AppServiceProvider.php │ │ ├── tests │ │ │ ├── TestCase.php │ │ │ ├── Unit │ │ │ │ └── ExampleTest.php │ │ │ └── Feature │ │ │ │ └── ExampleTest.php │ │ ├── .gitattributes │ │ ├── routes │ │ │ ├── console.php │ │ │ └── web.php │ │ ├── .editorconfig │ │ ├── .gitignore │ │ ├── vite.config.js │ │ ├── package.json │ │ ├── artisan │ │ ├── config │ │ │ ├── services.php │ │ │ ├── filesystems.php │ │ │ ├── cache.php │ │ │ ├── mail.php │ │ │ └── queue.php │ │ ├── phpunit.xml │ │ ├── .env.example │ │ ├── .env │ │ ├── composer.json │ │ └── README.md │ ├── php.ini │ ├── .vscode │ │ └── launch.json │ ├── .dockerignore │ └── Dockerfile ├── db │ ├── .dockerignore │ ├── Dockerfile │ ├── init │ │ ├── 01_create_tables.sql │ │ └── 02_insert_data.sql │ └── my.cnf ├── .devcontainer │ ├── .env │ ├── devcontainer.json │ └── compose.yml └── .gitignore ├── env_laravel_nginx_fpm ├── app │ ├── sample │ │ ├── public │ │ │ ├── favicon.ico │ │ │ ├── robots.txt │ │ │ ├── index.php │ │ │ └── .htaccess │ │ ├── database │ │ │ ├── .gitignore │ │ │ ├── seeders │ │ │ │ └── DatabaseSeeder.php │ │ │ ├── migrations │ │ │ │ ├── 0001_01_01_000001_create_cache_table.php │ │ │ │ ├── 0001_01_01_000000_create_users_table.php │ │ │ │ └── 0001_01_01_000002_create_jobs_table.php │ │ │ └── factories │ │ │ │ └── UserFactory.php │ │ ├── resources │ │ │ ├── js │ │ │ │ ├── app.js │ │ │ │ └── bootstrap.js │ │ │ ├── css │ │ │ │ └── app.css │ │ │ └── views │ │ │ │ └── book │ │ │ │ └── index.blade.php │ │ ├── storage │ │ │ ├── logs │ │ │ │ └── .gitignore │ │ │ ├── app │ │ │ │ ├── private │ │ │ │ │ └── .gitignore │ │ │ │ ├── public │ │ │ │ │ └── .gitignore │ │ │ │ └── .gitignore │ │ │ └── framework │ │ │ │ ├── sessions │ │ │ │ └── .gitignore │ │ │ │ ├── testing │ │ │ │ └── .gitignore │ │ │ │ ├── views │ │ │ │ └── .gitignore │ │ │ │ ├── cache │ │ │ │ ├── data │ │ │ │ │ └── .gitignore │ │ │ │ └── .gitignore │ │ │ │ └── .gitignore │ │ ├── bootstrap │ │ │ ├── cache │ │ │ │ └── .gitignore │ │ │ ├── providers.php │ │ │ └── app.php │ │ ├── app │ │ │ ├── Http │ │ │ │ └── Controllers │ │ │ │ │ ├── Controller.php │ │ │ │ │ └── BookController.php │ │ │ ├── Models │ │ │ │ ├── Book.php │ │ │ │ └── User.php │ │ │ └── Providers │ │ │ │ └── AppServiceProvider.php │ │ ├── tests │ │ │ ├── TestCase.php │ │ │ ├── Unit │ │ │ │ └── ExampleTest.php │ │ │ └── Feature │ │ │ │ └── ExampleTest.php │ │ ├── .gitattributes │ │ ├── routes │ │ │ ├── console.php │ │ │ └── web.php │ │ ├── .editorconfig │ │ ├── .gitignore │ │ ├── vite.config.js │ │ ├── package.json │ │ ├── artisan │ │ ├── config │ │ │ ├── services.php │ │ │ ├── filesystems.php │ │ │ ├── cache.php │ │ │ └── mail.php │ │ ├── phpunit.xml │ │ ├── .env.example │ │ ├── .env │ │ ├── composer.json │ │ └── README.md │ ├── php.ini │ ├── .vscode │ │ └── launch.json │ ├── .dockerignore │ └── Dockerfile ├── db │ ├── .dockerignore │ ├── Dockerfile │ ├── init │ │ ├── 01_create_tables.sql │ │ └── 02_insert_data.sql │ └── my.cnf ├── .devcontainer │ ├── .env │ ├── devcontainer.json │ └── compose.yml ├── .gitignore └── nginx │ └── default.conf ├── env_https ├── .gitignore ├── app │ ├── test.md │ ├── .vscode │ │ └── launch.json │ ├── templates │ │ └── index.html │ ├── main.go │ └── go.mod ├── .devcontainer │ ├── .env │ ├── db │ │ ├── Dockerfile │ │ └── my.cnf │ ├── devcontainer.json │ ├── app │ │ └── Dockerfile │ ├── web │ │ └── default.conf │ └── compose.yml └── db │ └── init │ ├── 01_create_tables.sql │ └── 02_insert_data.sql ├── ex02 ├── php.ini ├── src │ └── phpinfo.php └── Dockerfile ├── env_node1 ├── .devcontainer │ ├── .env │ ├── devcontainer.json │ └── compose.yml ├── app │ ├── .dockerignore │ ├── Dockerfile │ ├── .vscode │ │ └── launch.json │ └── sample │ │ ├── package.json │ │ ├── book_model.js │ │ ├── views │ │ └── index.ejs │ │ └── index.js ├── .gitignore └── db │ └── init │ └── 01.js ├── env_node_nginx ├── .devcontainer │ ├── .env │ ├── devcontainer.json │ └── compose.yml ├── app │ ├── .dockerignore │ ├── Dockerfile │ ├── .vscode │ │ └── launch.json │ └── sample │ │ ├── package.json │ │ ├── book_model.js │ │ ├── views │ │ └── index.ejs │ │ └── index.js ├── .gitignore ├── web │ └── nginx.conf └── db │ └── init │ └── 01.js ├── env_go_mysql ├── .devcontainer │ ├── .env │ ├── devcontainer.json │ └── compose.yml ├── db │ ├── Dockerfile │ ├── my.cnf │ ├── init │ │ ├── 01_create_tables.sql │ │ └── 02_insert_data.sql │ └── .dockerignore ├── app │ ├── templates │ │ ├── error.html │ │ └── index.html │ ├── .dockerignore │ ├── .vscode │ │ └── launch.json │ ├── Dockerfile │ ├── go.mod │ └── main.go └── .gitignore ├── env_go_mysql_nginx ├── .devcontainer │ ├── .env │ ├── devcontainer.json │ └── compose.yml ├── db │ ├── Dockerfile │ ├── my.cnf │ ├── init │ │ ├── 01_create_tables.sql │ │ └── 02_insert_data.sql │ └── .dockerignore ├── app │ ├── templates │ │ ├── error.html │ │ └── index.html │ ├── .dockerignore │ ├── .vscode │ │ └── launch.json │ ├── Dockerfile │ ├── go.mod │ └── main.go ├── .gitignore └── web │ └── default.conf ├── env_go_mysql_nginx_cert ├── .devcontainer │ ├── .env │ ├── devcontainer.json │ └── compose.yml ├── db │ ├── Dockerfile │ ├── my.cnf │ ├── init │ │ ├── 01_create_tables.sql │ │ └── 02_insert_data.sql │ └── .dockerignore ├── app │ ├── templates │ │ ├── error.html │ │ └── index.html │ ├── .dockerignore │ ├── .vscode │ │ └── launch.json │ ├── Dockerfile │ ├── go.mod │ └── main.go ├── .gitignore └── web │ └── default.conf ├── ex01 └── Dockerfile ├── ex04 ├── public │ └── index.php ├── composer.json └── Dockerfile ├── ex11 ├── .env ├── php │ ├── composer.json │ ├── src │ │ └── sample1.php │ └── Dockerfile └── compose.yml ├── ex21 ├── php │ ├── .dockerignore │ ├── composer.json │ ├── .vscode │ │ └── launch.json │ ├── Dockerfile │ └── public │ │ └── index.php └── .devcontainer │ ├── compose.yml │ └── devcontainer.json └── ex03 ├── Dockerfile └── src └── index.html /.gitignore.git: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite* 2 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite* 2 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/resources/js/app.js: -------------------------------------------------------------------------------- 1 | import './bootstrap'; 2 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /env_https/.gitignore: -------------------------------------------------------------------------------- 1 | /db/database 2 | localhost-key.pem 3 | localhost.pem 4 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/storage/app/private/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /env_laravel1/db/.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | .gitignore 3 | .DS_Store 4 | Thumbs.db -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/resources/js/app.js: -------------------------------------------------------------------------------- 1 | import './bootstrap'; 2 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/storage/framework/testing/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/storage/framework/cache/data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/storage/app/private/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !data/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/storage/framework/testing/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/db/.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | .gitignore 3 | .DS_Store 4 | Thumbs.db 5 | -------------------------------------------------------------------------------- /env_https/app/test.md: -------------------------------------------------------------------------------- 1 | # 指示: 2 | 以下の条件をもとに、レシピを作成してください 3 | 4 | # 条件: 5 | - サーモンを使う 6 | - キャンプ料理 -------------------------------------------------------------------------------- /env_laravel1/app/sample/storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !private/ 3 | !public/ 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/storage/framework/cache/data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !data/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !private/ 3 | !public/ 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /ex02/php.ini: -------------------------------------------------------------------------------- 1 | [Date] 2 | date.timezone = Asia/Tokyo 3 | 4 | [mbstring] 5 | mbstring.language = Japanese 6 | -------------------------------------------------------------------------------- /env_https/.devcontainer/.env: -------------------------------------------------------------------------------- 1 | MYSQL_ROOT_PASSWORD=root 2 | MYSQL_DATABASE=my 3 | MYSQL_USER=my 4 | MYSQL_PASSWORD=my -------------------------------------------------------------------------------- /env_laravel1/.devcontainer/.env: -------------------------------------------------------------------------------- 1 | MYSQL_ROOT_PASSWORD=root 2 | MYSQL_DATABASE=my 3 | MYSQL_USER=my 4 | MYSQL_PASSWORD=my -------------------------------------------------------------------------------- /env_laravel1/app/sample/bootstrap/providers.php: -------------------------------------------------------------------------------- 1 | ようこそ!PHP! 2 | ただいまの日時は、 です。 3 | 4 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/bootstrap/providers.php: -------------------------------------------------------------------------------- 1 | Hello from Multi-Stage Build (PHP)!

Served by container: " . htmlspecialchars($hostname) . "

"; 8 | 9 | ?> 10 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | 3 | *.blade.php diff=html 4 | *.css diff=css 5 | *.html diff=html 6 | *.md diff=markdown 7 | *.php diff=php 8 | 9 | /.github export-ignore 10 | CHANGELOG.md export-ignore 11 | .styleci.yml export-ignore 12 | -------------------------------------------------------------------------------- /env_go_mysql/db/init/01_create_tables.sql: -------------------------------------------------------------------------------- 1 | -- books テーブルを作成 2 | CREATE TABLE IF NOT EXISTS books ( 3 | id INT AUTO_INCREMENT NOT NULL PRIMARY KEY, 4 | title VARCHAR(255) NOT NULL, -- 長さを指定し、NOT NULL制約を追加 5 | insert_timestamp DATETIME DEFAULT CURRENT_TIMESTAMP -- デフォルト値を設定 6 | ); 7 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 8 | })->purpose('Display an inspiring quote'); 9 | -------------------------------------------------------------------------------- /ex11/.env: -------------------------------------------------------------------------------- 1 | # PostgreSQL Settings 2 | POSTGRES_USER=postgres 3 | POSTGRES_PASSWORD=postgres 4 | POSTGRES_DB=postgres 5 | 6 | # Database connection settings for PHP application 7 | DB_HOST=db 8 | DB_PORT=5432 9 | DB_DATABASE=postgres 10 | DB_USER=postgres 11 | DB_PASSWORD=postgres -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | 3 | *.blade.php diff=html 4 | *.css diff=css 5 | *.html diff=html 6 | *.md diff=markdown 7 | *.php diff=php 8 | 9 | /.github export-ignore 10 | CHANGELOG.md export-ignore 11 | .styleci.yml export-ignore 12 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 8 | })->purpose('Display an inspiring quote'); 9 | -------------------------------------------------------------------------------- /ex11/php/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ex11/app", 3 | "description": "PHP application connecting to PostgreSQL", 4 | "type": "project", 5 | "autoload": { 6 | "psr-4": { 7 | "App\\": "src/" 8 | } 9 | }, 10 | "require": {} 11 | } 12 | -------------------------------------------------------------------------------- /env_go_mysql_nginx/db/init/01_create_tables.sql: -------------------------------------------------------------------------------- 1 | -- books テーブルを作成 2 | CREATE TABLE IF NOT EXISTS books ( 3 | id INT AUTO_INCREMENT NOT NULL PRIMARY KEY, 4 | title VARCHAR(255) NOT NULL, -- 長さを指定し、NOT NULL制約を追加 5 | insert_timestamp DATETIME DEFAULT CURRENT_TIMESTAMP -- デフォルト値を設定 6 | ); 7 | -------------------------------------------------------------------------------- /env_go_mysql_nginx_cert/db/init/01_create_tables.sql: -------------------------------------------------------------------------------- 1 | -- books テーブルを作成 2 | CREATE TABLE IF NOT EXISTS books ( 3 | id INT AUTO_INCREMENT NOT NULL PRIMARY KEY, 4 | title VARCHAR(255) NOT NULL, -- 長さを指定し、NOT NULL制約を追加 5 | insert_timestamp DATETIME DEFAULT CURRENT_TIMESTAMP -- デフォルト値を設定 6 | ); 7 | -------------------------------------------------------------------------------- /ex04/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ex04/simple-app", 3 | "description": "A simple PHP web application example for multi-stage build.", 4 | "type": "project", 5 | "autoload": { 6 | "psr-4": { 7 | "App\\": "src/" 8 | } 9 | }, 10 | "require": {} 11 | } -------------------------------------------------------------------------------- /env_https/app/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Launch Package", 6 | "type": "go", 7 | "request": "launch", 8 | "mode": "auto", 9 | "program": "${fileDirname}" 10 | } 11 | ] 12 | } -------------------------------------------------------------------------------- /env_go_mysql/db/.dockerignore: -------------------------------------------------------------------------------- 1 | # Git files 2 | .git 3 | .gitignore 4 | 5 | # Initialization scripts (mounted via volume) 6 | init/ 7 | 8 | # Docker files 9 | Dockerfile 10 | .dockerignore 11 | 12 | # OS generated files 13 | .DS_Store 14 | Thumbs.db 15 | 16 | # MySQL config (copied in Dockerfile, so keep it) 17 | # !my.cnf 18 | -------------------------------------------------------------------------------- /env_go_mysql_nginx/db/.dockerignore: -------------------------------------------------------------------------------- 1 | # Git files 2 | .git 3 | .gitignore 4 | 5 | # Initialization scripts (mounted via volume) 6 | init/ 7 | 8 | # Docker files 9 | Dockerfile 10 | .dockerignore 11 | 12 | # OS generated files 13 | .DS_Store 14 | Thumbs.db 15 | 16 | # MySQL config (copied in Dockerfile, so keep it) 17 | # !my.cnf -------------------------------------------------------------------------------- /env_go_mysql_nginx/db/init/02_insert_data.sql: -------------------------------------------------------------------------------- 1 | -- 初期データの挿入 (存在しない場合のみ) 2 | INSERT INTO books (title) VALUES 3 | ('プログラミング言語C'), 4 | ('やさしいコンピューター科学'), 5 | ('ゲーデル、エッシャー、バッハ―あるいは不思議の環'), 6 | ('TeXブック コンピュータによる組版システム'), 7 | ('人月の神話 狼人間を撃つ銀の弾はない') 8 | ON DUPLICATE KEY UPDATE title=title; -- 重複を無視する (例: idが重複した場合など) 9 | -- もしくは、テーブルが空の場合のみ挿入するなどの工夫が必要 -------------------------------------------------------------------------------- /env_go_mysql_nginx_cert/db/.dockerignore: -------------------------------------------------------------------------------- 1 | # Git files 2 | .git 3 | .gitignore 4 | 5 | # Initialization scripts (mounted via volume) 6 | init/ 7 | 8 | # Docker files 9 | Dockerfile 10 | .dockerignore 11 | 12 | # OS generated files 13 | .DS_Store 14 | Thumbs.db 15 | 16 | # MySQL config (copied in Dockerfile, so keep it) 17 | # !my.cnf -------------------------------------------------------------------------------- /env_go_mysql_nginx_cert/db/init/02_insert_data.sql: -------------------------------------------------------------------------------- 1 | -- 初期データの挿入 (存在しない場合のみ) 2 | INSERT INTO books (title) VALUES 3 | ('プログラミング言語C'), 4 | ('やさしいコンピューター科学'), 5 | ('ゲーデル、エッシャー、バッハ―あるいは不思議の環'), 6 | ('TeXブック コンピュータによる組版システム'), 7 | ('人月の神話 狼人間を撃つ銀の弾はない') 8 | ON DUPLICATE KEY UPDATE title=title; -- 重複を無視する (例: idが重複した場合など) 9 | -- もしくは、テーブルが空の場合のみ挿入するなどの工夫が必要 -------------------------------------------------------------------------------- /env_node1/app/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:22-alpine 2 | 3 | # タイムゾーン設定 4 | RUN apk --update --no-cache add \ 5 | tzdata \ 6 | && cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime \ 7 | && apk del tzdata 8 | 9 | # 作業ディレクトリ設定 10 | WORKDIR /var/www/html 11 | 12 | # 非rootユーザーで実行 13 | USER node 14 | 15 | # アプリケーションが使用するポートを公開 16 | EXPOSE 3000 -------------------------------------------------------------------------------- /env_go_mysql/db/init/02_insert_data.sql: -------------------------------------------------------------------------------- 1 | -- 初期データの挿入 (存在しない場合のみ) 2 | INSERT INTO books (title) VALUES 3 | ('プログラミング言語C'), 4 | ('やさしいコンピューター科学'), 5 | ('ゲーデル、エッシャー、バッハ―あるいは不思議の環'), 6 | ('TeXブック コンピュータによる組版システム'), 7 | ('人月の神話 狼人間を撃つ銀の弾はない') 8 | ON DUPLICATE KEY UPDATE title=title; -- 重複を無視する (例: idが重複した場合など) 9 | -- もしくは、テーブルが空の場合のみ挿入するなどの工夫が必要 10 | -------------------------------------------------------------------------------- /env_node1/app/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "type": "node", 6 | "request": "launch", 7 | "name": "Launch Sample", 8 | "program": "${workspaceFolder}/sample/index.js", 9 | "cwd": "${workspaceFolder}/sample" 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /env_node_nginx/app/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:22-alpine 2 | 3 | # タイムゾーン設定 4 | RUN apk --update --no-cache add \ 5 | tzdata \ 6 | && cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime \ 7 | && apk del tzdata 8 | 9 | # 作業ディレクトリ設定 10 | WORKDIR /var/www/html 11 | 12 | # 非rootユーザーで実行 13 | USER node 14 | 15 | # アプリケーションが使用するポートを公開 (コンテナ内部) 16 | EXPOSE 3000 -------------------------------------------------------------------------------- /env_node1/.gitignore: -------------------------------------------------------------------------------- 1 | # プロジェクトルートの .gitignore 2 | # OS固有ファイル 3 | .DS_Store 4 | Thumbs.db 5 | 6 | # IDE/Editor設定 7 | # .vscode/ 8 | # !.vscode/launch.json 9 | 10 | # 依存関係 11 | /app/node_modules/ 12 | 13 | # ログファイル 14 | *.log 15 | npm-debug.log* 16 | 17 | # 環境変数ファイル 18 | # .env 19 | # /.devcontainer/.env 20 | 21 | # MongoDB データディレクトリ 22 | /db/database/ -------------------------------------------------------------------------------- /env_go_mysql/app/templates/error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | エラー 6 | 7 | 8 | 9 |

エラーが発生しました

10 |

{{ .message }}

11 |

トップに戻る

12 | 13 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/tests/Unit/ExampleTest.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /env_go_mysql_nginx/app/templates/error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | エラー 6 | 7 | 8 | 9 |

エラーが発生しました

10 |

{{ .message }}

11 |

トップに戻る

12 | 13 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/tests/Unit/ExampleTest.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /env_go_mysql_nginx_cert/app/templates/error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | エラー 6 | 7 | 8 | 9 |

エラーが発生しました

10 |

{{ .message }}

11 |

トップに戻る

12 | 13 | -------------------------------------------------------------------------------- /env_laravel1/app/php.ini: -------------------------------------------------------------------------------- 1 | [PHP] 2 | log_errors = On 3 | error_log = /dev/stderr 4 | date.timezone = Asia/Tokyo 5 | 6 | [mbstring] 7 | mbstring.language = Japanese 8 | 9 | [xdebug] 10 | xdebug.mode = debug 11 | xdebug.start_with_request = trigger 12 | xdebug.client_port = 9003 13 | xdebug.client_host = host.docker.internal 14 | xdebug.idekey = VSCODE 15 | xdebug.log_level = 0 -------------------------------------------------------------------------------- /env_laravel1/app/sample/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 4 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.{yml,yaml}] 15 | indent_size = 2 16 | 17 | [docker-compose.yml] 18 | indent_size = 4 19 | -------------------------------------------------------------------------------- /env_https/.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Https Nginx", 3 | "dockerComposeFile": "compose.yml", 4 | "service": "app", 5 | "workspaceFolder": "/var/www/html", 6 | "customizations": { 7 | "vscode": { 8 | "extensions": [ 9 | "golang.Go" 10 | ], 11 | "settings": { 12 | "editor.tabSize": 2 13 | } 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/php.ini: -------------------------------------------------------------------------------- 1 | [PHP] 2 | log_errors = On 3 | error_log = /dev/stderr 4 | date.timezone = Asia/Tokyo 5 | 6 | [mbstring] 7 | mbstring.language = Japanese 8 | 9 | [xdebug] 10 | xdebug.mode = debug 11 | xdebug.start_with_request = trigger 12 | xdebug.client_port = 9003 13 | xdebug.client_host = host.docker.internal 14 | xdebug.idekey = VSCODE 15 | xdebug.log_level = 0 -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 4 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.{yml,yaml}] 15 | indent_size = 2 16 | 17 | [docker-compose.yml] 18 | indent_size = 4 19 | -------------------------------------------------------------------------------- /env_https/db/init/02_insert_data.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO books VALUES(1, 'プログラミング言語C', current_timestamp); 2 | INSERT INTO books VALUES(2, 'やさしいコンピューター科学', current_timestamp); 3 | INSERT INTO books VALUES(3, 'ゲーデル、エッシャー、バッハ―あるいは不思議の環', current_timestamp); 4 | INSERT INTO books VALUES(4, 'TeXブック コンピュータによる組版システム', current_timestamp); 5 | INSERT INTO books VALUES(5, '人月の神話 狼人間を撃つ銀の弾はない', current_timestamp); 6 | -------------------------------------------------------------------------------- /env_node_nginx/app/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "type": "node", 6 | "request": "launch", 7 | "name": "Launch Sample", 8 | "program": "${workspaceFolder}/sample/index.js", // 起動するスクリプト 9 | "cwd": "${workspaceFolder}/sample", // 実行時のカレントディレクトリ 10 | // デバッグポートはVS Codeが自動的にフォワードするため、通常は設定不要 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /env_go_mysql/app/.dockerignore: -------------------------------------------------------------------------------- 1 | # Git files 2 | .git 3 | .gitignore 4 | 5 | # IDE/Editor specific 6 | # .vscode/ 7 | 8 | # Docker files 9 | Dockerfile 10 | .dockerignore 11 | 12 | # OS generated files 13 | .DS_Store 14 | Thumbs.db 15 | 16 | # Log files 17 | *.log 18 | 19 | # Go build artifacts (local builds) 20 | *.exe 21 | *.out 22 | app 23 | 24 | # Environment files (if present in this directory) 25 | # .env -------------------------------------------------------------------------------- /env_laravel1/app/sample/.gitignore: -------------------------------------------------------------------------------- 1 | /.phpunit.cache 2 | /node_modules 3 | /public/build 4 | /public/hot 5 | /public/storage 6 | /storage/*.key 7 | /storage/pail 8 | /vendor 9 | .env.backup 10 | .env.production 11 | .phpactor.json 12 | .phpunit.result.cache 13 | Homestead.json 14 | Homestead.yaml 15 | npm-debug.log 16 | yarn-error.log 17 | /auth.json 18 | /.fleet 19 | /.idea 20 | /.nova 21 | /.vscode 22 | /.zed 23 | -------------------------------------------------------------------------------- /ex02/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:8.3-apache 2 | 3 | # tzdataのインストール 4 | RUN apt-get update -qq \ 5 | && apt-get install -y --no-install-recommends tzdata \ 6 | && rm -rf /var/lib/apt/lists/* 7 | 8 | # タイムゾーンを設定する環境変数 9 | ENV TZ="Asia/Tokyo" 10 | 11 | # 作業ディレクトリを変更 12 | WORKDIR /usr/local/etc/php 13 | 14 | # ファイルのコピー 15 | COPY php.ini . 16 | 17 | # 一時変数の定義 18 | ARG wdir 19 | 20 | # 作業ディレクトリを変更 21 | WORKDIR $wdir 22 | -------------------------------------------------------------------------------- /env_go_mysql_nginx/app/.dockerignore: -------------------------------------------------------------------------------- 1 | # Git files 2 | .git 3 | .gitignore 4 | 5 | # IDE/Editor specific 6 | # .vscode/ 7 | 8 | # Docker files 9 | Dockerfile 10 | .dockerignore 11 | 12 | # OS generated files 13 | .DS_Store 14 | Thumbs.db 15 | 16 | # Log files 17 | *.log 18 | 19 | # Go build artifacts (local builds) 20 | *.exe 21 | *.out 22 | app 23 | 24 | # Environment files (if present in this directory) 25 | # .env -------------------------------------------------------------------------------- /env_go_mysql_nginx_cert/app/.dockerignore: -------------------------------------------------------------------------------- 1 | # Git files 2 | .git 3 | .gitignore 4 | 5 | # IDE/Editor specific 6 | # .vscode/ 7 | 8 | # Docker files 9 | Dockerfile 10 | .dockerignore 11 | 12 | # OS generated files 13 | .DS_Store 14 | Thumbs.db 15 | 16 | # Log files 17 | *.log 18 | 19 | # Go build artifacts (local builds) 20 | *.exe 21 | *.out 22 | app 23 | 24 | # Environment files (if present in this directory) 25 | # .env -------------------------------------------------------------------------------- /env_laravel1/app/sample/vite.config.js: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite'; 2 | import laravel from 'laravel-vite-plugin'; 3 | import tailwindcss from '@tailwindcss/vite'; 4 | 5 | export default defineConfig({ 6 | plugins: [ 7 | laravel({ 8 | input: ['resources/css/app.css', 'resources/js/app.js'], 9 | refresh: true, 10 | }), 11 | tailwindcss(), 12 | ], 13 | }); 14 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/.gitignore: -------------------------------------------------------------------------------- 1 | /.phpunit.cache 2 | /node_modules 3 | /public/build 4 | /public/hot 5 | /public/storage 6 | /storage/*.key 7 | /storage/pail 8 | /vendor 9 | .env.backup 10 | .env.production 11 | .phpactor.json 12 | .phpunit.result.cache 13 | Homestead.json 14 | Homestead.yaml 15 | npm-debug.log 16 | yarn-error.log 17 | /auth.json 18 | /.fleet 19 | /.idea 20 | /.nova 21 | /.vscode 22 | /.zed 23 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/vite.config.js: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite'; 2 | import laravel from 'laravel-vite-plugin'; 3 | import tailwindcss from '@tailwindcss/vite'; 4 | 5 | export default defineConfig({ 6 | plugins: [ 7 | laravel({ 8 | input: ['resources/css/app.css', 'resources/js/app.js'], 9 | refresh: true, 10 | }), 11 | tailwindcss(), 12 | ], 13 | }); 14 | -------------------------------------------------------------------------------- /env_https/.devcontainer/app/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.20-alpine 2 | 3 | # パッケージのインストール、タイムゾーン設定 4 | RUN apk --update --no-cache add \ 5 | tzdata \ 6 | && cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime \ 7 | && apk del tzdata 8 | 9 | # デバッグ用ツールのインストール 10 | RUN go install -v github.com/ramya-rao-a/go-outline@latest \ 11 | && go install -v golang.org/x/tools/gopls@latest \ 12 | && go install -v github.com/go-delve/delve/cmd/dlv@latest 13 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "type": "module", 4 | "scripts": { 5 | "build": "vite build", 6 | "dev": "vite" 7 | }, 8 | "devDependencies": { 9 | "@tailwindcss/vite": "^4.0.0", 10 | "axios": "^1.8.2", 11 | "concurrently": "^9.0.1", 12 | "laravel-vite-plugin": "^1.2.0", 13 | "tailwindcss": "^4.0.0", 14 | "vite": "^6.2.4" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /env_node_nginx/.gitignore: -------------------------------------------------------------------------------- 1 | # プロジェクトルートの .gitignore 2 | # OS固有ファイル 3 | .DS_Store 4 | Thumbs.db 5 | 6 | # IDE/Editor設定 7 | # .vscode/ 8 | # !.vscode/launch.json 9 | 10 | # 依存関係 11 | /app/node_modules/ 12 | 13 | # ログファイル 14 | *.log 15 | npm-debug.log* 16 | 17 | # 環境変数ファイル 18 | # .env 19 | # /.devcontainer/.env 20 | 21 | # MongoDB データボリューム (Docker管理なのでGitでは無視) 22 | # db-data/ (ボリューム名を直接指定するわけではない) 23 | 24 | # Nginx設定(環境依存の可能性がある場合) 25 | # /web/nginx.conf 26 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "type": "module", 4 | "scripts": { 5 | "build": "vite build", 6 | "dev": "vite" 7 | }, 8 | "devDependencies": { 9 | "@tailwindcss/vite": "^4.0.0", 10 | "axios": "^1.8.2", 11 | "concurrently": "^9.0.1", 12 | "laravel-vite-plugin": "^1.2.0", 13 | "tailwindcss": "^4.0.0", 14 | "vite": "^6.2.4" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /env_https/app/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 | 10 | {{ range .books }} 11 | 12 | 13 | 14 | 15 | 16 | {{ end }} 17 |
{{.Id}}{{.Title}}{{.InsertTimestamp}}
18 | 19 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/resources/css/app.css: -------------------------------------------------------------------------------- 1 | @import 'tailwindcss'; 2 | 3 | @source '../../vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php'; 4 | @source '../../storage/framework/views/*.php'; 5 | @source '../**/*.blade.php'; 6 | @source '../**/*.js'; 7 | 8 | @theme { 9 | --font-sans: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 10 | 'Segoe UI Symbol', 'Noto Color Emoji'; 11 | } 12 | -------------------------------------------------------------------------------- /env_node1/app/sample/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sample", 3 | "version": "1.0.0", 4 | "main": "index.js", 5 | "scripts": { 6 | "test": "echo \"Error: no test specified\" && exit 1" 7 | }, 8 | "keywords": [], 9 | "author": "", 10 | "license": "ISC", 11 | "description": "", 12 | "dependencies": { 13 | "ejs": "^3.1.10", 14 | "express": "^5.1.0", 15 | "moment": "^2.30.1", 16 | "mongodb": "^6.16.0", 17 | "mongoose": "^8.14.1" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/resources/css/app.css: -------------------------------------------------------------------------------- 1 | @import 'tailwindcss'; 2 | 3 | @source '../../vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php'; 4 | @source '../../storage/framework/views/*.php'; 5 | @source '../**/*.blade.php'; 6 | @source '../**/*.js'; 7 | 8 | @theme { 9 | --font-sans: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 10 | 'Segoe UI Symbol', 'Noto Color Emoji'; 11 | } 12 | -------------------------------------------------------------------------------- /env_node_nginx/app/sample/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sample", 3 | "version": "1.0.0", 4 | "main": "index.js", 5 | "scripts": { 6 | "test": "echo \"Error: no test specified\" && exit 1" 7 | }, 8 | "keywords": [], 9 | "author": "", 10 | "license": "ISC", 11 | "description": "", 12 | "dependencies": { 13 | "ejs": "^3.1.10", 14 | "express": "^5.1.0", 15 | "moment": "^2.30.1", 16 | "mongodb": "^6.16.0", 17 | "mongoose": "^8.14.1" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/tests/Feature/ExampleTest.php: -------------------------------------------------------------------------------- 1 | get('/'); 16 | 17 | $response->assertStatus(200); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/tests/Feature/ExampleTest.php: -------------------------------------------------------------------------------- 1 | get('/'); 16 | 17 | $response->assertStatus(200); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | handleCommand(new ArgvInput); 17 | 18 | exit($status); 19 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | handleCommand(new ArgvInput); 17 | 18 | exit($status); 19 | -------------------------------------------------------------------------------- /ex21/php/.dockerignore: -------------------------------------------------------------------------------- 1 | # Docker イメージのビルドコンテキストから除外するファイル/ディレクトリ 2 | 3 | # Git 4 | .git 5 | .gitignore 6 | 7 | # Composer 8 | vendor/ 9 | # composer.lock # 通常は含めるが、環境によっては除外 10 | 11 | # エディタ関係 12 | .idea/ 13 | # .vscode 14 | *.swp 15 | *.swo 16 | 17 | # OS関連 18 | .DS_Store 19 | Thumbs.db 20 | 21 | # ログ、一時ファイル 22 | *.log 23 | tmp/ 24 | storage/logs/ # Laravelなど 25 | 26 | # 環境変数 27 | # .env* 28 | 29 | # テスト 30 | tests/ 31 | phpunit.xml* 32 | .phpunit.result.cache 33 | 34 | # ビルド関係 (Node.jsアセットなどがある場合) 35 | node_modules/ 36 | public/build/ -------------------------------------------------------------------------------- /env_go_mysql/.gitignore: -------------------------------------------------------------------------------- 1 | # OS generated files 2 | .DS_Store 3 | Thumbs.db 4 | 5 | # Go build artifacts 6 | *.exe 7 | *.out 8 | app # ビルド後の実行ファイル名 (適宜変更) 9 | 10 | # Dependencies (managed by go.mod) 11 | # vendor/ # If using vendoring 12 | 13 | # Environment variables 14 | # .env 15 | # /.devcontainer/.env 16 | 17 | # Editor/IDE specific 18 | # .vscode/ 19 | # !.vscode/launch.json # launch.jsonは共有することが多い 20 | 21 | # MySQL data volume (managed by Docker) 22 | # No need to ignore db-data volume path directly 23 | 24 | # Log files 25 | *.log 26 | -------------------------------------------------------------------------------- /ex03/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:24.04 2 | 3 | # 環境変数: noninteractiveモードを指定し、tzdataインストール時の対話プロンプトを抑制 4 | ENV DEBIAN_FRONTEND=noninteractive 5 | 6 | # Nginxとタイムゾーンデータをインストール 7 | # RUN命令を&&で繋げてレイヤー数を減らし、最後にaptキャッシュを削除してイメージサイズを削減 8 | RUN apt-get update -qq \ 9 | && apt-get install -y --no-install-recommends nginx tzdata \ 10 | && rm -rf /var/lib/apt/lists/* 11 | 12 | # 環境変数: タイムゾーンをアジア/東京に設定 13 | ENV TZ="Asia/Tokyo" 14 | 15 | # ポートの指定 16 | EXPOSE 80 17 | 18 | # ファイルのコピー 19 | COPY src/index.html /var/www/html/ 20 | 21 | # Nginxの起動 22 | CMD ["nginx", "-g", "daemon off;"] -------------------------------------------------------------------------------- /ex21/php/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ex21/php-app", 3 | "description": "Basic PHP project for Dev Container example", 4 | "type": "project", 5 | "license": "MIT", 6 | "autoload": { 7 | "psr-4": { 8 | "App\\": "src/" 9 | } 10 | }, 11 | "authors": [ 12 | { 13 | "name": "Your Name", 14 | "email": "your.email@example.com" 15 | } 16 | ], 17 | "require": { 18 | "php": ">=8.2" 19 | }, 20 | "require-dev": { 21 | "phpunit/phpunit": "^10.0" 22 | } 23 | } -------------------------------------------------------------------------------- /env_laravel1/.gitignore: -------------------------------------------------------------------------------- 1 | # Docker / Dev Containers 2 | # .devcontainer/.env # Docker Compose 用の .env 3 | 4 | # Application specific 5 | # app/sample/.env # Laravel の .env 6 | app/sample/vendor/ 7 | 8 | # Laravel Storage 9 | app/sample/storage/logs/*.log 10 | app/sample/storage/framework/sessions/* 11 | app/sample/storage/framework/views/* 12 | app/sample/storage/framework/cache/data/* 13 | app/sample/public/storage 14 | 15 | # OS / Editor 16 | .DS_Store 17 | Thumbs.db 18 | *.swp 19 | *.swo 20 | # app/.vscode/ は launch.json を共有する場合 Git 管理下に含めることも検討 21 | # app/.vscode/* 22 | # !app/.vscode/launch.json -------------------------------------------------------------------------------- /env_laravel1/app/sample/database/seeders/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 17 | 18 | User::factory()->create([ 19 | 'name' => 'Test User', 20 | 'email' => 'test@example.com', 21 | ]); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /env_laravel1/app/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Listen for Xdebug", 6 | "type": "php", 7 | "request": "launch", 8 | "port": 9003, 9 | "pathMappings": { 10 | // Xdebugが認識するコンテナ内絶対パスのルート /var/www/html を 11 | // VS Codeサーバーが認識するワークスペースルート ${workspaceFolder} (同じくコンテナ内の /var/www/html) にマッピング 12 | "/var/www/html": "${workspaceFolder}" 13 | // あるいは、より直接的に絶対パスで指定しても同じ意味になります 14 | // "/var/www/html": "/var/www/html" 15 | }, 16 | "log": true // デバッグコンソールに詳細ログを出力 17 | } 18 | ] 19 | } -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/database/seeders/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 17 | 18 | User::factory()->create([ 19 | 'name' => 'Test User', 20 | 'email' => 'test@example.com', 21 | ]); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/bootstrap/app.php: -------------------------------------------------------------------------------- 1 | withRouting( 9 | web: __DIR__.'/../routes/web.php', 10 | commands: __DIR__.'/../routes/console.php', 11 | health: '/up', 12 | ) 13 | ->withMiddleware(function (Middleware $middleware) { 14 | // 15 | }) 16 | ->withExceptions(function (Exceptions $exceptions) { 17 | // 18 | })->create(); 19 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/bootstrap/app.php: -------------------------------------------------------------------------------- 1 | withRouting( 9 | web: __DIR__.'/../routes/web.php', 10 | commands: __DIR__.'/../routes/console.php', 11 | health: '/up', 12 | ) 13 | ->withMiddleware(function (Middleware $middleware) { 14 | // 15 | }) 16 | ->withExceptions(function (Exceptions $exceptions) { 17 | // 18 | })->create(); 19 | -------------------------------------------------------------------------------- /env_go_mysql/app/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Launch Go App (Debug)", 6 | "type": "go", 7 | "request": "launch", 8 | "mode": "debug", // または "auto" 9 | "program": "${workspaceFolder}/main.go", // エントリーポイント 10 | "cwd": "${workspaceFolder}", 11 | "env": {}, // 必要に応じて環境変数を追加 12 | "args": [], // プログラムへの引数 13 | // Delve 用の設定 (Dev Container経由の場合、VS Code拡張機能が適切に設定することが多い) 14 | // "debugAdapter": "dlv-dap", // 推奨されるアダプター 15 | // "port": 2345, // compose.yml で公開したポート 16 | // "host": "127.0.0.1", 17 | } 18 | ] 19 | } -------------------------------------------------------------------------------- /env_go_mysql_nginx/app/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Launch Go App (Debug)", 6 | "type": "go", 7 | "request": "launch", 8 | "mode": "debug", // または "auto" 9 | "program": "${workspaceFolder}/main.go", // エントリーポイント 10 | "cwd": "${workspaceFolder}", 11 | "env": {}, // 必要に応じて環境変数を追加 12 | "args": [], // プログラムへの引数 13 | // Delve 用の設定 (Dev Container経由の場合、VS Code拡張機能が適切に設定することが多い) 14 | // "debugAdapter": "dlv-dap", // 推奨されるアダプター 15 | // "port": 2345, // compose.yml で公開したポート 16 | // "host": "127.0.0.1", 17 | } 18 | ] 19 | } -------------------------------------------------------------------------------- /env_node1/app/sample/book_model.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose'); 2 | const Schema = mongoose.Schema; 3 | 4 | const bookSchema = new Schema({ 5 | title: String, 6 | insert_timestamp: { type: Date, default: Date.now } 7 | }, { 8 | versionKey: false, // __v フィールドを非表示に 9 | toJSON: { virtuals: true }, // toJSON時に仮想フィールドを含める 10 | toObject: { virtuals: true } // toObject時に仮想フィールドを含める 11 | }); 12 | 13 | // 仮想フィールド 'id' を定義 (_id の文字列版) 14 | bookSchema.virtual('id').get(function(){ 15 | return this._id.toHexString(); 16 | }); 17 | 18 | // 'Book' モデルを 'books' コレクションに紐付けてエクスポート 19 | module.exports = mongoose.model('Book', bookSchema, 'books'); -------------------------------------------------------------------------------- /env_go_mysql_nginx_cert/app/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Launch Go App (Debug)", 6 | "type": "go", 7 | "request": "launch", 8 | "mode": "debug", // または "auto" 9 | "program": "${workspaceFolder}/main.go", // エントリーポイント 10 | "cwd": "${workspaceFolder}", 11 | "env": {}, // 必要に応じて環境変数を追加 12 | "args": [], // プログラムへの引数 13 | // Delve 用の設定 (Dev Container経由の場合、VS Code拡張機能が適切に設定することが多い) 14 | // "debugAdapter": "dlv-dap", // 推奨されるアダプター 15 | // "port": 2345, // compose.yml で公開したポート 16 | // "host": "127.0.0.1", 17 | } 18 | ] 19 | } -------------------------------------------------------------------------------- /env_node_nginx/app/sample/book_model.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose'); 2 | const Schema = mongoose.Schema; 3 | 4 | const bookSchema = new Schema({ 5 | title: String, 6 | insert_timestamp: { type: Date, default: Date.now } 7 | }, { 8 | versionKey: false, // __v フィールドを非表示に 9 | toJSON: { virtuals: true }, // toJSON時に仮想フィールドを含める 10 | toObject: { virtuals: true } // toObject時に仮想フィールドを含める 11 | }); 12 | 13 | // 仮想フィールド 'id' を定義 (_id の文字列版) 14 | bookSchema.virtual('id').get(function(){ 15 | return this._id.toHexString(); 16 | }); 17 | 18 | // 'Book' モデルを 'books' コレクションに紐付けてエクスポート 19 | module.exports = mongoose.model('Book', bookSchema, 'books'); -------------------------------------------------------------------------------- /env_laravel1/app/sample/public/index.php: -------------------------------------------------------------------------------- 1 | handleRequest(Request::capture()); 21 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Listen for Xdebug", 6 | "type": "php", 7 | "request": "launch", 8 | "port": 9003, 9 | "pathMappings": { 10 | // Xdebugが認識するコンテナ内絶対パスのルート /var/www/html を 11 | // VS Codeサーバーが認識するワークスペースルート ${workspaceFolder} (同じくコンテナ内の /var/www/html) にマッピング 12 | "/var/www/html": "${workspaceFolder}" 13 | // あるいは、より直接的に絶対パスで指定しても同じ意味になります 14 | // "/var/www/html": "/var/www/html" 15 | }, 16 | "log": true // デバッグコンソールに詳細ログを出力 17 | } 18 | ] 19 | } -------------------------------------------------------------------------------- /env_go_mysql_nginx/.gitignore: -------------------------------------------------------------------------------- 1 | # OS generated files 2 | .DS_Store 3 | Thumbs.db 4 | 5 | # Go build artifacts 6 | *.exe 7 | *.out 8 | app # ビルド後の実行ファイル名 (適宜変更) 9 | 10 | # Dependencies (managed by go.mod) 11 | # vendor/ # If using vendoring 12 | 13 | # Environment variables 14 | # .env # プロジェクトルートに置く場合 15 | # /.devcontainer/.env # devcontainer内に置く場合 16 | 17 | # Editor/IDE specific 18 | # .vscode/ 19 | # !.vscode/launch.json # launch.jsonは共有することが多い 20 | 21 | # MySQL data volume (managed by Docker) 22 | # No need to ignore db-data volume path directly 23 | 24 | # Log files 25 | *.log 26 | 27 | # Nginx logs (if generated locally or mapped outside container) 28 | web/*.log -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/.gitignore: -------------------------------------------------------------------------------- 1 | # Docker / Dev Containers 2 | # .devcontainer/.env # Docker Compose 用の .env 3 | 4 | # Application specific 5 | # app/sample/.env # Laravel の .env 6 | app/sample/vendor/ 7 | 8 | # Laravel Storage 9 | app/sample/storage/logs/*.log 10 | app/sample/storage/framework/sessions/* 11 | app/sample/storage/framework/views/* 12 | app/sample/storage/framework/cache/data/* 13 | app/sample/public/storage 14 | 15 | # OS / Editor 16 | .DS_Store 17 | Thumbs.db 18 | *.swp 19 | *.swo 20 | # app/.vscode/ は launch.json を共有する場合 Git 管理下に含めることも検討 21 | # app/.vscode/* 22 | # !app/.vscode/launch.json 23 | 24 | # Nginx (ログなどビルドや実行時に生成される可能性のあるもの) 25 | nginx/logs/ -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/public/index.php: -------------------------------------------------------------------------------- 1 | handleRequest(Request::capture()); 21 | -------------------------------------------------------------------------------- /env_laravel1/app/.dockerignore: -------------------------------------------------------------------------------- 1 | # Git リポジトリ情報 2 | .git 3 | .gitignore 4 | 5 | # IDE/エディタ設定 6 | # .vscode/ 7 | .idea/ 8 | 9 | # OS固有ファイル 10 | .DS_Store 11 | Thumbs.db 12 | 13 | # Laravel プロジェクト固有の除外対象 (sample/ 配下) 14 | sample/vendor/ 15 | sample/node_modules/ 16 | sample/public/storage/ 17 | sample/public/hot 18 | sample/storage/framework/sessions/* 19 | sample/storage/framework/views/* 20 | sample/storage/framework/cache/data/* 21 | sample/storage/logs/*.log 22 | !sample/storage/logs/.gitkeep 23 | # sample/.env # 本番イメージなどでは含めない。開発用でもDockerfileで直接コピーしないなら不要。 24 | npm-debug.log* 25 | yarn-error.log* 26 | 27 | # Dockerfile自体やビルドに必要な設定ファイルは除外しない 28 | # !Dockerfile 29 | # !php.ini -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/.dockerignore: -------------------------------------------------------------------------------- 1 | # Git リポジトリ情報 2 | .git 3 | .gitignore 4 | 5 | # IDE/エディタ設定 6 | # .vscode/ 7 | .idea/ 8 | 9 | # OS固有ファイル 10 | .DS_Store 11 | Thumbs.db 12 | 13 | # Laravel プロジェクト固有の除外対象 (sample/ 配下) 14 | sample/vendor/ 15 | sample/node_modules/ 16 | sample/public/storage/ 17 | sample/public/hot 18 | sample/storage/framework/sessions/* 19 | sample/storage/framework/views/* 20 | sample/storage/framework/cache/data/* 21 | sample/storage/logs/*.log 22 | !sample/storage/logs/.gitkeep 23 | # sample/.env # 本番イメージなどでは含めない。開発用でもDockerfileで直接コピーしないなら不要。 24 | npm-debug.log* 25 | yarn-error.log* 26 | 27 | # Dockerfile自体やビルドに必要な設定ファイルは除外しない 28 | # !Dockerfile 29 | # !php.ini -------------------------------------------------------------------------------- /env_node_nginx/web/nginx.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | server_name localhost; # アクセスするホスト名 4 | 5 | location / { 6 | # appサービス(コンテナ名: app, ポート: 3000)にリクエストを転送 7 | proxy_pass http://app:3000; 8 | 9 | # プロキシ設定 (一般的な設定) 10 | proxy_http_version 1.1; 11 | proxy_set_header Upgrade $http_upgrade; 12 | proxy_set_header Connection 'upgrade'; 13 | proxy_set_header Host $host; 14 | proxy_set_header X-Real-IP $remote_addr; 15 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 16 | proxy_set_header X-Forwarded-Proto $scheme; 17 | proxy_cache_bypass $http_upgrade; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /env_node_nginx/.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Node Nginx Basic", 3 | "dockerComposeFile": "compose.yml", 4 | "service": "app", // VS Codeが接続するサービスは 'app' (Node.js) 5 | "workspaceFolder": "/var/www/html", // 'app' サービス内のワークスペース 6 | "customizations": { 7 | "vscode": { 8 | "extensions": [ 9 | "digitalbrainstem.javascript-ejs-support", 10 | "dbaeumer.vscode-eslint", 11 | "leizongmin.node-module-intellisense" 12 | ], 13 | "settings": { 14 | "editor.tabSize": 2 15 | } 16 | } 17 | }, 18 | // Nginx(webサービス)のポートを転送(オプション) 19 | // "forwardPorts": [80], 20 | // ポート転送しない場合は、直接 http://localhost/ でアクセス 21 | } 22 | -------------------------------------------------------------------------------- /env_node1/db/init/01.js: -------------------------------------------------------------------------------- 1 | // ユーザの作成 2 | var user = { 3 | user: "user1", 4 | pwd: "user1", 5 | roles: [ 6 | { 7 | role: "readWrite", 8 | db: "mongo" 9 | } 10 | ] 11 | }; 12 | db.createUser(user); 13 | 14 | // コレクションにデータを登録 15 | db.books.insert({id: 1, title: 'プログラミング言語C', "insert_timestamp": new Date()}); 16 | db.books.insert({id: 2, title: 'やさしいコンピューター科学', "insert_timestamp": new Date()}); 17 | db.books.insert({id: 3, title: 'ゲーデル、エッシャー、バッハ―あるいは不思議の環', "insert_timestamp": new Date()}); 18 | db.books.insert({id: 4, title: 'TeXブック コンピュータによる組版システム', "insert_timestamp": new Date()}); 19 | db.books.insert({id: 5, title: '人月の神話 狼人間を撃つ銀の弾はない', "insert_timestamp": new Date()}); 20 | -------------------------------------------------------------------------------- /env_go_mysql_nginx_cert/.gitignore: -------------------------------------------------------------------------------- 1 | # OS generated files 2 | .DS_Store 3 | Thumbs.db 4 | 5 | # Go build artifacts 6 | *.exe 7 | *.out 8 | app # ビルド後の実行ファイル名 (適宜変更) 9 | 10 | # Dependencies (managed by go.mod) 11 | # vendor/ # If using vendoring 12 | 13 | # Environment variables 14 | # .env # プロジェクトルートに置く場合 15 | # /.devcontainer/.env # devcontainer内に置く場合 16 | 17 | # Editor/IDE specific 18 | # .vscode/ 19 | # !.vscode/launch.json # launch.jsonは共有することが多い 20 | 21 | # MySQL data volume (managed by Docker) 22 | # No need to ignore db-data volume path directly 23 | 24 | # Log files 25 | *.log 26 | 27 | # Nginx logs (if generated locally or mapped outside container) 28 | web/*.log 29 | 30 | # SSL Certificates 31 | certs/ -------------------------------------------------------------------------------- /env_node_nginx/db/init/01.js: -------------------------------------------------------------------------------- 1 | // ユーザの作成 2 | var user = { 3 | user: "user1", 4 | pwd: "user1", 5 | roles: [ 6 | { 7 | role: "readWrite", 8 | db: "mongo" // .envで指定したデータベース名 9 | } 10 | ] 11 | }; 12 | db.createUser(user); 13 | 14 | // コレクションにデータを登録 15 | db.books.insert({id: 1, title: 'プログラミング言語C', "insert_timestamp": new Date()}); 16 | db.books.insert({id: 2, title: 'やさしいコンピューター科学', "insert_timestamp": new Date()}); 17 | db.books.insert({id: 3, title: 'ゲーデル、エッシャー、バッハ―あるいは不思議の環', "insert_timestamp": new Date()}); 18 | db.books.insert({id: 4, title: 'TeXブック コンピュータによる組版システム', "insert_timestamp": new Date()}); 19 | db.books.insert({id: 5, title: '人月の神話 狼人間を撃つ銀の弾はない', "insert_timestamp": new Date()}); -------------------------------------------------------------------------------- /ex03/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Sample 7 | 8 | 9 |

こんにちは!Docker!

10 |

11 | 12 | 25 | 26 | -------------------------------------------------------------------------------- /env_laravel1/.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Laravel Basic (DevContainer)", 3 | "dockerComposeFile": "compose.yml", 4 | "service": "app", 5 | "workspaceFolder": "/var/www/html", 6 | "remoteUser": "appuser", 7 | "customizations": { 8 | "vscode": { 9 | "extensions": [ 10 | "xdebug.php-debug", 11 | "bmewburn.vscode-intelephense-client", 12 | "neilbrayfield.php-docblocker", 13 | "MehediDracula.php-namespace-resolver" 14 | ], 15 | "settings": { 16 | "editor.tabSize": 4, 17 | "editor.insertSpaces": true, 18 | "php.validate.executablePath": "/usr/local/bin/php" 19 | } 20 | } 21 | }, 22 | "forwardPorts": [8000] 23 | } -------------------------------------------------------------------------------- /env_laravel1/app/sample/routes/web.php: -------------------------------------------------------------------------------- 1 | Book::all() 21 | ]; 22 | 23 | // ログ出力 (デバッグレベル) 24 | Log::debug('BookController::index called. Data retrieved:', ['book_count' => count($data['books'])]); 25 | // 必要であればデータ内容もログに出力 26 | // Log::debug($data); 27 | 28 | // ビューにデータを渡して表示 29 | return view('book.index', $data); 30 | } 31 | } -------------------------------------------------------------------------------- /env_node1/app/sample/views/index.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 書籍リスト 7 | 10 | 11 | 12 |

書籍リスト

13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | <% books.forEach(function (book, index) { %> 23 | 24 | 25 | 26 | <%# index.js でフォーマット済みの date を表示 %> 27 | 28 | <% }); %> 29 | 30 |
#タイトル登録日時
<%= index + 1 %><%= book.title %><%= book.date %>
31 | 32 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews -Indexes 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Handle Authorization Header 9 | RewriteCond %{HTTP:Authorization} . 10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 11 | 12 | # Handle X-XSRF-Token Header 13 | RewriteCond %{HTTP:x-xsrf-token} . 14 | RewriteRule .* - [E=HTTP_X_XSRF_TOKEN:%{HTTP:X-XSRF-Token}] 15 | 16 | # Redirect Trailing Slashes If Not A Folder... 17 | RewriteCond %{REQUEST_FILENAME} !-d 18 | RewriteCond %{REQUEST_URI} (.+)/$ 19 | RewriteRule ^ %1 [L,R=301] 20 | 21 | # Send Requests To Front Controller... 22 | RewriteCond %{REQUEST_FILENAME} !-d 23 | RewriteCond %{REQUEST_FILENAME} !-f 24 | RewriteRule ^ index.php [L] 25 | 26 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/app/Http/Controllers/BookController.php: -------------------------------------------------------------------------------- 1 | Book::all() 21 | ]; 22 | 23 | // ログ出力 (デバッグレベル) 24 | Log::debug('BookController::index called. Data retrieved:', ['book_count' => count($data['books'])]); 25 | // 必要であればデータ内容もログに出力 26 | // Log::debug($data); 27 | 28 | // ビューにデータを渡して表示 29 | return view('book.index', $data); 30 | } 31 | } -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews -Indexes 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Handle Authorization Header 9 | RewriteCond %{HTTP:Authorization} . 10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 11 | 12 | # Handle X-XSRF-Token Header 13 | RewriteCond %{HTTP:x-xsrf-token} . 14 | RewriteRule .* - [E=HTTP_X_XSRF_TOKEN:%{HTTP:X-XSRF-Token}] 15 | 16 | # Redirect Trailing Slashes If Not A Folder... 17 | RewriteCond %{REQUEST_FILENAME} !-d 18 | RewriteCond %{REQUEST_URI} (.+)/$ 19 | RewriteRule ^ %1 [L,R=301] 20 | 21 | # Send Requests To Front Controller... 22 | RewriteCond %{REQUEST_FILENAME} !-d 23 | RewriteCond %{REQUEST_FILENAME} !-f 24 | RewriteRule ^ index.php [L] 25 | 26 | -------------------------------------------------------------------------------- /env_node_nginx/app/sample/views/index.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 書籍リスト (Nginx) 7 | 10 | 11 | 12 |

書籍リスト (via Nginx)

13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | <% books.forEach(function (book, index) { %> 23 | 24 | 25 | 26 | <%# index.js でフォーマット済みの date を表示 %> 27 | 28 | <% }); %> 29 | 30 |
#タイトル登録日時
<%= index + 1 %><%= book.title %><%= book.date %>
31 | 32 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Laravel Nginx+FPM (DevContainer)", 3 | "dockerComposeFile": "compose.yml", 4 | "service": "app", // 接続先は PHP-FPM コンテナ (デバッグ、composer実行のため) 5 | "workspaceFolder": "/var/www/html", 6 | "remoteUser": "appuser", 7 | "customizations": { 8 | "vscode": { 9 | "extensions": [ 10 | "xdebug.php-debug", 11 | "bmewburn.vscode-intelephense-client", 12 | "neilbrayfield.php-docblocker", 13 | "MehediDracula.php-namespace-resolver" 14 | ], 15 | "settings": { 16 | "editor.tabSize": 4, 17 | "editor.insertSpaces": true, 18 | "php.validate.executablePath": "/usr/local/bin/php" 19 | } 20 | } 21 | }, 22 | "forwardPorts": [80] // Nginx が公開するポートを転送 23 | // "postCreateCommand": "composer install" // 必要に応じて追加 24 | } -------------------------------------------------------------------------------- /ex21/.devcontainer/compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | php: 3 | build: 4 | # ビルドコンテキスト: compose.yml から見て ../php ディレクトリ 5 | context: ../php 6 | 7 | # コンテナ内の作業ディレクトリ 8 | working_dir: /app 9 | 10 | volumes: 11 | # ホストの php ディレクトリ全体をコンテナの /app にマウント 12 | # これにより、ホストでのコード変更がコンテナ内に即時反映される (開発用) 13 | # public ディレクトリが含まれるように ../php をマウント 14 | - ../php:/app 15 | # vendor ディレクトリは名前付きボリュームを使用し、ホストからの上書きを防ぐ 16 | # コンテナ内の /app/vendor を vendor_data ボリュームに割り当てる 17 | - vendor_data:/app/vendor 18 | 19 | # コンテナ起動時に PHP ビルトインサーバーを起動 20 | # -S 0.0.0.0:8000: すべてのネットワークインターフェースのポート8000で待機 21 | # -t public: ドキュメントルートを /app/public に設定 22 | command: php -S 0.0.0.0:8000 -t public 23 | 24 | # Xdebug がホストマシン(VS Code)に接続できるように設定 25 | extra_hosts: 26 | - "host.docker.internal:host-gateway" 27 | 28 | # コンテナ間で共有・永続化するための名前付きボリュームを定義 29 | volumes: 30 | vendor_data: -------------------------------------------------------------------------------- /env_go_mysql/.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Go MySQL Basic", 3 | "dockerComposeFile": "compose.yml", // 同じディレクトリにある compose.yml を参照 4 | "service": "app", // VS Codeがアタッチするサービス 5 | "workspaceFolder": "/app", // 'app'サービス内のワークスペース (DockerfileのWORKDIRと合わせる) 6 | "customizations": { 7 | "vscode": { 8 | "extensions": [ 9 | "golang.Go" // 公式Go拡張機能 10 | ], 11 | "settings": { 12 | "editor.tabSize": 4, // Goの標準はタブ文字だが、スペース4つにする場合 13 | "[go]": { 14 | "editor.insertSpaces": false, // タブ文字を使用 15 | "editor.tabSize": 4, 16 | "editor.formatOnSave": true 17 | }, 18 | "go.toolsManagement.autoUpdate": true, 19 | "go.useLanguageServer": true 20 | } 21 | } 22 | }, 23 | // コンテナ起動後にGoツールをインストールする場合 24 | // "postCreateCommand": "go install golang.org/x/tools/gopls@latest && go install github.com/go-delve/delve/cmd/dlv@latest" 25 | } -------------------------------------------------------------------------------- /env_go_mysql_nginx/.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Go MySQL Nginx", 3 | "dockerComposeFile": "compose.yml", // 同じディレクトリにある compose.yml を参照 4 | "service": "app", // VS Codeがアタッチするサービス 5 | "workspaceFolder": "/app", // 'app'サービス内のワークスペース (DockerfileのWORKDIRと合わせる) 6 | "customizations": { 7 | "vscode": { 8 | "extensions": [ 9 | "golang.Go" // 公式Go拡張機能 10 | ], 11 | "settings": { 12 | "editor.tabSize": 4, // Goの標準はタブ文字だが、スペース4つにする場合 13 | "[go]": { 14 | "editor.insertSpaces": false, // タブ文字を使用 15 | "editor.tabSize": 4, 16 | "editor.formatOnSave": true 17 | }, 18 | "go.toolsManagement.autoUpdate": true, 19 | "go.useLanguageServer": true 20 | } 21 | } 22 | }, 23 | // コンテナ起動後にGoツールをインストールする場合 24 | // "postCreateCommand": "go install golang.org/x/tools/gopls@latest && go install github.com/go-delve/delve/cmd/dlv@latest" 25 | } -------------------------------------------------------------------------------- /env_go_mysql_nginx_cert/.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Go MySQL Nginx", 3 | "dockerComposeFile": "compose.yml", // 同じディレクトリにある compose.yml を参照 4 | "service": "app", // VS Codeがアタッチするサービス 5 | "workspaceFolder": "/app", // 'app'サービス内のワークスペース (DockerfileのWORKDIRと合わせる) 6 | "customizations": { 7 | "vscode": { 8 | "extensions": [ 9 | "golang.Go" // 公式Go拡張機能 10 | ], 11 | "settings": { 12 | "editor.tabSize": 4, // Goの標準はタブ文字だが、スペース4つにする場合 13 | "[go]": { 14 | "editor.insertSpaces": false, // タブ文字を使用 15 | "editor.tabSize": 4, 16 | "editor.formatOnSave": true 17 | }, 18 | "go.toolsManagement.autoUpdate": true, 19 | "go.useLanguageServer": true 20 | } 21 | } 22 | }, 23 | // コンテナ起動後にGoツールをインストールする場合 24 | // "postCreateCommand": "go install golang.org/x/tools/gopls@latest && go install github.com/go-delve/delve/cmd/dlv@latest" 25 | } -------------------------------------------------------------------------------- /env_go_mysql_nginx/app/Dockerfile: -------------------------------------------------------------------------------- 1 | # 最新の安定版Goイメージを使用 2 | FROM golang:1.24-alpine AS base 3 | 4 | # パッケージのインストール、タイムゾーン設定 5 | # compose.ymlのenvironmentでTZを設定するため、Dockerfileでの設定は必須ではない 6 | # RUN apk --update --no-cache add \ 7 | # tzdata \ 8 | #&& cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime \ 9 | #&& apk del tzdata 10 | 11 | # 作業ディレクトリ設定 12 | WORKDIR /app 13 | 14 | # Goモジュールのキャッシュを活用 (開発時、初回ビルド高速化のためコメントアウト解除推奨) 15 | # COPY go.mod go.sum ./ 16 | # RUN go mod download 17 | 18 | # アプリケーションコードをコピー (開発時はvolumeマウントするので不要な場合が多い) 19 | # COPY . . 20 | 21 | # 開発用ツール (gopls, delve) のインストール 22 | # delveはデバッグに必要 23 | # goplsはVS Code Go拡張機能に必要 24 | RUN go install golang.org/x/tools/gopls@latest \ 25 | && go install github.com/go-delve/delve/cmd/dlv@latest 26 | 27 | # アプリケーションが使用するポートを公開 (内部用) 28 | # EXPOSE 8080 は compose.yml の expose で指定するため、必須ではない 29 | 30 | # デバッグ用にdelveを起動可能にする (デフォルトのCMDは設定しないでおく) 31 | # または、開発時の起動コマンドとして設定: CMD ["go", "run", "main.go"] 32 | # 本番イメージの場合は CMD ["./your-app-binary"] のようにする -------------------------------------------------------------------------------- /env_go_mysql_nginx_cert/app/Dockerfile: -------------------------------------------------------------------------------- 1 | # 最新の安定版Goイメージを使用 2 | FROM golang:1.24-alpine AS base 3 | 4 | # パッケージのインストール、タイムゾーン設定 5 | # compose.ymlのenvironmentでTZを設定するため、Dockerfileでの設定は必須ではない 6 | # RUN apk --update --no-cache add \ 7 | # tzdata \ 8 | #&& cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime \ 9 | #&& apk del tzdata 10 | 11 | # 作業ディレクトリ設定 12 | WORKDIR /app 13 | 14 | # Goモジュールのキャッシュを活用 (開発時、初回ビルド高速化のためコメントアウト解除推奨) 15 | # COPY go.mod go.sum ./ 16 | # RUN go mod download 17 | 18 | # アプリケーションコードをコピー (開発時はvolumeマウントするので不要な場合が多い) 19 | # COPY . . 20 | 21 | # 開発用ツール (gopls, delve) のインストール 22 | # delveはデバッグに必要 23 | # goplsはVS Code Go拡張機能に必要 24 | RUN go install golang.org/x/tools/gopls@latest \ 25 | && go install github.com/go-delve/delve/cmd/dlv@latest 26 | 27 | # アプリケーションが使用するポートを公開 (内部用) 28 | # EXPOSE 8080 は compose.yml の expose で指定するため、必須ではない 29 | 30 | # デバッグ用にdelveを起動可能にする (デフォルトのCMDは設定しないでおく) 31 | # または、開発時の起動コマンドとして設定: CMD ["go", "run", "main.go"] 32 | # 本番イメージの場合は CMD ["./your-app-binary"] のようにする -------------------------------------------------------------------------------- /env_https/.devcontainer/web/default.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 443 ssl; 3 | ssl_certificate /etc/certs/localhost.pem; 4 | ssl_certificate_key /etc/certs/localhost-key.pem; 5 | server_name _; 6 | 7 | add_header X-Frame-Options "SAMEORIGIN"; 8 | add_header X-XSS-Protection "1; mode=block"; 9 | add_header X-Content-Type-Options "nosniff"; 10 | 11 | charset utf-8; 12 | 13 | access_log /dev/stdout; 14 | error_log /dev/stderr; 15 | 16 | location = /favicon.ico { access_log off; log_not_found off; } 17 | location = /robots.txt { access_log off; log_not_found off; } 18 | 19 | error_page 404 /index.php; 20 | 21 | location / { 22 | proxy_pass http://https1-app:3000/; 23 | proxy_http_version 1.1; 24 | proxy_set_header Upgrade $http_upgrade; 25 | proxy_set_header Connection 'upgrade'; 26 | proxy_set_header Host $host; 27 | proxy_cache_bypass $http_upgrade; 28 | } 29 | 30 | location ~ /\.(?!well-known).* { 31 | deny all; 32 | } 33 | } -------------------------------------------------------------------------------- /env_laravel1/app/sample/database/migrations/0001_01_01_000001_create_cache_table.php: -------------------------------------------------------------------------------- 1 | string('key')->primary(); 16 | $table->mediumText('value'); 17 | $table->integer('expiration'); 18 | }); 19 | 20 | Schema::create('cache_locks', function (Blueprint $table) { 21 | $table->string('key')->primary(); 22 | $table->string('owner'); 23 | $table->integer('expiration'); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | */ 30 | public function down(): void 31 | { 32 | Schema::dropIfExists('cache'); 33 | Schema::dropIfExists('cache_locks'); 34 | } 35 | }; 36 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/database/migrations/0001_01_01_000001_create_cache_table.php: -------------------------------------------------------------------------------- 1 | string('key')->primary(); 16 | $table->mediumText('value'); 17 | $table->integer('expiration'); 18 | }); 19 | 20 | Schema::create('cache_locks', function (Blueprint $table) { 21 | $table->string('key')->primary(); 22 | $table->string('owner'); 23 | $table->integer('expiration'); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | */ 30 | public function down(): void 31 | { 32 | Schema::dropIfExists('cache'); 33 | Schema::dropIfExists('cache_locks'); 34 | } 35 | }; 36 | -------------------------------------------------------------------------------- /env_go_mysql_nginx/web/default.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | server_name localhost; # 必要に応じて変更 4 | 5 | # アクセスログとエラーログの設定 (任意) 6 | access_log /var/log/nginx/access.log; 7 | error_log /var/log/nginx/error.log; 8 | 9 | location / { 10 | # upstream 'app' サービスのポート 8080 へリクエストを転送 11 | proxy_pass http://app:8080; 12 | 13 | # プロキシ経由でオリジナルのヘッダー情報をバックエンドに渡す設定 14 | proxy_set_header Host $host; 15 | proxy_set_header X-Real-IP $remote_addr; 16 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 17 | proxy_set_header X-Forwarded-Proto $scheme; 18 | 19 | # WebSocket を利用する場合 (任意) 20 | # proxy_http_version 1.1; 21 | # proxy_set_header Upgrade $http_upgrade; 22 | # proxy_set_header Connection "upgrade"; 23 | } 24 | 25 | # 静的ファイルを Nginx で配信する場合 (任意) 26 | # 例: /static/ へのリクエストを /app/static ディレクトリのファイルで処理 27 | # location /static/ { 28 | # alias /app/static/; # appサービスの /app/static を指す (compose.ymlでのマウントが必要) 29 | # expires 1d; # キャッシュ期間 30 | # } 31 | } -------------------------------------------------------------------------------- /env_laravel1/app/Dockerfile: -------------------------------------------------------------------------------- 1 | # 軽量PHPイメージ 2 | FROM php:8.3-fpm-alpine as runtime 3 | 4 | # Composer 実行ファイルをコピー 5 | COPY --from=composer:latest /usr/bin/composer /usr/bin/composer 6 | 7 | RUN addgroup -S -g 1000 appgroup && \ 8 | adduser -S -u 1000 -G appgroup -s /bin/sh appuser 9 | 10 | RUN apk update && \ 11 | apk add --no-cache \ 12 | tzdata \ 13 | icu-libs \ 14 | libzip \ 15 | oniguruma \ 16 | git \ 17 | && \ 18 | apk add --no-cache --virtual .build-deps \ 19 | $PHPIZE_DEPS \ 20 | linux-headers \ 21 | icu-dev \ 22 | libzip-dev \ 23 | oniguruma-dev \ 24 | && \ 25 | pecl install xdebug && \ 26 | docker-php-ext-configure zip && \ 27 | docker-php-ext-install -j$(nproc) \ 28 | pdo_mysql \ 29 | intl \ 30 | zip \ 31 | mbstring \ 32 | && \ 33 | docker-php-ext-enable xdebug && \ 34 | apk del .build-deps && \ 35 | rm -rf /var/cache/apk/* 36 | 37 | # PHP設定ファイルをコピー (Dockerfileと同じディレクトリから) 38 | COPY php.ini /usr/local/etc/php/conf.d/custom-php.ini 39 | 40 | WORKDIR /var/www/html 41 | 42 | ENV TZ="Asia/Tokyo" 43 | USER appuser -------------------------------------------------------------------------------- /ex11/compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | db: 3 | image: postgres:17.4-alpine 4 | container_name: 'ex11-db' # コンテナ名は元の例に合わせています 5 | expose: 6 | - "5432" 7 | environment: 8 | POSTGRES_DB: ${POSTGRES_DB} 9 | POSTGRES_USER: ${POSTGRES_USER} 10 | POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} 11 | # (オプション) データを永続化する場合は volumes を追加 12 | # volumes: 13 | # - postgres_data:/var/lib/postgresql/data 14 | 15 | php: 16 | build: 17 | context: ./php 18 | dockerfile: Dockerfile # Dockerfile名を明示 (デフォルト名なら省略可) 19 | container_name: 'ex11-php' # コンテナ名は元の例に合わせています 20 | volumes: 21 | # ホストの ./php/src ディレクトリをコンテナの /app/src にマウントする 22 | # これにより、開発中はホスト側のファイルで上書きされ、即時反映される 23 | - ./php/src:/app/src 24 | depends_on: 25 | - db 26 | environment: 27 | # .env ファイルから読み込んだ変数をPHPアプリケーション用に設定 28 | DB_HOST: ${DB_HOST} 29 | DB_PORT: ${DB_PORT} 30 | DB_DATABASE: ${DB_DATABASE} 31 | DB_USER: ${DB_USER} 32 | DB_PASSWORD: ${DB_PASSWORD} 33 | command: ["sleep", "infinity"] 34 | 35 | # (オプション) DBデータを永続化するための名前付きボリューム定義 36 | # volumes: 37 | # postgres_data: -------------------------------------------------------------------------------- /env_laravel1/app/sample/resources/views/book/index.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Books 7 | 11 | 12 | 13 |

Book List

14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | @forelse($books as $book) 24 | 25 | 26 | 27 | 28 | 29 | @empty 30 | 31 | 32 | 33 | @endforelse 34 | 35 |
IDTitleTimestamp
{{ $book->id }}{{ $book->title }}{{ $book->insert_timestamp }}
No books found.
36 | 37 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/resources/views/book/index.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Books 7 | 11 | 12 | 13 |

Book List

14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | @forelse($books as $book) 24 | 25 | 26 | 27 | 28 | 29 | @empty 30 | 31 | 32 | 33 | @endforelse 34 | 35 |
IDTitleTimestamp
{{ $book->id }}{{ $book->title }}{{ $book->insert_timestamp }}
No books found.
36 | 37 | -------------------------------------------------------------------------------- /env_go_mysql/app/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 書籍リスト 7 | 14 | 15 | 16 |

書籍リスト

17 | {{ if .books }} 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | {{ range .books }} 28 | 29 | 30 | 31 | 32 | 33 | {{ end }} 34 | 35 |
IDタイトル登録日時
{{ .Id }}{{ .Title }}{{ if .InsertTimestamp }}{{ .InsertTimestamp.Format "2006-01-02 15:04:05" }}{{ else }}N/A{{ end }}
36 | {{ else }} 37 |

登録されている書籍はありません。

38 | {{ end }} 39 | 40 | -------------------------------------------------------------------------------- /env_go_mysql_nginx/app/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 書籍リスト 7 | 14 | 15 | 16 |

書籍リスト

17 | {{ if .books }} 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | {{ range .books }} 28 | 29 | 30 | 31 | 32 | 33 | {{ end }} 34 | 35 |
IDタイトル登録日時
{{ .Id }}{{ .Title }}{{ if .InsertTimestamp }}{{ .InsertTimestamp.Format "2006-01-02 15:04:05" }}{{ else }}N/A{{ end }}
36 | {{ else }} 37 |

登録されている書籍はありません。

38 | {{ end }} 39 | 40 | -------------------------------------------------------------------------------- /env_go_mysql_nginx_cert/app/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 書籍リスト 7 | 14 | 15 | 16 |

書籍リスト

17 | {{ if .books }} 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | {{ range .books }} 28 | 29 | 30 | 31 | 32 | 33 | {{ end }} 34 | 35 |
IDタイトル登録日時
{{ .Id }}{{ .Title }}{{ if .InsertTimestamp }}{{ .InsertTimestamp.Format "2006-01-02 15:04:05" }}{{ else }}N/A{{ end }}
36 | {{ else }} 37 |

登録されている書籍はありません。

38 | {{ end }} 39 | 40 | -------------------------------------------------------------------------------- /env_https/app/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "time" 5 | "log" 6 | "gorm.io/gorm" 7 | "gorm.io/driver/mysql" 8 | "net/http" 9 | "github.com/gin-gonic/gin" 10 | ) 11 | 12 | // 構造体の定義 13 | type Books struct { 14 | Id int `gorm:"column:id"` 15 | Title string `gorm:"column:title"` 16 | InsertTimestamp *time.Time `gorm:"column:insert_timestamp"` 17 | } 18 | 19 | func main() { 20 | // DBへ接続 21 | dsn := "my:my@tcp(https1-db:3306)/my?charset=utf8mb4&parseTime=True&loc=Local" 22 | db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{}) 23 | if err != nil { 24 | panic(err) 25 | } 26 | // 使い終わったらDB接続を閉じる 27 | mydb, err := db.DB() 28 | defer mydb.Close() 29 | 30 | // データを格納する変数を定義 31 | books := []Books{} 32 | 33 | // booksテーブルのレコードを全て取得 34 | db.Find(&books) 35 | 36 | // Ginの準備 37 | router := gin.Default() 38 | // テンプレートフォルダを指定 39 | router.LoadHTMLGlob("templates/*") 40 | 41 | // リクエストに対する応答を定義 42 | router.GET("/", func(c *gin.Context){ 43 | c.HTML(http.StatusOK, "index.html", gin.H{"books": books}) 44 | // ログに出力 45 | log.Println("アクセスがありました。booksのレコード数:", len(books)) 46 | }) 47 | 48 | // 接続待ち 49 | router.Run(":3000") 50 | } -------------------------------------------------------------------------------- /env_node1/.devcontainer/compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | app: 3 | build: 4 | context: ../app 5 | ports: 6 | - '3000:3000' 7 | stdin_open: true 8 | tty: true 9 | volumes: 10 | - ../app:/var/www/html 11 | depends_on: 12 | db: 13 | condition: service_healthy 14 | environment: 15 | - WATCHPACK_POLLING=true 16 | 17 | db: 18 | image: mongo:8.0 19 | expose: 20 | - "27017" 21 | environment: 22 | - TZ=Asia/Tokyo 23 | - MONGO_INITDB_ROOT_USERNAME=${MONGO_INITDB_ROOT_USERNAME} 24 | - MONGO_INITDB_ROOT_PASSWORD=${MONGO_INITDB_ROOT_PASSWORD} 25 | - MONGO_INITDB_DATABASE=${MONGO_INITDB_DATABASE} 26 | volumes: 27 | - db-data:/data/db 28 | - ../db/init:/docker-entrypoint-initdb.d 29 | healthcheck: 30 | test: | 31 | mongosh --host localhost --port 27017 \ 32 | --username $$MONGO_INITDB_ROOT_USERNAME \ 33 | --password $$MONGO_INITDB_ROOT_PASSWORD \ 34 | --authenticationDatabase admin --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 1)' 35 | interval: 10s 36 | timeout: 5s 37 | retries: 5 38 | start_period: 30s 39 | 40 | volumes: 41 | db-data: -------------------------------------------------------------------------------- /env_https/.devcontainer/compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | app: 3 | image: https1/app:1.0 4 | build: ./app 5 | container_name: 'https1-app' 6 | expose: 7 | - "3000" 8 | stdin_open: true 9 | tty: true 10 | working_dir: '/var/www/html' 11 | volumes: 12 | - ../app:/var/www/html 13 | depends_on: 14 | - db 15 | 16 | db: 17 | image: https1/mysql:1.0 18 | build: ./db 19 | container_name: 'https1-db' 20 | expose: 21 | - "3306" 22 | environment: 23 | - TZ=Asia/Tokyo 24 | - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} 25 | - MYSQL_DATABASE=${MYSQL_DATABASE} 26 | - MYSQL_USER=${MYSQL_USER} 27 | - MYSQL_PASSWORD=${MYSQL_PASSWORD} 28 | volumes: 29 | - ../db/database:/var/lib/mysql 30 | - ../db/init:/docker-entrypoint-initdb.d 31 | 32 | web: 33 | image: nginx:1.19 34 | container_name: 'https1-web' 35 | ports: 36 | - '443:443' 37 | depends_on: 38 | - app 39 | volumes: 40 | - ./web/default.conf:/etc/nginx/conf.d/default.conf 41 | - ./web/localhost.pem:/etc/certs/localhost.pem 42 | - ./web/localhost-key.pem:/etc/certs/localhost-key.pem 43 | - ../app:/var/www/html -------------------------------------------------------------------------------- /ex11/php/src/sample1.php: -------------------------------------------------------------------------------- 1 | setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 24 | 25 | echo "データベースに接続しました。\n"; 26 | 27 | // pg_userテーブルの内容を取得するクエリを実行 28 | $stmt = $pdo->query('SELECT usename, usesysid FROM pg_catalog.pg_user'); 29 | 30 | // 結果を取得して表示 31 | echo "pg_user テーブルの内容:\n"; 32 | while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { 33 | print_r($row); 34 | } 35 | 36 | } catch (PDOException $e) { 37 | // 接続またはクエリ実行中にエラーが発生した場合 38 | echo "データベースエラー: " . $e->getMessage() . "\n"; 39 | exit(1); 40 | } 41 | 42 | ?> -------------------------------------------------------------------------------- /ex21/php/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Listen for Xdebug", // Webリクエストのデバッグ用設定 6 | "type": "php", // デバッガーの種類 (xdebug.php-debug 拡張機能用) 7 | "request": "launch", 8 | "port": 9003, // Xdebug が接続待機するポート (php.ini/xdebug.ini の xdebug.client_port と一致) 9 | "pathMappings": { 10 | "/app": "${workspaceFolder}" // コンテナ内のパス (/app) をホストのワークスペースパスにマッピング 11 | }, 12 | "hostname": "0.0.0.0", // VS Code デバッガーが接続を待機するアドレス 13 | "log": false // デバッグアダプタのログ (問題発生時にtrueに) 14 | }, 15 | { 16 | "name": "PHP: Current File", // CLI スクリプトのデバッグ用設定 17 | "type": "php", 18 | "request": "launch", 19 | "program": "${file}", // 現在アクティブなファイルを実行 20 | "cwd": "${workspaceFolder}", 21 | "runtimeExecutable": "/usr/local/bin/php", 22 | "externalConsole": false, 23 | "internalConsoleOptions": "openOnSessionStart" 24 | // CLIデバッグでもXdebugを使う場合、環境変数 XDEBUG_MODE=debug XDEBUG_CONFIG="client_host=localhost client_port=9003" などを設定する必要がある場合がある 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /env_laravel1/app/sample/config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'token' => env('POSTMARK_TOKEN'), 19 | ], 20 | 21 | 'ses' => [ 22 | 'key' => env('AWS_ACCESS_KEY_ID'), 23 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 24 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 25 | ], 26 | 27 | 'resend' => [ 28 | 'key' => env('RESEND_KEY'), 29 | ], 30 | 31 | 'slack' => [ 32 | 'notifications' => [ 33 | 'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'), 34 | 'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'), 35 | ], 36 | ], 37 | 38 | ]; 39 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/Dockerfile: -------------------------------------------------------------------------------- 1 | # 軽量PHP-FPMイメージ 2 | FROM php:8.3-fpm-alpine as runtime 3 | 4 | # Composer 実行ファイルをコピー 5 | COPY --from=composer:latest /usr/bin/composer /usr/bin/composer 6 | 7 | RUN addgroup -S -g 1000 appgroup && \ 8 | adduser -S -u 1000 -G appgroup -s /bin/sh appuser 9 | 10 | RUN apk update && \ 11 | apk add --no-cache \ 12 | tzdata \ 13 | icu-libs \ 14 | libzip \ 15 | oniguruma \ 16 | git \ 17 | && \ 18 | apk add --no-cache --virtual .build-deps \ 19 | $PHPIZE_DEPS \ 20 | linux-headers \ 21 | icu-dev \ 22 | libzip-dev \ 23 | oniguruma-dev \ 24 | && \ 25 | pecl install xdebug && \ 26 | docker-php-ext-configure zip && \ 27 | docker-php-ext-install -j$(nproc) \ 28 | pdo_mysql \ 29 | intl \ 30 | zip \ 31 | mbstring \ 32 | && \ 33 | docker-php-ext-enable xdebug && \ 34 | apk del .build-deps && \ 35 | rm -rf /var/cache/apk/* 36 | 37 | # PHP設定ファイルをコピー (Dockerfileと同じディレクトリから) 38 | COPY php.ini /usr/local/etc/php/conf.d/custom-php.ini 39 | 40 | WORKDIR /var/www/html 41 | 42 | ENV TZ="Asia/Tokyo" 43 | USER appuser 44 | 45 | # PHP-FPM をフォアグラウンドで起動 (ベースイメージに含まれている場合が多いが明示) 46 | CMD ["php-fpm"] -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'token' => env('POSTMARK_TOKEN'), 19 | ], 20 | 21 | 'ses' => [ 22 | 'key' => env('AWS_ACCESS_KEY_ID'), 23 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 24 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 25 | ], 26 | 27 | 'resend' => [ 28 | 'key' => env('RESEND_KEY'), 29 | ], 30 | 31 | 'slack' => [ 32 | 'notifications' => [ 33 | 'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'), 34 | 'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'), 35 | ], 36 | ], 37 | 38 | ]; 39 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/app/Models/User.php: -------------------------------------------------------------------------------- 1 | */ 13 | use HasFactory, Notifiable; 14 | 15 | /** 16 | * The attributes that are mass assignable. 17 | * 18 | * @var list 19 | */ 20 | protected $fillable = [ 21 | 'name', 22 | 'email', 23 | 'password', 24 | ]; 25 | 26 | /** 27 | * The attributes that should be hidden for serialization. 28 | * 29 | * @var list 30 | */ 31 | protected $hidden = [ 32 | 'password', 33 | 'remember_token', 34 | ]; 35 | 36 | /** 37 | * Get the attributes that should be cast. 38 | * 39 | * @return array 40 | */ 41 | protected function casts(): array 42 | { 43 | return [ 44 | 'email_verified_at' => 'datetime', 45 | 'password' => 'hashed', 46 | ]; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/app/Models/User.php: -------------------------------------------------------------------------------- 1 | */ 13 | use HasFactory, Notifiable; 14 | 15 | /** 16 | * The attributes that are mass assignable. 17 | * 18 | * @var list 19 | */ 20 | protected $fillable = [ 21 | 'name', 22 | 'email', 23 | 'password', 24 | ]; 25 | 26 | /** 27 | * The attributes that should be hidden for serialization. 28 | * 29 | * @var list 30 | */ 31 | protected $hidden = [ 32 | 'password', 33 | 'remember_token', 34 | ]; 35 | 36 | /** 37 | * Get the attributes that should be cast. 38 | * 39 | * @return array 40 | */ 41 | protected function casts(): array 42 | { 43 | return [ 44 | 'email_verified_at' => 'datetime', 45 | 'password' => 'hashed', 46 | ]; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | 11 | */ 12 | class UserFactory extends Factory 13 | { 14 | /** 15 | * The current password being used by the factory. 16 | */ 17 | protected static ?string $password; 18 | 19 | /** 20 | * Define the model's default state. 21 | * 22 | * @return array 23 | */ 24 | public function definition(): array 25 | { 26 | return [ 27 | 'name' => fake()->name(), 28 | 'email' => fake()->unique()->safeEmail(), 29 | 'email_verified_at' => now(), 30 | 'password' => static::$password ??= Hash::make('password'), 31 | 'remember_token' => Str::random(10), 32 | ]; 33 | } 34 | 35 | /** 36 | * Indicate that the model's email address should be unverified. 37 | */ 38 | public function unverified(): static 39 | { 40 | return $this->state(fn (array $attributes) => [ 41 | 'email_verified_at' => null, 42 | ]); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | 11 | */ 12 | class UserFactory extends Factory 13 | { 14 | /** 15 | * The current password being used by the factory. 16 | */ 17 | protected static ?string $password; 18 | 19 | /** 20 | * Define the model's default state. 21 | * 22 | * @return array 23 | */ 24 | public function definition(): array 25 | { 26 | return [ 27 | 'name' => fake()->name(), 28 | 'email' => fake()->unique()->safeEmail(), 29 | 'email_verified_at' => now(), 30 | 'password' => static::$password ??= Hash::make('password'), 31 | 'remember_token' => Str::random(10), 32 | ]; 33 | } 34 | 35 | /** 36 | * Indicate that the model's email address should be unverified. 37 | */ 38 | public function unverified(): static 39 | { 40 | return $this->state(fn (array $attributes) => [ 41 | 'email_verified_at' => null, 42 | ]); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | tests/Unit 10 | 11 | 12 | tests/Feature 13 | 14 | 15 | 16 | 17 | app 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | tests/Unit 10 | 11 | 12 | tests/Feature 13 | 14 | 15 | 16 | 17 | app 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/nginx/default.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | server_name localhost; # 必要に応じて変更 4 | root /var/www/html/sample/public; # Laravelの公開ディレクトリを指定 5 | index index.php index.html index.htm; 6 | 7 | charset utf-8; 8 | 9 | # アクセスログとエラーログの出力先 (標準出力/標準エラーへ) 10 | access_log /dev/stdout; 11 | error_log /dev/stderr warn; 12 | 13 | location / { 14 | # Laravel のルーティングに対応するための設定 15 | try_files $uri $uri/ /index.php?$query_string; 16 | } 17 | 18 | # PHPファイルへのリクエストをPHP-FPMに転送 19 | location ~ \.php$ { 20 | try_files $uri =404; 21 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 22 | # appサービス(PHP-FPM)のコンテナ名とポートを指定 23 | fastcgi_pass app:9000; 24 | fastcgi_index index.php; 25 | include fastcgi_params; 26 | # SCRIPT_FILENAME パラメータを正しく設定 27 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 28 | fastcgi_param PATH_INFO $fastcgi_path_info; 29 | # タイムアウト設定 (必要に応じて調整) 30 | fastcgi_read_timeout 300; 31 | } 32 | 33 | # .htaccess ファイルへのアクセスを拒否 34 | location ~ /\.ht { 35 | deny all; 36 | } 37 | 38 | # favicon.ico と robots.txt のログを抑制 (任意) 39 | location = /favicon.ico { access_log off; log_not_found off; } 40 | location = /robots.txt { access_log off; log_not_found off; } 41 | } -------------------------------------------------------------------------------- /env_laravel1/app/sample/.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | 7 | APP_LOCALE=en 8 | APP_FALLBACK_LOCALE=en 9 | APP_FAKER_LOCALE=en_US 10 | 11 | APP_MAINTENANCE_DRIVER=file 12 | # APP_MAINTENANCE_STORE=database 13 | 14 | PHP_CLI_SERVER_WORKERS=4 15 | 16 | BCRYPT_ROUNDS=12 17 | 18 | LOG_CHANNEL=stack 19 | LOG_STACK=single 20 | LOG_DEPRECATIONS_CHANNEL=null 21 | LOG_LEVEL=debug 22 | 23 | DB_CONNECTION=sqlite 24 | # DB_HOST=127.0.0.1 25 | # DB_PORT=3306 26 | # DB_DATABASE=laravel 27 | # DB_USERNAME=root 28 | # DB_PASSWORD= 29 | 30 | SESSION_DRIVER=database 31 | SESSION_LIFETIME=120 32 | SESSION_ENCRYPT=false 33 | SESSION_PATH=/ 34 | SESSION_DOMAIN=null 35 | 36 | BROADCAST_CONNECTION=log 37 | FILESYSTEM_DISK=local 38 | QUEUE_CONNECTION=database 39 | 40 | CACHE_STORE=database 41 | # CACHE_PREFIX= 42 | 43 | MEMCACHED_HOST=127.0.0.1 44 | 45 | REDIS_CLIENT=phpredis 46 | REDIS_HOST=127.0.0.1 47 | REDIS_PASSWORD=null 48 | REDIS_PORT=6379 49 | 50 | MAIL_MAILER=log 51 | MAIL_SCHEME=null 52 | MAIL_HOST=127.0.0.1 53 | MAIL_PORT=2525 54 | MAIL_USERNAME=null 55 | MAIL_PASSWORD=null 56 | MAIL_FROM_ADDRESS="hello@example.com" 57 | MAIL_FROM_NAME="${APP_NAME}" 58 | 59 | AWS_ACCESS_KEY_ID= 60 | AWS_SECRET_ACCESS_KEY= 61 | AWS_DEFAULT_REGION=us-east-1 62 | AWS_BUCKET= 63 | AWS_USE_PATH_STYLE_ENDPOINT=false 64 | 65 | VITE_APP_NAME="${APP_NAME}" 66 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | 7 | APP_LOCALE=en 8 | APP_FALLBACK_LOCALE=en 9 | APP_FAKER_LOCALE=en_US 10 | 11 | APP_MAINTENANCE_DRIVER=file 12 | # APP_MAINTENANCE_STORE=database 13 | 14 | PHP_CLI_SERVER_WORKERS=4 15 | 16 | BCRYPT_ROUNDS=12 17 | 18 | LOG_CHANNEL=stack 19 | LOG_STACK=single 20 | LOG_DEPRECATIONS_CHANNEL=null 21 | LOG_LEVEL=debug 22 | 23 | DB_CONNECTION=sqlite 24 | # DB_HOST=127.0.0.1 25 | # DB_PORT=3306 26 | # DB_DATABASE=laravel 27 | # DB_USERNAME=root 28 | # DB_PASSWORD= 29 | 30 | SESSION_DRIVER=database 31 | SESSION_LIFETIME=120 32 | SESSION_ENCRYPT=false 33 | SESSION_PATH=/ 34 | SESSION_DOMAIN=null 35 | 36 | BROADCAST_CONNECTION=log 37 | FILESYSTEM_DISK=local 38 | QUEUE_CONNECTION=database 39 | 40 | CACHE_STORE=database 41 | # CACHE_PREFIX= 42 | 43 | MEMCACHED_HOST=127.0.0.1 44 | 45 | REDIS_CLIENT=phpredis 46 | REDIS_HOST=127.0.0.1 47 | REDIS_PASSWORD=null 48 | REDIS_PORT=6379 49 | 50 | MAIL_MAILER=log 51 | MAIL_SCHEME=null 52 | MAIL_HOST=127.0.0.1 53 | MAIL_PORT=2525 54 | MAIL_USERNAME=null 55 | MAIL_PASSWORD=null 56 | MAIL_FROM_ADDRESS="hello@example.com" 57 | MAIL_FROM_NAME="${APP_NAME}" 58 | 59 | AWS_ACCESS_KEY_ID= 60 | AWS_SECRET_ACCESS_KEY= 61 | AWS_DEFAULT_REGION=us-east-1 62 | AWS_BUCKET= 63 | AWS_USE_PATH_STYLE_ENDPOINT=false 64 | 65 | VITE_APP_NAME="${APP_NAME}" 66 | -------------------------------------------------------------------------------- /ex04/Dockerfile: -------------------------------------------------------------------------------- 1 | # --- ステージ 1: ビルドステージ (builder) --- 2 | FROM composer:2 AS builder 3 | 4 | # 作業ディレクトリを設定 5 | WORKDIR /app 6 | 7 | # 依存関係定義ファイルのみ先にコピー 8 | COPY composer.json composer.lock* ./ 9 | # composer.lock がなくてもエラーにならないようにワイルドカードを使用 (初回ビルドなど) 10 | 11 | # 依存関係をインストール (今回は require が空なので vendor は実質空) 12 | # 依存関係がある場合はここで vendor ディレクトリが生成される 13 | RUN composer install --no-dev --no-interaction --optimize-autoloader 14 | 15 | # アプリケーションコードをコピー 16 | # public ディレクトリをコピー 17 | COPY public ./public 18 | # src ディレクトリなど他のコードがあれば同様にコピー 19 | # COPY src ./src 20 | 21 | # --- ステージ 2: 最終ステージ (runtime) --- 22 | # 軽量なPHPイメージを使用 (CLI/ビルトインサーバー用) 23 | FROM php:8.3-alpine AS runtime 24 | 25 | # アプリケーション実行用の非rootユーザーを作成・設定 26 | RUN addgroup -S appgroup && adduser -S appuser -G appgroup 27 | RUN mkdir -p /app && chown -R appuser:appgroup /app 28 | 29 | # 作業ディレクトリを設定 30 | WORKDIR /app 31 | 32 | # ビルドステージから必要なアーティファクトのみをコピー 33 | # vendor ディレクトリ (依存関係があれば) をコピー 34 | COPY --from=builder --chown=appuser:appgroup /app/vendor ./vendor 35 | # アプリケーションコード (public ディレクトリ) をコピー 36 | COPY --from=builder --chown=appuser:appgroup /app/public ./public 37 | 38 | # 以降の命令は 'appuser' として実行 39 | USER appuser 40 | 41 | # アプリケーション (PHPビルトインサーバー) がリッスンするポートを指定 42 | EXPOSE 8000 43 | 44 | # コンテナ起動時にPHPビルトインサーバーを実行するコマンド 45 | # -S 0.0.0.0:8000: すべてのインターフェースでポート8000をリッスン 46 | # -t public: ドキュメントルートを public ディレクトリに設定 47 | CMD ["php", "-S", "0.0.0.0:8000", "-t", "public"] -------------------------------------------------------------------------------- /env_laravel1/app/sample/.env: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY=base64:44e77sXXpKNX5+2z99W4vDfJ+9mAW/R10+vIiyFZFKU= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost:8000 6 | 7 | APP_LOCALE=en 8 | APP_FALLBACK_LOCALE=en 9 | APP_FAKER_LOCALE=en_US 10 | 11 | APP_MAINTENANCE_DRIVER=file 12 | # APP_MAINTENANCE_STORE=database 13 | 14 | PHP_CLI_SERVER_WORKERS=4 15 | 16 | BCRYPT_ROUNDS=12 17 | 18 | LOG_CHANNEL=stack 19 | LOG_STACK=single,stderr 20 | LOG_DEPRECATIONS_CHANNEL=null 21 | LOG_LEVEL=debug 22 | 23 | DB_CONNECTION=mysql 24 | DB_HOST=db 25 | DB_PORT=3306 26 | DB_DATABASE=my 27 | DB_USERNAME=my 28 | DB_PASSWORD=my 29 | 30 | SESSION_DRIVER=file 31 | SESSION_LIFETIME=120 32 | SESSION_ENCRYPT=false 33 | SESSION_PATH=/ 34 | SESSION_DOMAIN=null 35 | 36 | BROADCAST_CONNECTION=log 37 | FILESYSTEM_DISK=local 38 | QUEUE_CONNECTION=database 39 | 40 | CACHE_STORE=database 41 | # CACHE_PREFIX= 42 | 43 | MEMCACHED_HOST=127.0.0.1 44 | 45 | REDIS_CLIENT=phpredis 46 | REDIS_HOST=127.0.0.1 47 | REDIS_PASSWORD=null 48 | REDIS_PORT=6379 49 | 50 | MAIL_MAILER=log 51 | MAIL_SCHEME=null 52 | MAIL_HOST=127.0.0.1 53 | MAIL_PORT=2525 54 | MAIL_USERNAME=null 55 | MAIL_PASSWORD=null 56 | MAIL_FROM_ADDRESS="hello@example.com" 57 | MAIL_FROM_NAME="${APP_NAME}" 58 | 59 | AWS_ACCESS_KEY_ID= 60 | AWS_SECRET_ACCESS_KEY= 61 | AWS_DEFAULT_REGION=us-east-1 62 | AWS_BUCKET= 63 | AWS_USE_PATH_STYLE_ENDPOINT=false 64 | 65 | VITE_APP_NAME="${APP_NAME}" 66 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/.env: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY=base64:a4dRD3YJNXaz5xs14WchFAnOB8KmjQ5QkZZHmXwIUI0= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | 7 | APP_LOCALE=en 8 | APP_FALLBACK_LOCALE=en 9 | APP_FAKER_LOCALE=en_US 10 | 11 | APP_MAINTENANCE_DRIVER=file 12 | # APP_MAINTENANCE_STORE=database 13 | 14 | PHP_CLI_SERVER_WORKERS=4 15 | 16 | BCRYPT_ROUNDS=12 17 | 18 | # LOG_CHANNEL=stack 19 | LOG_CHANNEL=stderr 20 | LOG_STACK=single 21 | LOG_DEPRECATIONS_CHANNEL=null 22 | LOG_LEVEL=debug 23 | 24 | DB_CONNECTION=mysql 25 | DB_HOST=db 26 | DB_PORT=3306 27 | DB_DATABASE=my 28 | DB_USERNAME=my 29 | DB_PASSWORD=my 30 | 31 | SESSION_DRIVER=database 32 | SESSION_LIFETIME=120 33 | SESSION_ENCRYPT=false 34 | SESSION_PATH=/ 35 | SESSION_DOMAIN=null 36 | 37 | BROADCAST_CONNECTION=log 38 | FILESYSTEM_DISK=local 39 | QUEUE_CONNECTION=database 40 | 41 | CACHE_STORE=database 42 | # CACHE_PREFIX= 43 | 44 | MEMCACHED_HOST=127.0.0.1 45 | 46 | REDIS_CLIENT=phpredis 47 | REDIS_HOST=127.0.0.1 48 | REDIS_PASSWORD=null 49 | REDIS_PORT=6379 50 | 51 | MAIL_MAILER=log 52 | MAIL_SCHEME=null 53 | MAIL_HOST=127.0.0.1 54 | MAIL_PORT=2525 55 | MAIL_USERNAME=null 56 | MAIL_PASSWORD=null 57 | MAIL_FROM_ADDRESS="hello@example.com" 58 | MAIL_FROM_NAME="${APP_NAME}" 59 | 60 | AWS_ACCESS_KEY_ID= 61 | AWS_SECRET_ACCESS_KEY= 62 | AWS_DEFAULT_REGION=us-east-1 63 | AWS_BUCKET= 64 | AWS_USE_PATH_STYLE_ENDPOINT=false 65 | 66 | VITE_APP_NAME="${APP_NAME}" 67 | -------------------------------------------------------------------------------- /ex11/php/Dockerfile: -------------------------------------------------------------------------------- 1 | # --- ステージ 1: ビルドステージ (builder) --- 2 | # Composer公式イメージをベースに使用 (PHPバージョンは適宜合わせる) 3 | FROM composer:2 AS builder 4 | 5 | # 作業ディレクトリを設定 6 | WORKDIR /app 7 | 8 | # 依存関係定義ファイルのみ先にコピー (キャッシュ効率化のため) 9 | COPY composer.json composer.lock* ./ 10 | # composer.lock がなくてもエラーにならないようにワイルドカードを使用 11 | 12 | # 依存関係をインストール (今回は require が空) 13 | RUN composer install --no-dev --no-interaction --optimize-autoloader 14 | 15 | # --- ステージ 2: 最終ステージ (runtime) --- 16 | # 軽量なPHP-CLIイメージを使用 (バージョンはビルドステージと合わせる) 17 | FROM php:8.3-cli-alpine AS runtime 18 | 19 | # アプリケーション実行用の非rootユーザーを作成・設定 (Alpine Linux) 20 | RUN addgroup -S appgroup && adduser -S appuser -G appgroup 21 | RUN mkdir -p /app && chown -R appuser:appgroup /app 22 | 23 | # PostgreSQL接続に必要なPHP拡張(pdo_pgsql)とOSライブラリをインストール 24 | # apk add --no-cache でパッケージを追加し、docker-php-ext-install で拡張を有効化 25 | # postgresql-libs は pdo_pgsql の実行時依存関係 26 | RUN apk add --no-cache --virtual .persistent-deps \ 27 | postgresql-libs \ 28 | && apk add --no-cache --virtual .build-deps \ 29 | $PHPIZE_DEPS \ 30 | postgresql-dev \ 31 | && docker-php-ext-install pdo_pgsql \ 32 | && apk del .build-deps 33 | 34 | # 作業ディレクトリを設定 35 | WORKDIR /app 36 | 37 | # ビルドステージから vendor ディレクトリ (依存関係) をコピー 38 | COPY --from=builder --chown=appuser:appgroup /app/vendor ./vendor 39 | 40 | # アプリケーションコードをコピー 41 | COPY --chown=appuser:appgroup src ./src 42 | 43 | # 以降の命令は 'appuser' として実行 44 | USER appuser 45 | 46 | # コンテナ起動時にデフォルトで実行されるコマンドを設定 47 | # (compose.yml の command を削除した場合にこれが使われる) 48 | CMD ["php", "src/sample1.php"] -------------------------------------------------------------------------------- /env_node1/app/sample/index.js: -------------------------------------------------------------------------------- 1 | // モジュールの読込 2 | const express = require('express'); 3 | const app = express(); 4 | const mongoose = require('mongoose'); 5 | const moment = require('moment'); 6 | // スキーマ定義の読込 7 | const Book = require('./book_model.js') 8 | 9 | // viewエンジンにejsを設定 10 | app.set("view engine", "ejs"); 11 | app.set('views', './views'); 12 | 13 | // データベースへの接続文字列 14 | const dbUrl = `mongodb://user1:user1@db:27017/mongo?authSource=mongo`; 15 | 16 | mongoose.connect(dbUrl) 17 | .then(() => { 18 | console.log('Connected to database.'); 19 | }).catch((err) => { 20 | console.error('Failed to connect to database:', err); 21 | process.exit(1); 22 | }); 23 | 24 | // ルートパスへのGETリクエスト 25 | app.get('/', async (req, res, next) => { 26 | try { 27 | let books = await Book.find(); 28 | console.log('booksの件数:', books.length); 29 | 30 | const formattedBooks = books.map(book => { 31 | const formattedDate = book.insert_timestamp 32 | ? moment(book.insert_timestamp).format('YYYY-MM-DD HH:mm:ss') 33 | : 'N/A'; 34 | return { 35 | id: book.id || book._id.toHexString(), 36 | title: book.title, 37 | date: formattedDate 38 | }; 39 | }); 40 | res.render("index", { books: formattedBooks }); 41 | } catch (err) { 42 | console.error('Failed to fetch books:', err); 43 | next(err); 44 | } 45 | }); 46 | 47 | // ポート3000で待受 48 | const PORT = process.env.PORT || 3000; 49 | app.listen(PORT, () => { 50 | console.log(`Listening on port ${PORT}.`); 51 | }); 52 | 53 | // 基本的なエラーハンドリングミドルウェア 54 | app.use((err, req, res, next) => { 55 | console.error(err.stack); 56 | res.status(500).send('Something broke!'); 57 | }); -------------------------------------------------------------------------------- /env_laravel1/.devcontainer/compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | app: 3 | build: 4 | # ビルドコンテキストは app ディレクトリ 5 | context: ../app 6 | # Dockerfile はコンテキスト内の Dockerfile を指定 (デフォルト名なので省略可) 7 | # dockerfile: Dockerfile 8 | container_name: 'laravel-app' 9 | ports: 10 | - '8000:8000' 11 | working_dir: /var/www/html 12 | volumes: 13 | # ホストの app ディレクトリをマウント (コード同期) 14 | - ../app:/var/www/html 15 | depends_on: 16 | db: 17 | condition: service_healthy 18 | environment: 19 | # Laravelが必要とする環境変数を設定可能 (app/sample/.env も参照される) 20 | - APP_ENV=local 21 | - APP_DEBUG=true 22 | # DB接続情報は app/sample/.env で設定するのが一般的 23 | extra_hosts: 24 | - "host.docker.internal:host-gateway" 25 | tty: true 26 | 27 | db: 28 | build: 29 | # ビルドコンテキストは db ディレクトリ 30 | context: ../db 31 | # dockerfile: Dockerfile 32 | container_name: 'laravel-db' 33 | expose: 34 | - "3306" 35 | environment: 36 | # この compose.yml と同じディレクトリにある .env ファイルから読み込む 37 | MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} 38 | MYSQL_DATABASE: ${MYSQL_DATABASE} 39 | MYSQL_USER: ${MYSQL_USER} 40 | MYSQL_PASSWORD: ${MYSQL_PASSWORD} 41 | TZ: Asia/Tokyo 42 | volumes: 43 | # データベース永続化に名前付きボリュームを使用 44 | - db_data:/var/lib/mysql 45 | # 初期化SQLをマウント 46 | - ../db/init:/docker-entrypoint-initdb.d 47 | healthcheck: 48 | test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost", "-u$$MYSQL_USER", "-p$$MYSQL_PASSWORD"] 49 | interval: 10s 50 | timeout: 5s 51 | retries: 5 52 | start_period: 30s 53 | 54 | volumes: 55 | db_data: # データベース永続化用ボリューム -------------------------------------------------------------------------------- /env_node_nginx/.devcontainer/compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | web: 3 | image: nginx:stable-alpine 4 | ports: 5 | - '80:80' # ホストのポート80をコンテナのポート80にマッピング 6 | volumes: 7 | - ../web/nginx.conf:/etc/nginx/conf.d/default.conf:ro # Nginx設定ファイルを読み取り専用でマウント 8 | depends_on: 9 | - app # appサービスが起動してからwebサービスを起動 10 | 11 | app: 12 | build: 13 | context: ../app 14 | # ports: # Nginx経由でアクセスするため、直接ポートを公開しない 15 | # - '3000:3000' 16 | stdin_open: true 17 | tty: true 18 | volumes: 19 | - ../app:/var/www/html 20 | depends_on: 21 | db: 22 | condition: service_healthy # dbサービスのヘルスチェックが成功するまで待機 23 | environment: 24 | - WATCHPACK_POLLING=true # ファイル変更監視をポーリング方式に 25 | 26 | db: 27 | image: mongo:8.0 # MongoDBのLTS安定版イメージを使用 28 | # expose: # appサービスからの内部アクセスのみのため、公開は不要 29 | # - "27017" 30 | environment: 31 | - TZ=Asia/Tokyo 32 | - MONGO_INITDB_ROOT_USERNAME=${MONGO_INITDB_ROOT_USERNAME} 33 | - MONGO_INITDB_ROOT_PASSWORD=${MONGO_INITDB_ROOT_PASSWORD} 34 | - MONGO_INITDB_DATABASE=${MONGO_INITDB_DATABASE} 35 | volumes: 36 | - db-data:/data/db # 名前付きボリュームでデータを永続化 37 | - ../db/init:/docker-entrypoint-initdb.d # 初期化スクリプトをマウント 38 | healthcheck: 39 | test: | 40 | mongosh --host localhost --port 27017 \ 41 | --username $$MONGO_INITDB_ROOT_USERNAME \ 42 | --password $$MONGO_INITDB_ROOT_PASSWORD \ 43 | --authenticationDatabase admin --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 1)' 44 | interval: 10s 45 | timeout: 5s 46 | retries: 5 47 | start_period: 30s 48 | 49 | volumes: 50 | db-data: # dbサービスで使用する名前付きボリューム -------------------------------------------------------------------------------- /env_go_mysql/app/go.mod: -------------------------------------------------------------------------------- 1 | module myapp 2 | 3 | go 1.24.2 4 | 5 | require ( 6 | github.com/gin-gonic/gin v1.10.0 7 | gorm.io/driver/mysql v1.5.7 8 | gorm.io/gorm v1.26.0 9 | ) 10 | 11 | require ( 12 | github.com/bytedance/sonic v1.11.6 // indirect 13 | github.com/bytedance/sonic/loader v0.1.1 // indirect 14 | github.com/cloudwego/base64x v0.1.4 // indirect 15 | github.com/cloudwego/iasm v0.2.0 // indirect 16 | github.com/gabriel-vasile/mimetype v1.4.3 // indirect 17 | github.com/gin-contrib/sse v0.1.0 // indirect 18 | github.com/go-playground/locales v0.14.1 // indirect 19 | github.com/go-playground/universal-translator v0.18.1 // indirect 20 | github.com/go-playground/validator/v10 v10.20.0 // indirect 21 | github.com/go-sql-driver/mysql v1.7.0 // indirect 22 | github.com/goccy/go-json v0.10.2 // indirect 23 | github.com/jinzhu/inflection v1.0.0 // indirect 24 | github.com/jinzhu/now v1.1.5 // indirect 25 | github.com/json-iterator/go v1.1.12 // indirect 26 | github.com/klauspost/cpuid/v2 v2.2.7 // indirect 27 | github.com/leodido/go-urn v1.4.0 // indirect 28 | github.com/mattn/go-isatty v0.0.20 // indirect 29 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect 30 | github.com/modern-go/reflect2 v1.0.2 // indirect 31 | github.com/pelletier/go-toml/v2 v2.2.2 // indirect 32 | github.com/twitchyliquid64/golang-asm v0.15.1 // indirect 33 | github.com/ugorji/go/codec v1.2.12 // indirect 34 | golang.org/x/arch v0.8.0 // indirect 35 | golang.org/x/crypto v0.23.0 // indirect 36 | golang.org/x/net v0.25.0 // indirect 37 | golang.org/x/sys v0.20.0 // indirect 38 | golang.org/x/text v0.20.0 // indirect 39 | google.golang.org/protobuf v1.34.1 // indirect 40 | gopkg.in/yaml.v3 v3.0.1 // indirect 41 | ) 42 | -------------------------------------------------------------------------------- /env_go_mysql_nginx/app/go.mod: -------------------------------------------------------------------------------- 1 | module myapp 2 | 3 | go 1.24.2 4 | 5 | require ( 6 | github.com/gin-gonic/gin v1.10.0 7 | gorm.io/driver/mysql v1.5.7 8 | gorm.io/gorm v1.26.0 9 | ) 10 | 11 | require ( 12 | github.com/bytedance/sonic v1.11.6 // indirect 13 | github.com/bytedance/sonic/loader v0.1.1 // indirect 14 | github.com/cloudwego/base64x v0.1.4 // indirect 15 | github.com/cloudwego/iasm v0.2.0 // indirect 16 | github.com/gabriel-vasile/mimetype v1.4.3 // indirect 17 | github.com/gin-contrib/sse v0.1.0 // indirect 18 | github.com/go-playground/locales v0.14.1 // indirect 19 | github.com/go-playground/universal-translator v0.18.1 // indirect 20 | github.com/go-playground/validator/v10 v10.20.0 // indirect 21 | github.com/go-sql-driver/mysql v1.7.0 // indirect 22 | github.com/goccy/go-json v0.10.2 // indirect 23 | github.com/jinzhu/inflection v1.0.0 // indirect 24 | github.com/jinzhu/now v1.1.5 // indirect 25 | github.com/json-iterator/go v1.1.12 // indirect 26 | github.com/klauspost/cpuid/v2 v2.2.7 // indirect 27 | github.com/leodido/go-urn v1.4.0 // indirect 28 | github.com/mattn/go-isatty v0.0.20 // indirect 29 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect 30 | github.com/modern-go/reflect2 v1.0.2 // indirect 31 | github.com/pelletier/go-toml/v2 v2.2.2 // indirect 32 | github.com/twitchyliquid64/golang-asm v0.15.1 // indirect 33 | github.com/ugorji/go/codec v1.2.12 // indirect 34 | golang.org/x/arch v0.8.0 // indirect 35 | golang.org/x/crypto v0.23.0 // indirect 36 | golang.org/x/net v0.25.0 // indirect 37 | golang.org/x/sys v0.20.0 // indirect 38 | golang.org/x/text v0.20.0 // indirect 39 | google.golang.org/protobuf v1.34.1 // indirect 40 | gopkg.in/yaml.v3 v3.0.1 // indirect 41 | ) 42 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/database/migrations/0001_01_01_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('name'); 17 | $table->string('email')->unique(); 18 | $table->timestamp('email_verified_at')->nullable(); 19 | $table->string('password'); 20 | $table->rememberToken(); 21 | $table->timestamps(); 22 | }); 23 | 24 | Schema::create('password_reset_tokens', function (Blueprint $table) { 25 | $table->string('email')->primary(); 26 | $table->string('token'); 27 | $table->timestamp('created_at')->nullable(); 28 | }); 29 | 30 | Schema::create('sessions', function (Blueprint $table) { 31 | $table->string('id')->primary(); 32 | $table->foreignId('user_id')->nullable()->index(); 33 | $table->string('ip_address', 45)->nullable(); 34 | $table->text('user_agent')->nullable(); 35 | $table->longText('payload'); 36 | $table->integer('last_activity')->index(); 37 | }); 38 | } 39 | 40 | /** 41 | * Reverse the migrations. 42 | */ 43 | public function down(): void 44 | { 45 | Schema::dropIfExists('users'); 46 | Schema::dropIfExists('password_reset_tokens'); 47 | Schema::dropIfExists('sessions'); 48 | } 49 | }; 50 | -------------------------------------------------------------------------------- /env_go_mysql_nginx_cert/app/go.mod: -------------------------------------------------------------------------------- 1 | module myapp 2 | 3 | go 1.24.2 4 | 5 | require ( 6 | github.com/gin-gonic/gin v1.10.0 7 | gorm.io/driver/mysql v1.5.7 8 | gorm.io/gorm v1.26.0 9 | ) 10 | 11 | require ( 12 | github.com/bytedance/sonic v1.11.6 // indirect 13 | github.com/bytedance/sonic/loader v0.1.1 // indirect 14 | github.com/cloudwego/base64x v0.1.4 // indirect 15 | github.com/cloudwego/iasm v0.2.0 // indirect 16 | github.com/gabriel-vasile/mimetype v1.4.3 // indirect 17 | github.com/gin-contrib/sse v0.1.0 // indirect 18 | github.com/go-playground/locales v0.14.1 // indirect 19 | github.com/go-playground/universal-translator v0.18.1 // indirect 20 | github.com/go-playground/validator/v10 v10.20.0 // indirect 21 | github.com/go-sql-driver/mysql v1.7.0 // indirect 22 | github.com/goccy/go-json v0.10.2 // indirect 23 | github.com/jinzhu/inflection v1.0.0 // indirect 24 | github.com/jinzhu/now v1.1.5 // indirect 25 | github.com/json-iterator/go v1.1.12 // indirect 26 | github.com/klauspost/cpuid/v2 v2.2.7 // indirect 27 | github.com/leodido/go-urn v1.4.0 // indirect 28 | github.com/mattn/go-isatty v0.0.20 // indirect 29 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect 30 | github.com/modern-go/reflect2 v1.0.2 // indirect 31 | github.com/pelletier/go-toml/v2 v2.2.2 // indirect 32 | github.com/twitchyliquid64/golang-asm v0.15.1 // indirect 33 | github.com/ugorji/go/codec v1.2.12 // indirect 34 | golang.org/x/arch v0.8.0 // indirect 35 | golang.org/x/crypto v0.23.0 // indirect 36 | golang.org/x/net v0.25.0 // indirect 37 | golang.org/x/sys v0.20.0 // indirect 38 | golang.org/x/text v0.20.0 // indirect 39 | google.golang.org/protobuf v1.34.1 // indirect 40 | gopkg.in/yaml.v3 v3.0.1 // indirect 41 | ) 42 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/database/migrations/0001_01_01_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('name'); 17 | $table->string('email')->unique(); 18 | $table->timestamp('email_verified_at')->nullable(); 19 | $table->string('password'); 20 | $table->rememberToken(); 21 | $table->timestamps(); 22 | }); 23 | 24 | Schema::create('password_reset_tokens', function (Blueprint $table) { 25 | $table->string('email')->primary(); 26 | $table->string('token'); 27 | $table->timestamp('created_at')->nullable(); 28 | }); 29 | 30 | Schema::create('sessions', function (Blueprint $table) { 31 | $table->string('id')->primary(); 32 | $table->foreignId('user_id')->nullable()->index(); 33 | $table->string('ip_address', 45)->nullable(); 34 | $table->text('user_agent')->nullable(); 35 | $table->longText('payload'); 36 | $table->integer('last_activity')->index(); 37 | }); 38 | } 39 | 40 | /** 41 | * Reverse the migrations. 42 | */ 43 | public function down(): void 44 | { 45 | Schema::dropIfExists('users'); 46 | Schema::dropIfExists('password_reset_tokens'); 47 | Schema::dropIfExists('sessions'); 48 | } 49 | }; 50 | -------------------------------------------------------------------------------- /env_node_nginx/app/sample/index.js: -------------------------------------------------------------------------------- 1 | // モジュールの読込 2 | const express = require('express'); 3 | const app = express(); 4 | const mongoose = require('mongoose'); 5 | const moment = require('moment'); 6 | // スキーマ定義の読込 7 | const Book = require('./book_model.js') 8 | 9 | // viewエンジンにejsを設定 10 | app.set("view engine", "ejs"); 11 | app.set('views', './views'); 12 | 13 | // データベースへの接続文字列 (Docker Composeのサービス名 'db' を使用) 14 | const dbUrl = `mongodb://user1:user1@db:27017/mongo?authSource=mongo`; 15 | 16 | mongoose.connect(dbUrl) 17 | .then(() => { 18 | console.log('Connected to database.'); 19 | }).catch((err) => { 20 | console.error('Failed to connect to database:', err); 21 | process.exit(1); 22 | }); 23 | 24 | // ルートパスへのGETリクエスト 25 | app.get('/', async (req, res, next) => { 26 | try { 27 | let books = await Book.find(); 28 | console.log('booksの件数:', books.length); 29 | 30 | const formattedBooks = books.map(book => { 31 | const formattedDate = book.insert_timestamp 32 | ? moment(book.insert_timestamp).format('YYYY-MM-DD HH:mm:ss') 33 | : 'N/A'; 34 | return { 35 | id: book.id || book._id.toHexString(), 36 | title: book.title, 37 | date: formattedDate 38 | }; 39 | }); 40 | res.render("index", { books: formattedBooks }); 41 | } catch (err) { 42 | console.error('Failed to fetch books:', err); 43 | next(err); // エラーハンドリングミドルウェアへ渡す 44 | } 45 | }); 46 | 47 | // ポート3000で待受 (コンテナ内部ポート) 48 | const PORT = process.env.PORT || 3000; 49 | app.listen(PORT, () => { 50 | console.log(`Listening on internal port ${PORT}. Access via Nginx (http://localhost/).`); 51 | }); 52 | 53 | // 基本的なエラーハンドリングミドルウェア 54 | app.use((err, req, res, next) => { 55 | console.error(err.stack); 56 | res.status(500).send('Something broke!'); 57 | }); 58 | -------------------------------------------------------------------------------- /env_https/app/go.mod: -------------------------------------------------------------------------------- 1 | module mymodule 2 | 3 | go 1.20 4 | 5 | require ( 6 | github.com/gin-gonic/gin v1.9.1 7 | gorm.io/driver/mysql v1.5.1 8 | gorm.io/gorm v1.25.1 9 | ) 10 | 11 | require ( 12 | github.com/bytedance/sonic v1.9.1 // indirect 13 | github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect 14 | github.com/gabriel-vasile/mimetype v1.4.2 // indirect 15 | github.com/gin-contrib/sse v0.1.0 // indirect 16 | github.com/go-playground/locales v0.14.1 // indirect 17 | github.com/go-playground/universal-translator v0.18.1 // indirect 18 | github.com/go-playground/validator/v10 v10.14.1 // indirect 19 | github.com/go-sql-driver/mysql v1.7.1 // indirect 20 | github.com/goccy/go-json v0.10.2 // indirect 21 | github.com/google/go-cmp v0.5.9 // indirect 22 | github.com/jinzhu/inflection v1.0.0 // indirect 23 | github.com/jinzhu/now v1.1.5 // indirect 24 | github.com/json-iterator/go v1.1.12 // indirect 25 | github.com/klauspost/cpuid/v2 v2.2.5 // indirect 26 | github.com/kr/pretty v0.3.1 // indirect 27 | github.com/leodido/go-urn v1.2.4 // indirect 28 | github.com/mattn/go-isatty v0.0.19 // indirect 29 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect 30 | github.com/modern-go/reflect2 v1.0.2 // indirect 31 | github.com/pelletier/go-toml/v2 v2.0.8 // indirect 32 | github.com/twitchyliquid64/golang-asm v0.15.1 // indirect 33 | github.com/ugorji/go/codec v1.2.11 // indirect 34 | golang.org/x/arch v0.3.0 // indirect 35 | golang.org/x/crypto v0.10.0 // indirect 36 | golang.org/x/net v0.11.0 // indirect 37 | golang.org/x/sys v0.9.0 // indirect 38 | golang.org/x/text v0.10.0 // indirect 39 | google.golang.org/protobuf v1.30.0 // indirect 40 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect 41 | gopkg.in/yaml.v3 v3.0.1 // indirect 42 | ) 43 | -------------------------------------------------------------------------------- /env_go_mysql/.devcontainer/compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | app: 3 | build: 4 | context: ../app # プロジェクトルートのappディレクトリをビルドコンテキストに 5 | dockerfile: Dockerfile # ../app/Dockerfile を使用 6 | container_name: 'go-mysql-app' # 任意でコンテナ名を指定 7 | ports: 8 | - '8080:8080' # ホストのポート8080をコンテナのポート8080にマッピング 9 | - '2345:2345' # Delveデバッガー用のポート 10 | volumes: 11 | - ../app:/app # ホストのappディレクトリをコンテナの/appにマウント (コード変更を反映) 12 | # Goモジュールのキャッシュを永続化 (オプション) 13 | - go-mod-cache:/go/pkg/mod 14 | depends_on: 15 | db: 16 | condition: service_healthy # dbサービスがhealthyになるまで待機 17 | environment: 18 | - GIN_MODE=debug # Ginフレームワークのモード (debug/release) 19 | - MYSQL_USER=${MYSQL_USER} 20 | - MYSQL_PASSWORD=${MYSQL_PASSWORD} 21 | - MYSQL_DATABASE=${MYSQL_DATABASE} 22 | # デバッグ用に起動する場合 (launch.jsonと連携) 23 | # command: dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec /app/main # これはlaunch.jsonで行うことが多い 24 | stdin_open: true # コンテナの標準入力を開いたままにする 25 | tty: true # TTYを割り当てる 26 | 27 | db: 28 | build: 29 | context: ../db # プロジェクトルートのdbディレクトリをビルドコンテキストに 30 | dockerfile: Dockerfile # ../db/Dockerfile を使用 31 | container_name: 'go-mysql-db' # 任意でコンテナ名を指定 32 | # expose: # ポートは公開せず、appサービスからのみアクセス 33 | # - "3306" 34 | environment: 35 | - TZ=Asia/Tokyo 36 | - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} 37 | - MYSQL_DATABASE=${MYSQL_DATABASE} 38 | - MYSQL_USER=${MYSQL_USER} 39 | - MYSQL_PASSWORD=${MYSQL_PASSWORD} 40 | volumes: 41 | - db-data:/var/lib/mysql # 名前付きボリュームでデータを永続化 42 | - ../db/init:/docker-entrypoint-initdb.d # 初期化SQLスクリプトをマウント 43 | healthcheck: 44 | test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "${MYSQL_USER}", "-p${MYSQL_PASSWORD}"] 45 | interval: 10s 46 | timeout: 5s 47 | retries: 5 48 | start_period: 30s 49 | 50 | volumes: 51 | db-data: # MySQLデータ用ボリューム 52 | go-mod-cache: # Goモジュールキャッシュ用ボリューム (オプション) -------------------------------------------------------------------------------- /ex21/.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "PHP Basic Project (with Xdebug)", 3 | // compose.yml ファイルへの相対パス (devcontainer.json と同じディレクトリにある) 4 | "dockerComposeFile": "compose.yml", 5 | // compose.yml 内で使用するサービス名 6 | "service": "php", 7 | // VS Code を開いた際のコンテナ内のワークスペースフォルダ 8 | "workspaceFolder": "/app", // Dockerfile の WORKDIR, compose.yml の volume mount 先と一致 9 | // コンテナ内で VS Code サーバーやターミナルを実行するユーザー 10 | "remoteUser": "appuser", // Dockerfile で作成した非rootユーザー 11 | 12 | // VS Code のカスタマイズ設定 13 | "customizations": { 14 | "vscode": { 15 | // コンテナ内で有効にする VS Code 拡張機能 16 | "extensions": [ 17 | "bmewburn.vscode-intelephense-client", // PHP IntelliSense 18 | "DEVSENSE.phptools-vscode", // PHP Tools (デバッグ機能も含むが、専用拡張も推奨) 19 | "xdebug.php-debug" // PHP Xdebug (デバッグ専用拡張機能) 20 | // (任意) 他に推奨される拡張機能を追加: 21 | // "ms-azuretools.vscode-docker" 22 | ], 23 | // コンテナ内での VS Code 設定 24 | "settings": { 25 | "editor.tabSize": 4, // PHP推奨のタブサイズ (PSR準拠など) 26 | "php.validate.executablePath": "/usr/local/bin/php", // PHP実行ファイルのパス 27 | // Intelephense の設定例 28 | // "intelephense.environment.phpVersion": "8.3", // プロジェクトのPHPバージョン指定 29 | // フォーマッタ (phpcs, phpcbf, php-cs-fixer など) の設定を追加可能 30 | 31 | // PHP Debug 拡張機能 (xdebug.php-debug) 用の設定例 32 | "php.debug.executablePath": "/usr/local/bin/php", 33 | // "php.debug.log": true, // デバッグアダプタのログを有効化 (問題発生時) 34 | "php.debug.ideKey": "VSCODE" // Xdebug設定と合わせる (任意) 35 | } 36 | } 37 | }, 38 | // ポートフォワーディング設定: コンテナのポート8000をホストに公開 (Webサーバー用) 39 | "forwardPorts": [8000], 40 | 41 | // コンテナ作成後に composer install を実行するコマンドを追加 42 | // これにより、マウント後に依存関係がインストールされる 43 | // コンテナ作成後に /app/vendor の所有者を appuser に変更してから composer install を実行 44 | "postCreateCommand": "sudo chown -R appuser:appgroup /app/vendor && composer install --no-interaction --optimize-autoloader" 45 | 46 | // (任意) コンテナ起動時のコマンド実行 47 | // "postStartCommand": "echo 'Dev Container Started!'" 48 | } -------------------------------------------------------------------------------- /env_go_mysql_nginx_cert/web/default.conf: -------------------------------------------------------------------------------- 1 | # HTTP (ポート80) へのアクセスを HTTPS (ポート443) へリダイレクト 2 | server { 3 | listen 80; 4 | server_name localhost; # 必要に応じて変更 5 | 6 | # アクセスログとエラーログの設定 (任意、HTTPSサーバーと共有も可能) 7 | # access_log /var/log/nginx/access.log; 8 | # error_log /var/log/nginx/error.log; 9 | 10 | # HTTPSへリダイレクト 11 | return 301 https://$host$request_uri; 12 | } 13 | 14 | # HTTPS (ポート443) の設定 15 | server { 16 | listen 443 ssl; # ★変更: SSLを有効化 17 | server_name localhost; # 必要に応じて変更 18 | 19 | # ★追加: SSL証明書と秘密鍵のパスを指定 (compose.ymlでマウントしたパス) 20 | ssl_certificate /etc/nginx/certs/localhost.pem; 21 | ssl_certificate_key /etc/nginx/certs/localhost-key.pem; 22 | 23 | # ★追加: 推奨されるSSL/TLS設定 (任意、セキュリティ強度を高める場合) 24 | ssl_protocols TLSv1.2 TLSv1.3; 25 | ssl_prefer_server_ciphers off; 26 | ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384; 27 | 28 | # アクセスログとエラーログの設定 29 | access_log /var/log/nginx/access.log; 30 | error_log /var/log/nginx/error.log; 31 | 32 | location / { 33 | # upstream 'app' サービスのポート 8080 へリクエストを転送 34 | proxy_pass http://app:8080; 35 | 36 | # プロキシ経由でオリジナルのヘッダー情報をバックエンドに渡す設定 37 | proxy_set_header Host $host; 38 | proxy_set_header X-Real-IP $remote_addr; 39 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 40 | # ★変更: X-Forwarded-Proto ヘッダーを https に設定 41 | proxy_set_header X-Forwarded-Proto https; 42 | 43 | # WebSocket を利用する場合 (任意) 44 | # proxy_http_version 1.1; 45 | # proxy_set_header Upgrade $http_upgrade; 46 | # proxy_set_header Connection "upgrade"; 47 | } 48 | 49 | # 静的ファイルを Nginx で配信する場合 (任意) 50 | # 例: /static/ へのリクエストを /app/static ディレクトリのファイルで処理 51 | # location /static/ { 52 | # alias /app/static/; # appサービスの /app/static を指す (compose.ymlでのマウントが必要) 53 | # expires 1d; # キャッシュ期間 54 | # } 55 | } -------------------------------------------------------------------------------- /env_laravel1/app/sample/database/migrations/0001_01_01_000002_create_jobs_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('queue')->index(); 17 | $table->longText('payload'); 18 | $table->unsignedTinyInteger('attempts'); 19 | $table->unsignedInteger('reserved_at')->nullable(); 20 | $table->unsignedInteger('available_at'); 21 | $table->unsignedInteger('created_at'); 22 | }); 23 | 24 | Schema::create('job_batches', function (Blueprint $table) { 25 | $table->string('id')->primary(); 26 | $table->string('name'); 27 | $table->integer('total_jobs'); 28 | $table->integer('pending_jobs'); 29 | $table->integer('failed_jobs'); 30 | $table->longText('failed_job_ids'); 31 | $table->mediumText('options')->nullable(); 32 | $table->integer('cancelled_at')->nullable(); 33 | $table->integer('created_at'); 34 | $table->integer('finished_at')->nullable(); 35 | }); 36 | 37 | Schema::create('failed_jobs', function (Blueprint $table) { 38 | $table->id(); 39 | $table->string('uuid')->unique(); 40 | $table->text('connection'); 41 | $table->text('queue'); 42 | $table->longText('payload'); 43 | $table->longText('exception'); 44 | $table->timestamp('failed_at')->useCurrent(); 45 | }); 46 | } 47 | 48 | /** 49 | * Reverse the migrations. 50 | */ 51 | public function down(): void 52 | { 53 | Schema::dropIfExists('jobs'); 54 | Schema::dropIfExists('job_batches'); 55 | Schema::dropIfExists('failed_jobs'); 56 | } 57 | }; 58 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/database/migrations/0001_01_01_000002_create_jobs_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('queue')->index(); 17 | $table->longText('payload'); 18 | $table->unsignedTinyInteger('attempts'); 19 | $table->unsignedInteger('reserved_at')->nullable(); 20 | $table->unsignedInteger('available_at'); 21 | $table->unsignedInteger('created_at'); 22 | }); 23 | 24 | Schema::create('job_batches', function (Blueprint $table) { 25 | $table->string('id')->primary(); 26 | $table->string('name'); 27 | $table->integer('total_jobs'); 28 | $table->integer('pending_jobs'); 29 | $table->integer('failed_jobs'); 30 | $table->longText('failed_job_ids'); 31 | $table->mediumText('options')->nullable(); 32 | $table->integer('cancelled_at')->nullable(); 33 | $table->integer('created_at'); 34 | $table->integer('finished_at')->nullable(); 35 | }); 36 | 37 | Schema::create('failed_jobs', function (Blueprint $table) { 38 | $table->id(); 39 | $table->string('uuid')->unique(); 40 | $table->text('connection'); 41 | $table->text('queue'); 42 | $table->longText('payload'); 43 | $table->longText('exception'); 44 | $table->timestamp('failed_at')->useCurrent(); 45 | }); 46 | } 47 | 48 | /** 49 | * Reverse the migrations. 50 | */ 51 | public function down(): void 52 | { 53 | Schema::dropIfExists('jobs'); 54 | Schema::dropIfExists('job_batches'); 55 | Schema::dropIfExists('failed_jobs'); 56 | } 57 | }; 58 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/.devcontainer/compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | web: 3 | image: nginx:1.27-alpine # Nginxイメージを指定 4 | container_name: 'laravel-nginx' 5 | ports: 6 | - '80:80' # ホストのポート80をコンテナのポート80にマッピング 7 | volumes: 8 | # アプリケーションコードをマウント (Nginxが静的ファイルを提供、PHPパス解決に利用) 9 | - ../app:/var/www/html 10 | # Nginx設定ファイルをマウント 11 | - ../nginx/default.conf:/etc/nginx/conf.d/default.conf 12 | depends_on: 13 | - app # app(PHP-FPM)サービスが起動してから起動 14 | working_dir: /var/www/html # working_dir は必須ではないが設定しておく 15 | 16 | app: 17 | build: 18 | # ビルドコンテキストは app ディレクトリ 19 | context: ../app 20 | # dockerfile: Dockerfile (デフォルト名なので省略可) 21 | container_name: 'laravel-app-fpm' 22 | # ポートは公開せず、Nginxからの接続のみ受け付ける (expose はドキュメント用) 23 | # expose: 24 | # - "9000" 25 | working_dir: /var/www/html 26 | volumes: 27 | # ホストの app ディレクトリをマウント (コード同期、PHP-FPMが実行) 28 | - ../app:/var/www/html 29 | depends_on: 30 | db: 31 | condition: service_healthy 32 | environment: 33 | # Laravelが必要とする環境変数を設定可能 (app/sample/.env も参照される) 34 | - APP_ENV=local 35 | - APP_DEBUG=true 36 | # DB接続情報は app/sample/.env で設定するのが一般的 37 | extra_hosts: 38 | - "host.docker.internal:host-gateway" # Xdebug用 39 | # tty: true # FPM実行には通常不要 40 | 41 | db: 42 | build: 43 | # ビルドコンテキストは db ディレクトリ 44 | context: ../db 45 | # dockerfile: Dockerfile 46 | container_name: 'laravel-db' 47 | expose: 48 | - "3306" 49 | environment: 50 | # この compose.yml と同じディレクトリにある .env ファイルから読み込む 51 | MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} 52 | MYSQL_DATABASE: ${MYSQL_DATABASE} 53 | MYSQL_USER: ${MYSQL_USER} 54 | MYSQL_PASSWORD: ${MYSQL_PASSWORD} 55 | TZ: Asia/Tokyo 56 | volumes: 57 | # データベース永続化に名前付きボリュームを使用 58 | - db_data:/var/lib/mysql 59 | # 初期化SQLをマウント 60 | - ../db/init:/docker-entrypoint-initdb.d 61 | healthcheck: 62 | test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost", "-u$$MYSQL_USER", "-p$$MYSQL_PASSWORD"] 63 | interval: 10s 64 | timeout: 5s 65 | retries: 5 66 | start_period: 30s 67 | 68 | volumes: 69 | db_data: # データベース永続化用ボリューム -------------------------------------------------------------------------------- /env_go_mysql_nginx/.devcontainer/compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | web: 3 | image: nginx:stable-alpine # Nginxイメージを使用 4 | container_name: 'go-mysql-nginx-web' 5 | ports: 6 | - "80:80" # ホストのポート80をコンテナのポート80にマッピング 7 | volumes: 8 | - ../web/default.conf:/etc/nginx/conf.d/default.conf:ro # Nginx設定ファイルを読み取り専用でマウント 9 | depends_on: 10 | - app # appサービスが起動してからwebサービスを起動 11 | environment: 12 | - TZ=Asia/Tokyo 13 | 14 | app: 15 | build: 16 | context: ../app # プロジェクトルートのappディレクトリをビルドコンテキストに 17 | dockerfile: Dockerfile # ../app/Dockerfile を使用 18 | container_name: 'go-mysql-nginx-app' # 任意でコンテナ名を指定 19 | # ports: # ポートは公開せず、webサービスからのみアクセス 20 | # - '8080:8080' 21 | expose: 22 | - '8080' # webサービスからアクセスされるポート 23 | ports: # Delveデバッガー用のポートは公開する 24 | - '2345:2345' 25 | volumes: 26 | - ../app:/app # ホストのappディレクトリをコンテナの/appにマウント (コード変更を反映) 27 | # Goモジュールのキャッシュを永続化 (オプション) 28 | - go-mod-cache:/go/pkg/mod 29 | depends_on: 30 | db: 31 | condition: service_healthy # dbサービスがhealthyになるまで待機 32 | environment: 33 | - GIN_MODE=debug # Ginフレームワークのモード (debug/release) 34 | - MYSQL_USER=${MYSQL_USER} 35 | - MYSQL_PASSWORD=${MYSQL_PASSWORD} 36 | - MYSQL_DATABASE=${MYSQL_DATABASE} 37 | - TZ=Asia/Tokyo 38 | # デバッグ用に起動する場合 (launch.jsonと連携) 39 | # command: dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec /app/main # これはlaunch.jsonで行うことが多い 40 | stdin_open: true # コンテナの標準入力を開いたままにする 41 | tty: true # TTYを割り当てる 42 | 43 | db: 44 | build: 45 | context: ../db # プロジェクトルートのdbディレクトリをビルドコンテキストに 46 | dockerfile: Dockerfile # ../db/Dockerfile を使用 47 | container_name: 'go-mysql-nginx-db' # 任意でコンテナ名を指定 48 | # expose: # ポートは公開せず、appサービスからのみアクセス 49 | # - "3306" 50 | environment: 51 | - TZ=Asia/Tokyo 52 | - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} 53 | - MYSQL_DATABASE=${MYSQL_DATABASE} 54 | - MYSQL_USER=${MYSQL_USER} 55 | - MYSQL_PASSWORD=${MYSQL_PASSWORD} 56 | volumes: 57 | - db-data:/var/lib/mysql # 名前付きボリュームでデータを永続化 58 | - ../db/init:/docker-entrypoint-initdb.d # 初期化SQLスクリプトをマウント 59 | healthcheck: 60 | test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "${MYSQL_USER}", "-p${MYSQL_PASSWORD}"] 61 | interval: 10s 62 | timeout: 5s 63 | retries: 5 64 | start_period: 30s 65 | 66 | volumes: 67 | db-data: # MySQLデータ用ボリューム 68 | go-mod-cache: # Goモジュールキャッシュ用ボリューム (オプション) -------------------------------------------------------------------------------- /env_go_mysql_nginx_cert/.devcontainer/compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | web: 3 | image: nginx:stable-alpine # Nginxイメージを使用 4 | container_name: 'go-mysql-nginx-web' 5 | ports: 6 | - "80:80" # ホストのポート80をコンテナのポート80にマッピング 7 | - "443:443" # ★追加: HTTPSポート 8 | volumes: 9 | - ../web/default.conf:/etc/nginx/conf.d/default.conf:ro # Nginx設定ファイルを読み取り専用でマウント 10 | - ../certs:/etc/nginx/certs:ro # ★追加: 証明書フォルダを読み取り専用でマウント 11 | depends_on: 12 | - app # appサービスが起動してからwebサービスを起動 13 | environment: 14 | - TZ=Asia/Tokyo 15 | 16 | app: 17 | build: 18 | context: ../app # プロジェクトルートのappディレクトリをビルドコンテキストに 19 | dockerfile: Dockerfile # ../app/Dockerfile を使用 20 | container_name: 'go-mysql-nginx-app' # 任意でコンテナ名を指定 21 | # ports: # ポートは公開せず、webサービスからのみアクセス 22 | # - '8080:8080' 23 | expose: 24 | - '8080' # webサービスからアクセスされるポート 25 | ports: # Delveデバッガー用のポートは公開する 26 | - '2345:2345' 27 | volumes: 28 | - ../app:/app # ホストのappディレクトリをコンテナの/appにマウント (コード変更を反映) 29 | # Goモジュールのキャッシュを永続化 (オプション) 30 | - go-mod-cache:/go/pkg/mod 31 | depends_on: 32 | db: 33 | condition: service_healthy # dbサービスがhealthyになるまで待機 34 | environment: 35 | - GIN_MODE=debug # Ginフレームワークのモード (debug/release) 36 | - MYSQL_USER=${MYSQL_USER} 37 | - MYSQL_PASSWORD=${MYSQL_PASSWORD} 38 | - MYSQL_DATABASE=${MYSQL_DATABASE} 39 | - TZ=Asia/Tokyo 40 | # デバッグ用に起動する場合 (launch.jsonと連携) 41 | # command: dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec /app/main # これはlaunch.jsonで行うことが多い 42 | stdin_open: true # コンテナの標準入力を開いたままにする 43 | tty: true # TTYを割り当てる 44 | 45 | db: 46 | build: 47 | context: ../db # プロジェクトルートのdbディレクトリをビルドコンテキストに 48 | dockerfile: Dockerfile # ../db/Dockerfile を使用 49 | container_name: 'go-mysql-nginx-db' # 任意でコンテナ名を指定 50 | # expose: # ポートは公開せず、appサービスからのみアクセス 51 | # - "3306" 52 | environment: 53 | - TZ=Asia/Tokyo 54 | - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} 55 | - MYSQL_DATABASE=${MYSQL_DATABASE} 56 | - MYSQL_USER=${MYSQL_USER} 57 | - MYSQL_PASSWORD=${MYSQL_PASSWORD} 58 | volumes: 59 | - db-data:/var/lib/mysql # 名前付きボリュームでデータを永続化 60 | - ../db/init:/docker-entrypoint-initdb.d # 初期化SQLスクリプトをマウント 61 | healthcheck: 62 | test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "${MYSQL_USER}", "-p${MYSQL_PASSWORD}"] 63 | interval: 10s 64 | timeout: 5s 65 | retries: 5 66 | start_period: 30s 67 | 68 | volumes: 69 | db-data: # MySQLデータ用ボリューム 70 | go-mod-cache: # Goモジュールキャッシュ用ボリューム (オプション) -------------------------------------------------------------------------------- /env_laravel1/app/sample/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://getcomposer.org/schema.json", 3 | "name": "laravel/laravel", 4 | "type": "project", 5 | "description": "The skeleton application for the Laravel framework.", 6 | "keywords": ["laravel", "framework"], 7 | "license": "MIT", 8 | "require": { 9 | "php": "^8.2", 10 | "laravel/framework": "^12.0", 11 | "laravel/tinker": "^2.10.1" 12 | }, 13 | "require-dev": { 14 | "fakerphp/faker": "^1.23", 15 | "laravel/pail": "^1.2.2", 16 | "laravel/pint": "^1.13", 17 | "laravel/sail": "^1.41", 18 | "mockery/mockery": "^1.6", 19 | "nunomaduro/collision": "^8.6", 20 | "phpunit/phpunit": "^11.5.3" 21 | }, 22 | "autoload": { 23 | "psr-4": { 24 | "App\\": "app/", 25 | "Database\\Factories\\": "database/factories/", 26 | "Database\\Seeders\\": "database/seeders/" 27 | } 28 | }, 29 | "autoload-dev": { 30 | "psr-4": { 31 | "Tests\\": "tests/" 32 | } 33 | }, 34 | "scripts": { 35 | "post-autoload-dump": [ 36 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 37 | "@php artisan package:discover --ansi" 38 | ], 39 | "post-update-cmd": [ 40 | "@php artisan vendor:publish --tag=laravel-assets --ansi --force" 41 | ], 42 | "post-root-package-install": [ 43 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 44 | ], 45 | "post-create-project-cmd": [ 46 | "@php artisan key:generate --ansi", 47 | "@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"", 48 | "@php artisan migrate --graceful --ansi" 49 | ], 50 | "dev": [ 51 | "Composer\\Config::disableProcessTimeout", 52 | "npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite" 53 | ], 54 | "test": [ 55 | "@php artisan config:clear --ansi", 56 | "@php artisan test" 57 | ] 58 | }, 59 | "extra": { 60 | "laravel": { 61 | "dont-discover": [] 62 | } 63 | }, 64 | "config": { 65 | "optimize-autoloader": true, 66 | "preferred-install": "dist", 67 | "sort-packages": true, 68 | "allow-plugins": { 69 | "pestphp/pest-plugin": true, 70 | "php-http/discovery": true 71 | } 72 | }, 73 | "minimum-stability": "stable", 74 | "prefer-stable": true 75 | } 76 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://getcomposer.org/schema.json", 3 | "name": "laravel/laravel", 4 | "type": "project", 5 | "description": "The skeleton application for the Laravel framework.", 6 | "keywords": ["laravel", "framework"], 7 | "license": "MIT", 8 | "require": { 9 | "php": "^8.2", 10 | "laravel/framework": "^12.0", 11 | "laravel/tinker": "^2.10.1" 12 | }, 13 | "require-dev": { 14 | "fakerphp/faker": "^1.23", 15 | "laravel/pail": "^1.2.2", 16 | "laravel/pint": "^1.13", 17 | "laravel/sail": "^1.41", 18 | "mockery/mockery": "^1.6", 19 | "nunomaduro/collision": "^8.6", 20 | "phpunit/phpunit": "^11.5.3" 21 | }, 22 | "autoload": { 23 | "psr-4": { 24 | "App\\": "app/", 25 | "Database\\Factories\\": "database/factories/", 26 | "Database\\Seeders\\": "database/seeders/" 27 | } 28 | }, 29 | "autoload-dev": { 30 | "psr-4": { 31 | "Tests\\": "tests/" 32 | } 33 | }, 34 | "scripts": { 35 | "post-autoload-dump": [ 36 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 37 | "@php artisan package:discover --ansi" 38 | ], 39 | "post-update-cmd": [ 40 | "@php artisan vendor:publish --tag=laravel-assets --ansi --force" 41 | ], 42 | "post-root-package-install": [ 43 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 44 | ], 45 | "post-create-project-cmd": [ 46 | "@php artisan key:generate --ansi", 47 | "@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"", 48 | "@php artisan migrate --graceful --ansi" 49 | ], 50 | "dev": [ 51 | "Composer\\Config::disableProcessTimeout", 52 | "npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite" 53 | ], 54 | "test": [ 55 | "@php artisan config:clear --ansi", 56 | "@php artisan test" 57 | ] 58 | }, 59 | "extra": { 60 | "laravel": { 61 | "dont-discover": [] 62 | } 63 | }, 64 | "config": { 65 | "optimize-autoloader": true, 66 | "preferred-install": "dist", 67 | "sort-packages": true, 68 | "allow-plugins": { 69 | "pestphp/pest-plugin": true, 70 | "php-http/discovery": true 71 | } 72 | }, 73 | "minimum-stability": "stable", 74 | "prefer-stable": true 75 | } 76 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/config/filesystems.php: -------------------------------------------------------------------------------- 1 | env('FILESYSTEM_DISK', 'local'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Filesystem Disks 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Below you may configure as many filesystem disks as necessary, and you 24 | | may even configure multiple disks for the same driver. Examples for 25 | | most supported storage drivers are configured here for reference. 26 | | 27 | | Supported drivers: "local", "ftp", "sftp", "s3" 28 | | 29 | */ 30 | 31 | 'disks' => [ 32 | 33 | 'local' => [ 34 | 'driver' => 'local', 35 | 'root' => storage_path('app/private'), 36 | 'serve' => true, 37 | 'throw' => false, 38 | 'report' => false, 39 | ], 40 | 41 | 'public' => [ 42 | 'driver' => 'local', 43 | 'root' => storage_path('app/public'), 44 | 'url' => env('APP_URL').'/storage', 45 | 'visibility' => 'public', 46 | 'throw' => false, 47 | 'report' => false, 48 | ], 49 | 50 | 's3' => [ 51 | 'driver' => 's3', 52 | 'key' => env('AWS_ACCESS_KEY_ID'), 53 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 54 | 'region' => env('AWS_DEFAULT_REGION'), 55 | 'bucket' => env('AWS_BUCKET'), 56 | 'url' => env('AWS_URL'), 57 | 'endpoint' => env('AWS_ENDPOINT'), 58 | 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), 59 | 'throw' => false, 60 | 'report' => false, 61 | ], 62 | 63 | ], 64 | 65 | /* 66 | |-------------------------------------------------------------------------- 67 | | Symbolic Links 68 | |-------------------------------------------------------------------------- 69 | | 70 | | Here you may configure the symbolic links that will be created when the 71 | | `storage:link` Artisan command is executed. The array keys should be 72 | | the locations of the links and the values should be their targets. 73 | | 74 | */ 75 | 76 | 'links' => [ 77 | public_path('storage') => storage_path('app/public'), 78 | ], 79 | 80 | ]; 81 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/config/filesystems.php: -------------------------------------------------------------------------------- 1 | env('FILESYSTEM_DISK', 'local'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Filesystem Disks 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Below you may configure as many filesystem disks as necessary, and you 24 | | may even configure multiple disks for the same driver. Examples for 25 | | most supported storage drivers are configured here for reference. 26 | | 27 | | Supported drivers: "local", "ftp", "sftp", "s3" 28 | | 29 | */ 30 | 31 | 'disks' => [ 32 | 33 | 'local' => [ 34 | 'driver' => 'local', 35 | 'root' => storage_path('app/private'), 36 | 'serve' => true, 37 | 'throw' => false, 38 | 'report' => false, 39 | ], 40 | 41 | 'public' => [ 42 | 'driver' => 'local', 43 | 'root' => storage_path('app/public'), 44 | 'url' => env('APP_URL').'/storage', 45 | 'visibility' => 'public', 46 | 'throw' => false, 47 | 'report' => false, 48 | ], 49 | 50 | 's3' => [ 51 | 'driver' => 's3', 52 | 'key' => env('AWS_ACCESS_KEY_ID'), 53 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 54 | 'region' => env('AWS_DEFAULT_REGION'), 55 | 'bucket' => env('AWS_BUCKET'), 56 | 'url' => env('AWS_URL'), 57 | 'endpoint' => env('AWS_ENDPOINT'), 58 | 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), 59 | 'throw' => false, 60 | 'report' => false, 61 | ], 62 | 63 | ], 64 | 65 | /* 66 | |-------------------------------------------------------------------------- 67 | | Symbolic Links 68 | |-------------------------------------------------------------------------- 69 | | 70 | | Here you may configure the symbolic links that will be created when the 71 | | `storage:link` Artisan command is executed. The array keys should be 72 | | the locations of the links and the values should be their targets. 73 | | 74 | */ 75 | 76 | 'links' => [ 77 | public_path('storage') => storage_path('app/public'), 78 | ], 79 | 80 | ]; 81 | -------------------------------------------------------------------------------- /env_go_mysql/app/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | "net/http" 6 | "os" 7 | "time" 8 | 9 | "github.com/gin-gonic/gin" 10 | "gorm.io/driver/mysql" 11 | "gorm.io/gorm" 12 | "gorm.io/gorm/logger" 13 | ) 14 | 15 | // Book 構造体 (データベースの books テーブルに対応) 16 | type Book struct { 17 | Id int `gorm:"column:id;primaryKey;autoIncrement"` 18 | Title string `gorm:"column:title;not null"` 19 | InsertTimestamp *time.Time `gorm:"column:insert_timestamp;default:CURRENT_TIMESTAMP"` 20 | } 21 | 22 | // TableName メソッドで GORM にテーブル名を明示的に伝える (任意) 23 | func (Book) TableName() string { 24 | return "books" 25 | } 26 | 27 | func main() { 28 | // --- データベース接続 --- 29 | // 環境変数から接続情報を取得 (docker-compose.yml の .env 参照) 30 | user := os.Getenv("MYSQL_USER") 31 | password := os.Getenv("MYSQL_PASSWORD") 32 | dbName := os.Getenv("MYSQL_DATABASE") 33 | // compose.yml のサービス名 'db' をホスト名として使用 34 | host := "db" 35 | port := "3306" 36 | 37 | dsn := user + ":" + password + "@tcp(" + host + ":" + port + ")/" + dbName + "?charset=utf8mb4&parseTime=True&loc=Local" 38 | 39 | // GORMのロガー設定 (SQLログを出力) 40 | newLogger := logger.New( 41 | log.New(os.Stdout, "\r\n", log.LstdFlags), // io writer 42 | logger.Config{ 43 | SlowThreshold: time.Second, // 遅いSQLの閾値 44 | LogLevel: logger.Info, // ログレベル (Info, Warn, Error, Silent) 45 | Colorful: true, // カラーログ 46 | }, 47 | ) 48 | 49 | // データベースに接続 50 | db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{ 51 | Logger: newLogger, // 設定したロガーを使用 52 | }) 53 | if err != nil { 54 | log.Fatalf("Failed to connect to database: %v", err) // panic の代わりに log.Fatalf を使用 55 | } 56 | 57 | // GORMによる自動マイグレーション (テーブルが存在しない場合作成) - 開発時には便利 58 | // db.AutoMigrate(&Book{}) // 初期化SQLで作成するので通常は不要 59 | 60 | // --- Gin ルーターの設定 --- 61 | router := gin.Default() // Logger と Recovery ミドルウェアを含むデフォルトルーター 62 | 63 | // HTML テンプレートの場所を指定 64 | router.LoadHTMLGlob("templates/*.html") // app/templates/*.html を参照 65 | 66 | // --- ルートハンドラの定義 --- 67 | // GET / : 書籍リストを表示 68 | router.GET("/", func(c *gin.Context) { 69 | var books []Book // データを格納するスライス 70 | 71 | // books テーブルから全レコードを取得 (作成日時順にソート) 72 | result := db.Order("insert_timestamp desc").Find(&books) 73 | if result.Error != nil { 74 | log.Printf("Error fetching books: %v", result.Error) 75 | c.HTML(http.StatusInternalServerError, "error.html", gin.H{"message": "データベースエラーが発生しました。"}) 76 | return // エラーが発生したら処理を中断 77 | } 78 | 79 | // 取得したデータをテンプレートに渡して HTML をレンダリング 80 | c.HTML(http.StatusOK, "index.html", gin.H{ 81 | "books": books, 82 | }) 83 | 84 | log.Printf("Accessed /. Found %d books.", len(books)) 85 | }) 86 | 87 | // --- サーバーの起動 --- 88 | log.Println("Starting server on port 8080...") 89 | // router.Run() はデフォルトで :8080 で起動 90 | if err := router.Run(":8080"); err != nil { 91 | log.Fatalf("Failed to run server: %v", err) 92 | } 93 | } -------------------------------------------------------------------------------- /ex21/php/Dockerfile: -------------------------------------------------------------------------------- 1 | # ベースイメージ: 特定バージョンの PHP CLI イメージを使用 (Alpineベースで軽量) 2 | # CLIイメージでもXdebugやFPM連携は可能だが、用途によってはFPMイメージが良い場合もある 3 | FROM php:8.3-cli-alpine 4 | 5 | # 引数で作業ディレクトリを定義 (変更しやすくするため) 6 | ARG APP_DIR=/app 7 | WORKDIR ${APP_DIR} 8 | 9 | # ビルド時依存関係と永続依存関係をインストール (Xdebugビルド用) 10 | # linux-headers を .build-deps に追加 11 | RUN apk add --no-cache --virtual .build-deps \ 12 | $PHPIZE_DEPS \ 13 | make \ 14 | g++ \ 15 | linux-headers \ 16 | && apk add --no-cache --virtual .persistent-deps \ 17 | tzdata \ 18 | && apk add --no-cache sudo 19 | 20 | # Xdebug を PECL 経由でインストール 21 | RUN pecl install xdebug \ 22 | && docker-php-ext-enable xdebug 23 | 24 | # Xdebug の設定ファイルを作成(既存の zend_extension 行を消さないように >> を使う) 25 | # 念のため最初に空行を追記してから [xdebug] セクションと設定を追記 26 | RUN echo "" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ 27 | && echo "[xdebug]" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ 28 | && echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ 29 | && echo "xdebug.start_with_request=trigger" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ 30 | && echo "xdebug.client_port=9003" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ 31 | && echo "xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ 32 | && echo ";xdebug.discover_client_host=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ 33 | && echo ";xdebug.log=/tmp/xdebug.log" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ 34 | && echo "xdebug.idekey=VSCODE" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini 35 | 36 | # ビルド時依存関係を削除 37 | RUN apk del .build-deps 38 | 39 | # 非rootユーザー 'appuser' (UID 1001) を作成 40 | RUN addgroup -S -g 1001 appgroup && \ 41 | adduser -S -u 1001 -s /bin/sh -G appgroup appuser 42 | 43 | # appuser がパスワードなしで sudo を実行できるようにする 44 | RUN mkdir -p /etc/sudoers.d && \ 45 | echo "appuser ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/appuser && \ 46 | chmod 0440 /etc/sudoers.d/appuser 47 | 48 | # 作業ディレクトリとvendorディレクトリを作成し、所有者をappuserにする 49 | RUN mkdir -p ${APP_DIR}/vendor && \ 50 | chown -R appuser:appgroup ${APP_DIR} 51 | 52 | # ユーザーを appuser に切り替える 53 | USER appuser 54 | WORKDIR ${APP_DIR} 55 | 56 | # 依存関係ファイルを先にコピー 57 | COPY --chown=appuser:appgroup composer.json composer.lock* ./ 58 | 59 | # Composer をダウンロード・インストール (root権限が必要なので一時的に USER root) 60 | USER root 61 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \ 62 | chmod +x /usr/local/bin/composer # 実行権限を付与 63 | 64 | # === composer install はここでは実行しない (devcontainer.json の postCreateCommand で実行) === 65 | # # 依存関係を appuser としてインストール 66 | # USER appuser 67 | # RUN composer install --no-interaction --optimize-autoloader 68 | 69 | # ユーザーを appuser に戻す 70 | USER appuser 71 | 72 | # アプリケーションコードはこの Dockerfile ではコピーしない (マウントされるため) 73 | # 本番用イメージなど、コードをイメージに含める場合は以下の行を追加: 74 | # COPY --chown=appuser:appgroup public ./public 75 | # COPY --chown=appuser:appgroup src ./src # src ディレクトリがある場合 76 | 77 | # デフォルトのコンテナ起動コマンドは compose.yml で上書きされる想定 78 | # (ビルトインサーバーを起動するため) 79 | # CMD ["php", "public/index.php"] # CLI実行の場合 -------------------------------------------------------------------------------- /env_go_mysql_nginx/app/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | "net/http" 6 | "os" 7 | "time" 8 | 9 | "github.com/gin-gonic/gin" 10 | "gorm.io/driver/mysql" 11 | "gorm.io/gorm" 12 | "gorm.io/gorm/logger" 13 | ) 14 | 15 | // Book 構造体 (データベースの books テーブルに対応) 16 | type Book struct { 17 | Id int `gorm:"column:id;primaryKey;autoIncrement"` 18 | Title string `gorm:"column:title;not null"` 19 | InsertTimestamp *time.Time `gorm:"column:insert_timestamp;default:CURRENT_TIMESTAMP"` 20 | } 21 | 22 | // TableName メソッドで GORM にテーブル名を明示的に伝える (任意) 23 | func (Book) TableName() string { 24 | return "books" 25 | } 26 | 27 | func main() { 28 | // --- データベース接続 --- 29 | // 環境変数から接続情報を取得 (docker-compose.yml の .env 参照) 30 | user := os.Getenv("MYSQL_USER") 31 | password := os.Getenv("MYSQL_PASSWORD") 32 | dbName := os.Getenv("MYSQL_DATABASE") 33 | // compose.yml のサービス名 'db' をホスト名として使用 34 | host := "db" 35 | port := "3306" 36 | 37 | dsn := user + ":" + password + "@tcp(" + host + ":" + port + ")/" + dbName + "?charset=utf8mb4&parseTime=True&loc=Local" 38 | 39 | // GORMのロガー設定 (SQLログを出力) 40 | newLogger := logger.New( 41 | log.New(os.Stdout, "\r\n", log.LstdFlags), // io writer 42 | logger.Config{ 43 | SlowThreshold: time.Second, // 遅いSQLの閾値 44 | LogLevel: logger.Info, // ログレベル (Info, Warn, Error, Silent) 45 | Colorful: true, // カラーログ 46 | }, 47 | ) 48 | 49 | // データベースに接続 50 | db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{ 51 | Logger: newLogger, // 設定したロガーを使用 52 | }) 53 | if err != nil { 54 | log.Fatalf("Failed to connect to database: %v", err) // panic の代わりに log.Fatalf を使用 55 | } 56 | 57 | // GORMによる自動マイグレーション (テーブルが存在しない場合作成) - 開発時には便利 58 | // db.AutoMigrate(&Book{}) // 初期化SQLで作成するので通常は不要 59 | 60 | // --- Gin ルーターの設定 --- 61 | router := gin.Default() // Logger と Recovery ミドルウェアを含むデフォルトルーター 62 | 63 | // HTML テンプレートの場所を指定 64 | router.LoadHTMLGlob("templates/*.html") // app/templates/*.html を参照 65 | 66 | // --- ルートハンドラの定義 --- 67 | // GET / : 書籍リストを表示 68 | router.GET("/", func(c *gin.Context) { 69 | var books []Book // データを格納するスライス 70 | 71 | // books テーブルから全レコードを取得 (作成日時順にソート) 72 | result := db.Order("insert_timestamp desc").Find(&books) 73 | if result.Error != nil { 74 | log.Printf("Error fetching books: %v", result.Error) 75 | c.HTML(http.StatusInternalServerError, "error.html", gin.H{"message": "データベースエラーが発生しました。"}) 76 | return // エラーが発生したら処理を中断 77 | } 78 | 79 | // 取得したデータをテンプレートに渡して HTML をレンダリング 80 | c.HTML(http.StatusOK, "index.html", gin.H{ 81 | "books": books, 82 | }) 83 | 84 | log.Printf("Accessed /. Found %d books.", len(books)) 85 | }) 86 | 87 | // --- サーバーの起動 --- 88 | log.Println("Starting server on port 8080...") 89 | // router.Run() はデフォルトで :8080 で起動 90 | // Nginx経由でアクセスされるため、ここでは内部ポート8080で待機 91 | if err := router.Run(":8080"); err != nil { 92 | log.Fatalf("Failed to run server: %v", err) 93 | } 94 | } -------------------------------------------------------------------------------- /env_go_mysql_nginx_cert/app/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | "net/http" 6 | "os" 7 | "time" 8 | 9 | "github.com/gin-gonic/gin" 10 | "gorm.io/driver/mysql" 11 | "gorm.io/gorm" 12 | "gorm.io/gorm/logger" 13 | ) 14 | 15 | // Book 構造体 (データベースの books テーブルに対応) 16 | type Book struct { 17 | Id int `gorm:"column:id;primaryKey;autoIncrement"` 18 | Title string `gorm:"column:title;not null"` 19 | InsertTimestamp *time.Time `gorm:"column:insert_timestamp;default:CURRENT_TIMESTAMP"` 20 | } 21 | 22 | // TableName メソッドで GORM にテーブル名を明示的に伝える (任意) 23 | func (Book) TableName() string { 24 | return "books" 25 | } 26 | 27 | func main() { 28 | // --- データベース接続 --- 29 | // 環境変数から接続情報を取得 (docker-compose.yml の .env 参照) 30 | user := os.Getenv("MYSQL_USER") 31 | password := os.Getenv("MYSQL_PASSWORD") 32 | dbName := os.Getenv("MYSQL_DATABASE") 33 | // compose.yml のサービス名 'db' をホスト名として使用 34 | host := "db" 35 | port := "3306" 36 | 37 | dsn := user + ":" + password + "@tcp(" + host + ":" + port + ")/" + dbName + "?charset=utf8mb4&parseTime=True&loc=Local" 38 | 39 | // GORMのロガー設定 (SQLログを出力) 40 | newLogger := logger.New( 41 | log.New(os.Stdout, "\r\n", log.LstdFlags), // io writer 42 | logger.Config{ 43 | SlowThreshold: time.Second, // 遅いSQLの閾値 44 | LogLevel: logger.Info, // ログレベル (Info, Warn, Error, Silent) 45 | Colorful: true, // カラーログ 46 | }, 47 | ) 48 | 49 | // データベースに接続 50 | db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{ 51 | Logger: newLogger, // 設定したロガーを使用 52 | }) 53 | if err != nil { 54 | log.Fatalf("Failed to connect to database: %v", err) // panic の代わりに log.Fatalf を使用 55 | } 56 | 57 | // GORMによる自動マイグレーション (テーブルが存在しない場合作成) - 開発時には便利 58 | // db.AutoMigrate(&Book{}) // 初期化SQLで作成するので通常は不要 59 | 60 | // --- Gin ルーターの設定 --- 61 | router := gin.Default() // Logger と Recovery ミドルウェアを含むデフォルトルーター 62 | 63 | // HTML テンプレートの場所を指定 64 | router.LoadHTMLGlob("templates/*.html") // app/templates/*.html を参照 65 | 66 | // --- ルートハンドラの定義 --- 67 | // GET / : 書籍リストを表示 68 | router.GET("/", func(c *gin.Context) { 69 | var books []Book // データを格納するスライス 70 | 71 | // books テーブルから全レコードを取得 (作成日時順にソート) 72 | result := db.Order("insert_timestamp desc").Find(&books) 73 | if result.Error != nil { 74 | log.Printf("Error fetching books: %v", result.Error) 75 | c.HTML(http.StatusInternalServerError, "error.html", gin.H{"message": "データベースエラーが発生しました。"}) 76 | return // エラーが発生したら処理を中断 77 | } 78 | 79 | // 取得したデータをテンプレートに渡して HTML をレンダリング 80 | c.HTML(http.StatusOK, "index.html", gin.H{ 81 | "books": books, 82 | }) 83 | 84 | log.Printf("Accessed /. Found %d books.", len(books)) 85 | }) 86 | 87 | // --- サーバーの起動 --- 88 | log.Println("Starting server on port 8080...") 89 | // router.Run() はデフォルトで :8080 で起動 90 | // Nginx経由でアクセスされるため、ここでは内部ポート8080で待機 91 | if err := router.Run(":8080"); err != nil { 92 | log.Fatalf("Failed to run server: %v", err) 93 | } 94 | } -------------------------------------------------------------------------------- /ex21/php/public/index.php: -------------------------------------------------------------------------------- 1 | 21 | 22 | 23 | 24 | 25 | 26 | PHP Dev Container - Web Page 27 | 67 | 68 | 69 |
70 |

ようこそ PHP Dev Container へ!

71 |

これはPHPビルトインWebサーバーによって提供されるシンプルなWebページです。

72 | 73 |

環境情報:

74 |
    75 |
  • PHP Version:
  • 76 |
  • Server Software:
  • 77 |
  • Current Time:
  • 78 |
79 | 80 |
81 | Xdebug Status: 82 | 83 | (Mode: ) 84 | 85 |
86 | 87 |

PHP Info を表示

88 | 89 | PHP Info:'; 93 | // ここにブレークポイントを設定してデバッグを試すことができます 94 | $infoVar = "Displaying PHP Info"; // デバッグ用変数 95 | phpinfo(); 96 | } 97 | ?> 98 |
99 | 100 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_STORE', 'database'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Cache Stores 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the cache "stores" for your application as 26 | | well as their drivers. You may even define multiple stores for the 27 | | same cache driver to group types of items stored in your caches. 28 | | 29 | | Supported drivers: "array", "database", "file", "memcached", 30 | | "redis", "dynamodb", "octane", "null" 31 | | 32 | */ 33 | 34 | 'stores' => [ 35 | 36 | 'array' => [ 37 | 'driver' => 'array', 38 | 'serialize' => false, 39 | ], 40 | 41 | 'database' => [ 42 | 'driver' => 'database', 43 | 'connection' => env('DB_CACHE_CONNECTION'), 44 | 'table' => env('DB_CACHE_TABLE', 'cache'), 45 | 'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'), 46 | 'lock_table' => env('DB_CACHE_LOCK_TABLE'), 47 | ], 48 | 49 | 'file' => [ 50 | 'driver' => 'file', 51 | 'path' => storage_path('framework/cache/data'), 52 | 'lock_path' => storage_path('framework/cache/data'), 53 | ], 54 | 55 | 'memcached' => [ 56 | 'driver' => 'memcached', 57 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 58 | 'sasl' => [ 59 | env('MEMCACHED_USERNAME'), 60 | env('MEMCACHED_PASSWORD'), 61 | ], 62 | 'options' => [ 63 | // Memcached::OPT_CONNECT_TIMEOUT => 2000, 64 | ], 65 | 'servers' => [ 66 | [ 67 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 68 | 'port' => env('MEMCACHED_PORT', 11211), 69 | 'weight' => 100, 70 | ], 71 | ], 72 | ], 73 | 74 | 'redis' => [ 75 | 'driver' => 'redis', 76 | 'connection' => env('REDIS_CACHE_CONNECTION', 'cache'), 77 | 'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'), 78 | ], 79 | 80 | 'dynamodb' => [ 81 | 'driver' => 'dynamodb', 82 | 'key' => env('AWS_ACCESS_KEY_ID'), 83 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 84 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 85 | 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), 86 | 'endpoint' => env('DYNAMODB_ENDPOINT'), 87 | ], 88 | 89 | 'octane' => [ 90 | 'driver' => 'octane', 91 | ], 92 | 93 | ], 94 | 95 | /* 96 | |-------------------------------------------------------------------------- 97 | | Cache Key Prefix 98 | |-------------------------------------------------------------------------- 99 | | 100 | | When utilizing the APC, database, memcached, Redis, and DynamoDB cache 101 | | stores, there might be other applications using the same cache. For 102 | | that reason, you may prefix every cache key to avoid collisions. 103 | | 104 | */ 105 | 106 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'), 107 | 108 | ]; 109 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_STORE', 'database'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Cache Stores 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the cache "stores" for your application as 26 | | well as their drivers. You may even define multiple stores for the 27 | | same cache driver to group types of items stored in your caches. 28 | | 29 | | Supported drivers: "array", "database", "file", "memcached", 30 | | "redis", "dynamodb", "octane", "null" 31 | | 32 | */ 33 | 34 | 'stores' => [ 35 | 36 | 'array' => [ 37 | 'driver' => 'array', 38 | 'serialize' => false, 39 | ], 40 | 41 | 'database' => [ 42 | 'driver' => 'database', 43 | 'connection' => env('DB_CACHE_CONNECTION'), 44 | 'table' => env('DB_CACHE_TABLE', 'cache'), 45 | 'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'), 46 | 'lock_table' => env('DB_CACHE_LOCK_TABLE'), 47 | ], 48 | 49 | 'file' => [ 50 | 'driver' => 'file', 51 | 'path' => storage_path('framework/cache/data'), 52 | 'lock_path' => storage_path('framework/cache/data'), 53 | ], 54 | 55 | 'memcached' => [ 56 | 'driver' => 'memcached', 57 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 58 | 'sasl' => [ 59 | env('MEMCACHED_USERNAME'), 60 | env('MEMCACHED_PASSWORD'), 61 | ], 62 | 'options' => [ 63 | // Memcached::OPT_CONNECT_TIMEOUT => 2000, 64 | ], 65 | 'servers' => [ 66 | [ 67 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 68 | 'port' => env('MEMCACHED_PORT', 11211), 69 | 'weight' => 100, 70 | ], 71 | ], 72 | ], 73 | 74 | 'redis' => [ 75 | 'driver' => 'redis', 76 | 'connection' => env('REDIS_CACHE_CONNECTION', 'cache'), 77 | 'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'), 78 | ], 79 | 80 | 'dynamodb' => [ 81 | 'driver' => 'dynamodb', 82 | 'key' => env('AWS_ACCESS_KEY_ID'), 83 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 84 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 85 | 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), 86 | 'endpoint' => env('DYNAMODB_ENDPOINT'), 87 | ], 88 | 89 | 'octane' => [ 90 | 'driver' => 'octane', 91 | ], 92 | 93 | ], 94 | 95 | /* 96 | |-------------------------------------------------------------------------- 97 | | Cache Key Prefix 98 | |-------------------------------------------------------------------------- 99 | | 100 | | When utilizing the APC, database, memcached, Redis, and DynamoDB cache 101 | | stores, there might be other applications using the same cache. For 102 | | that reason, you may prefix every cache key to avoid collisions. 103 | | 104 | */ 105 | 106 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'), 107 | 108 | ]; 109 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/README.md: -------------------------------------------------------------------------------- 1 |

Laravel Logo

2 | 3 |

4 | Build Status 5 | Total Downloads 6 | Latest Stable Version 7 | License 8 |

9 | 10 | ## About Laravel 11 | 12 | Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as: 13 | 14 | - [Simple, fast routing engine](https://laravel.com/docs/routing). 15 | - [Powerful dependency injection container](https://laravel.com/docs/container). 16 | - Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage. 17 | - Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent). 18 | - Database agnostic [schema migrations](https://laravel.com/docs/migrations). 19 | - [Robust background job processing](https://laravel.com/docs/queues). 20 | - [Real-time event broadcasting](https://laravel.com/docs/broadcasting). 21 | 22 | Laravel is accessible, powerful, and provides tools required for large, robust applications. 23 | 24 | ## Learning Laravel 25 | 26 | Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. 27 | 28 | You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch. 29 | 30 | If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library. 31 | 32 | ## Laravel Sponsors 33 | 34 | We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com). 35 | 36 | ### Premium Partners 37 | 38 | - **[Vehikl](https://vehikl.com/)** 39 | - **[Tighten Co.](https://tighten.co)** 40 | - **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)** 41 | - **[64 Robots](https://64robots.com)** 42 | - **[Curotec](https://www.curotec.com/services/technologies/laravel/)** 43 | - **[DevSquad](https://devsquad.com/hire-laravel-developers)** 44 | - **[Redberry](https://redberry.international/laravel-development/)** 45 | - **[Active Logic](https://activelogic.com)** 46 | 47 | ## Contributing 48 | 49 | Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). 50 | 51 | ## Code of Conduct 52 | 53 | In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct). 54 | 55 | ## Security Vulnerabilities 56 | 57 | If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed. 58 | 59 | ## License 60 | 61 | The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). 62 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/README.md: -------------------------------------------------------------------------------- 1 |

Laravel Logo

2 | 3 |

4 | Build Status 5 | Total Downloads 6 | Latest Stable Version 7 | License 8 |

9 | 10 | ## About Laravel 11 | 12 | Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as: 13 | 14 | - [Simple, fast routing engine](https://laravel.com/docs/routing). 15 | - [Powerful dependency injection container](https://laravel.com/docs/container). 16 | - Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage. 17 | - Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent). 18 | - Database agnostic [schema migrations](https://laravel.com/docs/migrations). 19 | - [Robust background job processing](https://laravel.com/docs/queues). 20 | - [Real-time event broadcasting](https://laravel.com/docs/broadcasting). 21 | 22 | Laravel is accessible, powerful, and provides tools required for large, robust applications. 23 | 24 | ## Learning Laravel 25 | 26 | Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. 27 | 28 | You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch. 29 | 30 | If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library. 31 | 32 | ## Laravel Sponsors 33 | 34 | We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com). 35 | 36 | ### Premium Partners 37 | 38 | - **[Vehikl](https://vehikl.com/)** 39 | - **[Tighten Co.](https://tighten.co)** 40 | - **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)** 41 | - **[64 Robots](https://64robots.com)** 42 | - **[Curotec](https://www.curotec.com/services/technologies/laravel/)** 43 | - **[DevSquad](https://devsquad.com/hire-laravel-developers)** 44 | - **[Redberry](https://redberry.international/laravel-development/)** 45 | - **[Active Logic](https://activelogic.com)** 46 | 47 | ## Contributing 48 | 49 | Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). 50 | 51 | ## Code of Conduct 52 | 53 | In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct). 54 | 55 | ## Security Vulnerabilities 56 | 57 | If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed. 58 | 59 | ## License 60 | 61 | The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). 62 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/config/mail.php: -------------------------------------------------------------------------------- 1 | env('MAIL_MAILER', 'log'), 18 | 19 | /* 20 | |-------------------------------------------------------------------------- 21 | | Mailer Configurations 22 | |-------------------------------------------------------------------------- 23 | | 24 | | Here you may configure all of the mailers used by your application plus 25 | | their respective settings. Several examples have been configured for 26 | | you and you are free to add your own as your application requires. 27 | | 28 | | Laravel supports a variety of mail "transport" drivers that can be used 29 | | when delivering an email. You may specify which one you're using for 30 | | your mailers below. You may also add additional mailers if needed. 31 | | 32 | | Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2", 33 | | "postmark", "resend", "log", "array", 34 | | "failover", "roundrobin" 35 | | 36 | */ 37 | 38 | 'mailers' => [ 39 | 40 | 'smtp' => [ 41 | 'transport' => 'smtp', 42 | 'scheme' => env('MAIL_SCHEME'), 43 | 'url' => env('MAIL_URL'), 44 | 'host' => env('MAIL_HOST', '127.0.0.1'), 45 | 'port' => env('MAIL_PORT', 2525), 46 | 'username' => env('MAIL_USERNAME'), 47 | 'password' => env('MAIL_PASSWORD'), 48 | 'timeout' => null, 49 | 'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url(env('APP_URL', 'http://localhost'), PHP_URL_HOST)), 50 | ], 51 | 52 | 'ses' => [ 53 | 'transport' => 'ses', 54 | ], 55 | 56 | 'postmark' => [ 57 | 'transport' => 'postmark', 58 | // 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'), 59 | // 'client' => [ 60 | // 'timeout' => 5, 61 | // ], 62 | ], 63 | 64 | 'resend' => [ 65 | 'transport' => 'resend', 66 | ], 67 | 68 | 'sendmail' => [ 69 | 'transport' => 'sendmail', 70 | 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'), 71 | ], 72 | 73 | 'log' => [ 74 | 'transport' => 'log', 75 | 'channel' => env('MAIL_LOG_CHANNEL'), 76 | ], 77 | 78 | 'array' => [ 79 | 'transport' => 'array', 80 | ], 81 | 82 | 'failover' => [ 83 | 'transport' => 'failover', 84 | 'mailers' => [ 85 | 'smtp', 86 | 'log', 87 | ], 88 | 'retry_after' => 60, 89 | ], 90 | 91 | 'roundrobin' => [ 92 | 'transport' => 'roundrobin', 93 | 'mailers' => [ 94 | 'ses', 95 | 'postmark', 96 | ], 97 | 'retry_after' => 60, 98 | ], 99 | 100 | ], 101 | 102 | /* 103 | |-------------------------------------------------------------------------- 104 | | Global "From" Address 105 | |-------------------------------------------------------------------------- 106 | | 107 | | You may wish for all emails sent by your application to be sent from 108 | | the same address. Here you may specify a name and address that is 109 | | used globally for all emails that are sent by your application. 110 | | 111 | */ 112 | 113 | 'from' => [ 114 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 115 | 'name' => env('MAIL_FROM_NAME', 'Example'), 116 | ], 117 | 118 | ]; 119 | -------------------------------------------------------------------------------- /env_laravel_nginx_fpm/app/sample/config/mail.php: -------------------------------------------------------------------------------- 1 | env('MAIL_MAILER', 'log'), 18 | 19 | /* 20 | |-------------------------------------------------------------------------- 21 | | Mailer Configurations 22 | |-------------------------------------------------------------------------- 23 | | 24 | | Here you may configure all of the mailers used by your application plus 25 | | their respective settings. Several examples have been configured for 26 | | you and you are free to add your own as your application requires. 27 | | 28 | | Laravel supports a variety of mail "transport" drivers that can be used 29 | | when delivering an email. You may specify which one you're using for 30 | | your mailers below. You may also add additional mailers if needed. 31 | | 32 | | Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2", 33 | | "postmark", "resend", "log", "array", 34 | | "failover", "roundrobin" 35 | | 36 | */ 37 | 38 | 'mailers' => [ 39 | 40 | 'smtp' => [ 41 | 'transport' => 'smtp', 42 | 'scheme' => env('MAIL_SCHEME'), 43 | 'url' => env('MAIL_URL'), 44 | 'host' => env('MAIL_HOST', '127.0.0.1'), 45 | 'port' => env('MAIL_PORT', 2525), 46 | 'username' => env('MAIL_USERNAME'), 47 | 'password' => env('MAIL_PASSWORD'), 48 | 'timeout' => null, 49 | 'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url(env('APP_URL', 'http://localhost'), PHP_URL_HOST)), 50 | ], 51 | 52 | 'ses' => [ 53 | 'transport' => 'ses', 54 | ], 55 | 56 | 'postmark' => [ 57 | 'transport' => 'postmark', 58 | // 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'), 59 | // 'client' => [ 60 | // 'timeout' => 5, 61 | // ], 62 | ], 63 | 64 | 'resend' => [ 65 | 'transport' => 'resend', 66 | ], 67 | 68 | 'sendmail' => [ 69 | 'transport' => 'sendmail', 70 | 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'), 71 | ], 72 | 73 | 'log' => [ 74 | 'transport' => 'log', 75 | 'channel' => env('MAIL_LOG_CHANNEL'), 76 | ], 77 | 78 | 'array' => [ 79 | 'transport' => 'array', 80 | ], 81 | 82 | 'failover' => [ 83 | 'transport' => 'failover', 84 | 'mailers' => [ 85 | 'smtp', 86 | 'log', 87 | ], 88 | 'retry_after' => 60, 89 | ], 90 | 91 | 'roundrobin' => [ 92 | 'transport' => 'roundrobin', 93 | 'mailers' => [ 94 | 'ses', 95 | 'postmark', 96 | ], 97 | 'retry_after' => 60, 98 | ], 99 | 100 | ], 101 | 102 | /* 103 | |-------------------------------------------------------------------------- 104 | | Global "From" Address 105 | |-------------------------------------------------------------------------- 106 | | 107 | | You may wish for all emails sent by your application to be sent from 108 | | the same address. Here you may specify a name and address that is 109 | | used globally for all emails that are sent by your application. 110 | | 111 | */ 112 | 113 | 'from' => [ 114 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 115 | 'name' => env('MAIL_FROM_NAME', 'Example'), 116 | ], 117 | 118 | ]; 119 | -------------------------------------------------------------------------------- /env_laravel1/app/sample/config/queue.php: -------------------------------------------------------------------------------- 1 | env('QUEUE_CONNECTION', 'database'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Queue Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure the connection options for every queue backend 24 | | used by your application. An example configuration is provided for 25 | | each backend supported by Laravel. You're also free to add more. 26 | | 27 | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'sync' => [ 34 | 'driver' => 'sync', 35 | ], 36 | 37 | 'database' => [ 38 | 'driver' => 'database', 39 | 'connection' => env('DB_QUEUE_CONNECTION'), 40 | 'table' => env('DB_QUEUE_TABLE', 'jobs'), 41 | 'queue' => env('DB_QUEUE', 'default'), 42 | 'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90), 43 | 'after_commit' => false, 44 | ], 45 | 46 | 'beanstalkd' => [ 47 | 'driver' => 'beanstalkd', 48 | 'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'), 49 | 'queue' => env('BEANSTALKD_QUEUE', 'default'), 50 | 'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90), 51 | 'block_for' => 0, 52 | 'after_commit' => false, 53 | ], 54 | 55 | 'sqs' => [ 56 | 'driver' => 'sqs', 57 | 'key' => env('AWS_ACCESS_KEY_ID'), 58 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 59 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 60 | 'queue' => env('SQS_QUEUE', 'default'), 61 | 'suffix' => env('SQS_SUFFIX'), 62 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 63 | 'after_commit' => false, 64 | ], 65 | 66 | 'redis' => [ 67 | 'driver' => 'redis', 68 | 'connection' => env('REDIS_QUEUE_CONNECTION', 'default'), 69 | 'queue' => env('REDIS_QUEUE', 'default'), 70 | 'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90), 71 | 'block_for' => null, 72 | 'after_commit' => false, 73 | ], 74 | 75 | ], 76 | 77 | /* 78 | |-------------------------------------------------------------------------- 79 | | Job Batching 80 | |-------------------------------------------------------------------------- 81 | | 82 | | The following options configure the database and table that store job 83 | | batching information. These options can be updated to any database 84 | | connection and table which has been defined by your application. 85 | | 86 | */ 87 | 88 | 'batching' => [ 89 | 'database' => env('DB_CONNECTION', 'sqlite'), 90 | 'table' => 'job_batches', 91 | ], 92 | 93 | /* 94 | |-------------------------------------------------------------------------- 95 | | Failed Queue Jobs 96 | |-------------------------------------------------------------------------- 97 | | 98 | | These options configure the behavior of failed queue job logging so you 99 | | can control how and where failed jobs are stored. Laravel ships with 100 | | support for storing failed jobs in a simple file or in a database. 101 | | 102 | | Supported drivers: "database-uuids", "dynamodb", "file", "null" 103 | | 104 | */ 105 | 106 | 'failed' => [ 107 | 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), 108 | 'database' => env('DB_CONNECTION', 'sqlite'), 109 | 'table' => 'failed_jobs', 110 | ], 111 | 112 | ]; 113 | --------------------------------------------------------------------------------