読み込みが終了しない場合は、しばらく待つか、リロードを行なってください。
If loading does not finish, wait for a while or reload.
エンジニア向けの情報を発信するブログです。
どなたでも発信できます。
お好きに利用していただれば幸いです。
変更履歴
20230323
srcディレクトリを作成する記述をしていなかったので追加しました
20230407
sqlクライアントの設定を追加しました
git clone https://github.com/oracle/docker-images.git
👇 ダウンロードしたzipファイル docker-images/OracleDatabase/SingleInstance/dockerfiles/21.3.0/LINUX.X64_213000_db_home.zip
cd docker-images/OracleDatabase/SingleInstance/dockerfiles
./buildContainerImage.sh -v 21.3.0 -x -i
Oracle Database container image for 'xe' version 21.3.0 is ready to be extended: --> oracle/database:21.3.0-xe Build completed in 674 seconds.
docker images REPOSITORY TAG IMAGE ID CREATED SIZE oracle/database 21.3.0-xe fbf0460bd29d 3 minutes ago 6.54GB
root ├── docker │ ├── nginx │ │ └── default.conf │ ├── oracle │ │ └── oradata │ └── php │ ├── Dockerfile │ ├── entrypoint.sh │ ├── instantclient-basic-linux.x64-21.9.0.0.0dbru.zip │ ├── instantclient-sdk-linux.x64-21.9.0.0.0dbru.zip │ └── php.ini ├── docker-compose.yml ├── .env └── src (laravelのファイル群) ├── ...
root ├── docker │ └── php │ ├── instantclient-basic-linux.x64-21.9.0.0.0dbru.zip │ └── instantclient-sdk-linux.x64-21.9.0.0.0dbru.zip
version: '3' services: app: build: context: . dockerfile: ./docker/php/Dockerfile args: XDEBUG_INSTALL: "${XDEBUG_INSTALL:-false}" ports: - "9000:9000" - "4430:443" volumes: - "./src:/var/www/html:${VOLUME_CONSISTENCY:-consistent}" environment: - HOST_UID - XDEBUG_CLIENT_HOST - "XDEBUG_CLIENT_PORT=${XDEBUG_CLIENT_PORT:-9000}" - "XDEBUG_INSTALL=${XDEBUG_INSTALL:-false}" depends_on: - oracle web: image: nginx:1.23.3 volumes: - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf - "./src:/var/www/html" ports: - "${WEB_HOST_PORT:-80}:80" depends_on: - app oracle: image: oracle/database:21.3.0-xe container_name: oracle shm_size: 1g ports: - 1521:1521 - 5500:5500 volumes: - ./docker/oracle/oradata:/opt/oracle/oradata environment: - ORACLE_PWD=passw0rd - ORACLE_CHARACTERSET=AL32UTF8 - TZ=Asia/Tokyo mailcatcher: image: schickling/mailcatcher ports: - "1080:1080" - "1025:1025"
XDEBUG_INSTALL=true HOST_UID=501 XDEBUG_CLIENT_HOST=host.docker.internal XDEBUG_CLIENT_PORT=9003 WEB_HOST_PORT=8080
FROM php:8.2.3-fpm ENV APACHE_DOCUMENT_ROOT /var/www/html RUN apt-get update \ && apt-get install --no-install-recommends -y \ apt-transport-https \ apt-utils \ build-essential \ curl \ debconf-utils \ gcc \ git \ vim \ zip \ gnupg2 \ libfreetype6-dev \ libicu-dev \ libjpeg62-turbo-dev \ libpng-dev \ libpq-dev \ libzip-dev \ locales \ ssl-cert \ unzip \ zlib1g-dev \ iputils-ping \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* \ && echo "en_US.UTF-8 UTF-8" >/etc/locale.gen \ && locale-gen \ ; ENV LD_LIBRARY_PATH /usr/local/instantclient/ ENV TNS_ADMIN /usr/local/instantclient/ COPY ./docker/php/instantclient-basic-linux.x64-21.9.0.0.0dbru.zip /tmp COPY ./docker/php/instantclient-sdk-linux.x64-21.9.0.0.0dbru.zip /tmp RUN apt-get update && \ apt-get install -y zip unzip libaio1 wget && \ unzip /tmp/instantclient-basic-linux.x64-21.9.0.0.0dbru.zip -d /usr/local/ && \ unzip /tmp/instantclient-sdk-linux.x64-21.9.0.0.0dbru.zip -d /usr/local/ && \ ln -s /usr/local/instantclient_21_9 /usr/local/instantclient && \ ln -s /usr/local/instantclient/libclntsh.so.21.1 /usr/local/instantclient/lnlibclntsh.so && \ export LD_LIBRARY_PATH=/usr/local/instantclient && \ docker-php-ext-configure oci8 --with-oci8=instantclient,/usr/local/instantclient && \ docker-php-ext-install oci8 && \ docker-php-ext-configure pdo_oci --with-pdo-oci=instantclient,/usr/local/instantclient,12.2 && \ docker-php-ext-install pdo_oci && \ rm -rf /usr/local/*.zip RUN pecl install apcu && echo "extension=apcu.so" > /usr/local/etc/php/conf.d/apc.ini RUN curl -sS https://getcomposer.org/installer \ | php -- \ --filename=composer \ --install-dir=/usr/local/bin \ && chown www-data /var/www \ && chmod g+s /var/www/html RUN curl -SL https://deb.nodesource.com/setup_14.x | bash RUN apt-get install -y nodejs && \ npm install -g npm@latest && \ npm install -g @vue/cli ARG XDEBUG_INSTALL ARG BOOL=true RUN if [ ${XDEBUG_INSTALL} = ${BOOL} ]; then \ pecl install xdebug-3.2.0 && docker-php-ext-enable xdebug; \ fi COPY ./docker/php/php.ini /usr/local/etc/php/php.ini COPY ./docker/php/entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] CMD ["php-fpm"]
ln -s /usr/local/instantclient/libclntsh.so.21.1 /usr/local/instantclient/lnlibclntsh.so && \
libclntsh.so && \
lnlibclntsh.so && \
#!/bin/sh if [ -n "${HOST_UID}" -a "${HOST_UID}" != "$(id -u www-data)" ]; then usermod -u "${HOST_UID}" www-data fi if [ -n "${HOST_GID}" -a "${HOST_GID}" != "$(id -g www-data)" ]; then groupmod -g "${HOST_GID}" www-data fi if [ ${XDEBUG_INSTALL} = true ]; then ini=$(cat << EOS xdebug.client_host=${XDEBUG_CLIENT_HOST:-$(ip route | awk 'NR==1 {print $3}')} xdebug.client_port=${XDEBUG_CLIENT_PORT} xdebug.start_with_request=yes xdebug.remote_cookie_expire_time=3600 xdebug.mode=debug EOS ) echo "${ini}" >> /usr/local/etc/php/conf.d/php.ini fi exec docker-php-entrypoint "$@"
chmod 777 entrypoint.sh
opcache.max_accelerated_files = 20000 opcache.memory_consumption=256 realpath_cache_size = 4096K realpath_cache_ttl = 600 ; 一行改行を入れておく
server { listen 80; root /var/www/html/public; index index.php index.html; server_name php-docker.local; error_log /var/log/nginx/error.log; access_log /var/log/nginx/access.log; location / { try_files $uri /index.php$is_args$args; } location ~ \.php$ { fastcgi_read_timeout 365d; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass app:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; internal; } location ~ \\.php$ { return 404; } }
mkdir src
root ├── .env ├── docker │ ├── nginx │ │ └── default.conf │ └── php │ ├── Dockerfile │ ├── entrypoint.sh │ ├── instantclient-basic-linux.x64-21.9.0.0.0dbru.zip │ ├── instantclient-sdk-linux.x64-21.9.0.0.0dbru.zip │ └── php.ini ├── docker-compose.yml └── src
docker-compose build
docker-compose up
root ├── .env ├── docker │ ├── nginx │ │ └── default.conf │ ├── oracle 👈 upで自動的に作成される │ │ └── oradata │ │ ├── .XE.created │ │ ├── XE │ │ │ ├── ... │ │ └── dbconfig │ │ └── ... │ └── php │ ├── Dockerfile │ ├── entrypoint.sh │ ├── instantclient-basic-linux.x64-21.9.0.0.0dbru.zip │ ├── instantclient-sdk-linux.x64-21.9.0.0.0dbru.zip │ └── php.ini ├── docker-compose.yml └── src
docker-compose exec app bash
composer create-project laravel/laravel:^10.0 .
composer require yajra/laravel-oci8:^10
'providers' => [ /* * Laravel Framework Service Providers... */ Illuminate\Auth\AuthServiceProvider::class, .... // 👇 こいつを追加 Yajra\Oci8\Oci8ServiceProvider::class, ],
php artisan vendor:publish --tag=oracle
... DB_CONNECTION=oracle DB_HOST=oracle DB_PORT=1521 DB_DATABASE=XE DB_USERNAME=system DB_PASSWORD=passw0rd ... MAIL_MAILER=smtp MAIL_HOST=mailcatcher MAIL_PORT=1025 MAIL_USERNAME=null MAIL_PASSWORD=null MAIL_ENCRYPTION=null MAIL_FROM_ADDRESS="hello@example.com" MAIL_FROM_NAME="${APP_NAME}" ...
php artisan migrate
http://localhost:8080/
... public function run(): void { \App\Models\User::factory(10)->create(); \App\Models\User::factory()->create([ 'name' => 'Test User', 'email' => 'test@example.com', ]); } ...
php artisan db:seed
php artisan tinker
DB::table('users')->get();
http://localhost:4040
<?php use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Mail; // 👈 追加 /* |-------------------------------------------------------------------------- | Web Routes |-------------------------------------------------------------------------- | | Here is where you can register web routes for your application. These | routes are loaded by the RouteServiceProvider and all of them will | be assigned to the "web" middleware group. Make something great! | */ Route::get('/', function () { // 👇 こいつを追加 Mail::raw('こんにちお', function ($message) { $message ->to('beginnerengineerblog@sample.com') ->bcc('beginnerengineer@sample.com') ->subject('Hello Beginner Engineer!'); }); return view('welcome'); });
http://localhost:8080/
http://localhost:1080/
Route::get('/', function () { phpinfo(); // 👈 こいつを追加 return view('welcome'); });
http://localhost:8080/