インストール後、SoftwareUpdaterが走る。とても手間がかかるようです。
しかし、今までがUbuntu16だったので、いちいち無駄な手間がかかっていたのが解消されれば良いなと。
Dockerで環境を構築することにするので、その手順。
コマンドを順番に実行するだけだと思います。
Heroku環境を作る。参考
git clone 元
いや、下の3つ入らなかったような??
docker pull php:7.4-fpm-alpine
docker pull nginx:1.19-alpine
docker pull postgres:12
git clone https://github.com/nagi125/laravel-docker-template
cd laravel-docker-template/
docker-compose up
apt install docker-compose
docker-compose up
何かエラーが出ているような・・・・
2022-04-03 続き
docker-compose up
で起動完了。
laravelインストール
docker-compose exec app composer create-project –prefer-dist laravel/laravel blog “6.*”
docker-compose exec app cp -R ./blog/. ./
http://localhost
にアクセスできるけどエラーが出る。
file_put_contents(/app/storage/framework/sessions/P3K1Aj8hOoLxXi7AMqZD1Y7oPc8moikg4urhQuhM): failed to open stream: Permission denied
対策 参考
chmod 777 storage/logs
chmod 777 storage/framework/sessions/
chmod 777 storage/framework/views/
http://localhost/
でトップページが表示された。
vi .heroku/nginx/nginx.conf
vi Procfile
heroku-cli インストール 公式参考
sudo snap install –classic heroku
結構手間がかかっています。
heroku login
自動でブラウザは起動しなかった。まあ手動でログイン。
heroku buildpacks:add heroku/php -a your-app-name
heroku buildpacks:add heroku/nodejs -a your-app-name
git push heroku main
fatal: ‘heroku’ does not appear to be a git repository
fatal: Could not read from remote repository.
gitのリポジトリが無い。
gitインストールして無かったから。 参考
sudo apt update && sudo apt install git
git –version
git version 2.25.1
git push heroku main
fatal: ‘heroku’ does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
対策、参考
git remote add heroku https://git.heroku.com/アプリケーション名.git
git push heroku main
! [rejected] main -> main (fetch first)
error: failed to push some refs to ‘https://git.heroku.com/アプリ名.git’
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., ‘git pull …’) before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push –help’ for details.
対策、参考
git commit
*** Please tell me who you are.
対策、参考
$git config –global user.email ここに自分のアドレス
$git config –global user.name ここに自分の名前
git commit
何かまだエラーがあるような
そもそも、gitコマンドに慣れてないので。参考
git push heroku main
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., ‘git pull …’) before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push –help’ for details.
なるほど既に前のやつとの整合性が取れない。参考。
git pull heroku main
なるほど。アプリケーションを新しく作った方が良いな。リモートの。
http://localhost/
でエラーになってしまった。pullしたせいだなこれは。
要はやり直した方が良い。
削除。docker rm などで。参考
docker rmi [イメージID]
2022-04-05 作り直した後
git push heroku main
でまだエラーが出る。
remote: Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255
remote: ! WARNING: A post-autoload-dump script terminated with an error
remote:
remote: ! ERROR: Dependency installation failed!
remote: !
remote: ! The 'composer install' process failed with an error. The cause
remote: ! may be the download or installation of packages, or a pre- or
remote: ! post-install hook (e.g. a 'post-install-cmd' item in 'scripts')
remote: ! in your 'composer.json'.
remote: !
remote: ! Typical error cases are out-of-date or missing parts of code,
remote: ! timeouts when making external connections, or memory limits.
remote: !
remote: ! Check the above error output closely to determine the cause of
remote: ! the problem, ensure the code you're pushing is functioning
remote: ! properly, and that all local changes are committed correctly.
remote: !
remote: ! For more information on builds for PHP on Heroku, refer to
remote: ! https://devcenter.heroku.com/articles/php-support
remote: !
remote: ! REMINDER: the following warnings were emitted during the build;
remote: ! check the details above, as they may be related to this error:
remote: ! - A post-autoload-dump script terminated with an error
remote:
remote: ! Push rejected, failed to compile PHP app.
remote:
remote: ! Push failed
remote: !
remote: ! ## Warning - The same version of this code has already been built: 4f6a003432986e9c40d4e65c18566b7000573630
remote: !
remote: ! We have detected that you have triggered a build from source code with version 4f6a003432986e9c40d4e65c18566b7000573630
remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote: !
remote: ! If you are developing on a branch and deploying via git you must run:
remote: !
remote: ! git push heroku :main
remote: !
remote: ! This article goes into details on the behavior:
remote: ! https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
2022-04-07 結構手間取ったけどphp8にしないといけないのかな
————-
ビルドログがなんか違うぞ。
Installing platform packages…
– php (8.1.4)
– apache (2.4.53)
– composer (2.3.3)
– nginx (1.20.2)
どうもこれらしいな。phpのバージョンが8になってるんだ。
laravelはversion8からphp8なのか?
docker-compose exec app composer create-project –prefer-dist laravel/laravel blog “8.*”
docker-compose exec app cp -R ./blog/. ./
docker-compose exec app rm -rf blog
ではphpは8にならなかった。
php8にする。どうやって? 参考
.docker/php# vi Dockerfile
#FROM php:7.4-fpm-alpine
FROM php:8.0.5-fpm-alpine
docker rmi a64a6e03b055
とかで消してから再度docker-compose up
docker-compose exec app composer create-project –prefer-dist laravel/laravel blog “8.*”
ralavelのversion8をインストール
docker-compose exec app cp -R ./blog/. ./
docker-compose exec app rm -rf blog
git add .
git commit -m “comment”
http://localhost/
でエラーが出る。
Symfony\Component\ErrorHandler\Error\FatalError
Declaration of Symfony\Component\Translation\TranslatorInterface::getLocale() must be compatible with Symfony\Contracts\Translation\LocaleAwareInterface::getLocale(): string
“symfony/translation”: “4.3.8”,
なんか違う事やってたかもしれない。解決できないな。
composer update
sudo apt-get remove composer;
composer self-update
しかし、git push heroku main で、
ビルドはできた。
heroku config:set APP_KEY=your-app-key -a your-app-name
が無いからアクセスはできない。