LoginSignup
1
2

More than 5 years have passed since last update.

【GAE】PHP7を拡張してカスタムランタイムをデプロイする

Last updated at Posted at 2019-04-08

前提

  • GAE PHP72 runtimeで動いているLaravelアプリケーションが存在する

ffmpeg を利用して動画から静止画を作成し、
Cloud Vision APIで解析を行うための環境を作ろうと思います。

ランタイムの拡張

プロジェクトのディレクトリで下記のコマンドを実行してベースとなるapp.yaml, Dockerfileを作成します
gcloud beta app gen-config --custom

ベースを元に設定を追加します

app.yaml

runtime: custom
env: flex

runtime_config:
  document_root: public

# Ensure we skip ".env", which is only for local development
skip_files:
  - .env

env_variables:
  # Put production environment variables here.
  APP_LOG: errorlog
  WHITELIST_FUNCTIONS: proc_open,proc_close

automatic_scaling:     # add
  min_num_instances: 1 # add
  max_num_instances: 1 # add

Dockerfile

# Dockerfile extending the generic PHP image with application files for a
# single application.
FROM gcr.io/google-appengine/php:latest

## FFMpeg Dependency
RUN apt-get update -qq && apt-get -y install \
  autoconf \
  automake \
  build-essential \
  cmake \
  git-core \
  libass-dev \
  libfreetype6-dev \
  libsdl2-dev \
  libtool \
  libva-dev \
  libvdpau-dev \
  libvorbis-dev \
  libxcb1-dev \
  libxcb-shm0-dev \
  libxcb-xfixes0-dev \
  pkg-config \
  texinfo \
  wget \
  zlib1g-dev

RUN apt-get update -y && apt-get install -y \
        vim \
        unzip \
        zip \
        zlib1g-dev \
        ffmpeg

# The Docker image will configure the document root according to this
# environment variable.
ENV DOCUMENT_ROOT /app/public

基本的にffmpegなどのミドルウェアをインストールしたい場合には
PHP用のベースイメージを元に拡張してあげれば環境を作ることができます

FROM gcr.io/google-appengine/php:latest

ローカル環境として立ち上げる場合にはコンテナの8080portが開いているので
好きなホストのportと繋ぐといいと思います

1
2
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
2