LoginSignup
0
0

More than 3 years have passed since last update.

CircleCIで詰まったこと

Last updated at Posted at 2020-05-11

前提

php:7.3
laravel:6
postgres:9.6
ubuntu
macOS

本題

CircleCI導入時に詰まったところを記入していきます。

今回はDBにpostgresを使用していたため、以下の記述が必要になるとのこと。
&& sudo apt-get -y install libpq-dev

config.yml
#変更前
steps:    
      - checkout
      - run:
          name: Update apt-get
          command: sudo apt-get update


#変更後
steps:    
      - checkout
      - run:
          name: Update apt-get
          command: sudo apt-get update  && sudo apt-get -y install libpq-dev

mmap() failed: [12] Cannot allocate memory

メモリー容量不足が原因とのこと。
下記のコマンドをターミナルに入力し解決。

# free -m   #容量の確認
# sudo dd if=/dev/zero of=/swapfile bs=1M count=2048
# sudo chmod 600 /swapfile
# sudo mkswap /swapfile
# sudo swapon /swapfile

SQLSTATE[08006] [7] FATAL: role "root" does not exist

ずーっとこのエラーにハマってました...
DockerHubの公式サイトを見るとすぐに解決しました。
https://hub.docker.com/r/circleci/postgres

cofig.yml
#変更前
version: 2
jobs:
  build:
    docker:
      - image: circleci/php:7.3-node-browsers
      - image: circleci/postgres:9.6-alpine
    environment:
      - DB_CONNECTION: circle_testing

#変更後
version: 2
jobs:
  build:
    docker:
      - image: circleci/php:7.3-node-browsers
      - image: circleci/postgres:9.6-alpine
    environment:
      - ENV POSTGRES_DB: circle_testing  #変更点

Impossible to create the root directory

そういえば、ssh内のlaravel/.envのAPP_URLがローカルになってると思い、修正しました。

env.
#変更前
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:*************************=
APP_DEBUG=true
APP_URL=http://localhost

#変更後
APP_URL=http://本番環境のURL.com

APP_URL=http://localhostを本番環境のURLに変更しました。

よし、これでリロード!
...またエラー

failed to open stream: Permission denied

ディレクトリパーミッション
Laravelをインストールした後に、多少のパーミッションの設定が必要とのこと。
storage下とbootstrap/cacheディレクトリをWebサーバから書き込み可能に設定。
設定しないとLaravelは正しく実行されません。
Homestead仮想マシンを使用する場合は、あらかじめ設定されています。

root@eee10544329b:/var/www# chmod -R 777 storage
root@eee10544329b:/var/www# chmod -R 777 bootstrap/cache

何とか本番環境でアプリケーションを問題なく起動できました。

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