1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Docker】最小構成でLaravel13環境構築

1
Posted at

Dockerfileとdocker-compose.ymlを用意。

WSL2環境で確認済み

Dockerfile
# Laravel 12/13 は PHP 8.2+ が必須。今なら 8.3 か 8.4 がおすすめ
FROM php:8.3-cli-alpine

# Composer のインストール(安定の最新版)
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

# 最新の Laravel に必要なシステムパッケージ
# sqlite-dev: L11以降、標準のDBとしてよく使われるため追加
RUN apk add --no-cache \
    git \
    unzip \
    zip \
    libzip-dev \
    sqlite-dev \
    icu-dev \
    oniguruma-dev

# 必須級のPHP拡張
# bcmath/intl: Laravelの文字列処理や計算に必要
RUN docker-php-ext-install zip bcmath intl opcache

WORKDIR /var/www
docker-compose.yml
services:
  app:
    build: .
    volumes:
      - .:/var/www
    ports:
      - "{空いてるポート}:8000"
    environment:
      # 依存関係解決中はメモリを食うので制限を解除しておくのがコツです
      - COMPOSER_MEMORY_LIMIT=-1
    tty: true
    stdin_open: true
sudo docker compose build
docker compose up -d
# cliだからshじゃないと通らない
docker compose exec app sh
> composer create-project laravel/laravel:^13.0 {pj_name}
> cd {pj_name}
> php artisan serve --host=0.0.0.0 --port=8000
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?