0
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?

More than 1 year has passed since last update.

ucan-labさんの環境構築でDockerに任意の環境変数を使用する

Last updated at Posted at 2023-06-04

laravelの構築をする時に
ucan-labさんのdockerを使わせてもらってます。
すごい便利なのですが、Dockerを知ってたら当たり前なんでしょうが、環境変数を用意しておかないとデフォルト設定しか反映されない。

  • APP_DEBUG=${APP_DEBUG:-true}の部分はbashの環境変数にAPP_DEBUGが入ってないと反映されない。APP_DEBUGの環境変数がない場合はtrueを使用。envコマンドで環境変数は見れる。

ひとまず下記のコマンドを叩くようにしました。

export $(cat ./src/.env)
docker-compose.yml
services:
  app:
    build:
      context: .
      dockerfile: ./infra/docker/php/Dockerfile
      target: ${APP_BUILD_TARGET:-development}
    volumes:
      - type: bind
        source: ./src
        target: /workspace
      - type: volume
        source: psysh-store
        target: /root/.config/psysh
        volume:
          nocopy: true
    environment:
      - APP_DEBUG=${APP_DEBUG:-true}
      - APP_ENV=${APP_ENV:-local}
      - APP_URL=${APP_URL:-http://localhost}
      - LOG_CHANNEL=${LOG_CHANNEL:-stderr}
      - LOG_STDERR_FORMATTER=${LOG_STDERR_FORMATTER:-Monolog\Formatter\JsonFormatter}
      - DB_CONNECTION=${DB_CONNECTION:-mysql}
      - DB_HOST=${DB_HOST:-db}
      - DB_PORT=${DB_PORT:-3306}
      - DB_DATABASE=${DB_DATABASE:-laravel}
      - DB_USERNAME=${DB_USERNAME:-phper}
      - DB_PASSWORD=${DB_PASSWORD:-secret}

もっといい処理がある場合は教えてください。

0
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
0
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?