Skip to content

Instantly share code, notes, and snippets.

@n1215
Last active September 13, 2023 15:29
Show Gist options
  • Save n1215/4569c9bb0b5cc68f91897028ffc8a0d3 to your computer and use it in GitHub Desktop.
Save n1215/4569c9bb0b5cc68f91897028ffc8a0d3 to your computer and use it in GitHub Desktop.
build settings for Laravel + Heroku Buildpacks on AWS App Runner/Google Cloud Run
version: 0.2
env:
variables:
APPLICATION_NAME: "myapp"
PACK_VERSION: "0.29.0"
phases:
install:
commands:
- wget -q https://github.com/buildpacks/pack/releases/download/v$PACK_VERSION/pack-v$PACK_VERSION-linux.tgz -O - | tar -xz
- chmod +x ./pack
pre_build:
commands:
- AWS_ACCOUNT_ID=$CODEBUILD_BUILD_ARN && IFS=':' && set -- $AWS_ACCOUNT_ID && AWS_ACCOUNT_ID=$5
- ECR_DOMAIN="$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com"
- ECR_REPOSITORY="$ECR_DOMAIN/$APPLICATION_NAME"
- aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $ECR_DOMAIN
build:
commands:
- |
./pack build "$ECR_REPOSITORY:latest" \
--verbose \
--no-color \
--cache-image "$ECR_REPOSITORY:cache" \
--tag "$ECR_REPOSITORY:$CODEBUILD_RESOLVED_SOURCE_VERSION" \
--publish
steps:
- name: gcr.io/k8s-skaffold/pack
args:
- build
- $_IMAGE_NAME:latest
- --verbose
- --tag
- $_IMAGE_NAME:$REVISION_ID
- --cache-image
- $_IMAGE_NAME:cache
- --publish
- name: gcr.io/cloud-builders/gcloud
args:
- run
- deploy
- $_APP_NAME
- --image
- $_IMAGE_NAME
- --region
- asia-northeast1
- --allow-unauthenticated
substitutions:
_IMAGE_NAME: 'asia-northeast1-docker.pkg.dev/${PROJECT_ID}/myrepo/myapp'
_APP_NAME: 'myapp'
options:
logging: CLOUD_LOGGING_ONLY
dynamic_substitutions: true
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
- "php": "^8.1",
+ "php": "~8.2.0",
+ "ext-redis": "5.3.7",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^10.10",
"laravel/sanctum": "^3.2",
"laravel/tinker": "^2.8"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
"laravel/pint": "^1.0",
"laravel/sail": "^1.18",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^7.0",
"phpunit/phpunit": "^10.1",
"spatie/laravel-ignition": "^2.0"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true,
"php-http/discovery": true
}
},
"minimum-stability": "stable",
"prefer-stable": true
}
location / {
try_files $uri @rewriteapp;
}
location @rewriteapp {
rewrite ^(.*)$ /index.php$1 last;
}
{
"private": true,
+ "engines": {
+ "node": "18.x"
+ },
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build"
},
"devDependencies": {
"axios": "^1.1.2",
"laravel-vite-plugin": "^0.7.5",
"vite": "^4.0.0"
}
}
web: heroku-php-nginx -C nginx.conf public
[_]
id = "my-project"
name = "My Project"
version = "1.0.0"
schema-version="0.2"
[io.buildpacks]
builder = "heroku/buildpacks:20"
exclude = [
".idea",
"/README.md",
".git",
"/vendor",
"/node_modules",
"/bootstrap/cache/*.php",
]
[[io.buildpacks.group]]
uri = "heroku/php"
[[io.buildpacks.group]]
uri = "heroku/procfile"
[[io.buildpacks.group]]
uri = "heroku/nodejs"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment