Shopify / shopify-app-template-php

280 stars 90 forks source link

Im using cli of shopify to install my app, laravel and react js ,how can depoy on herooku this shopify-app-template-php #468

Closed Lahoucine-hrird closed 1 year ago

Lahoucine-hrird commented 1 year ago

Issue summary

Write a short description of the issue here ↓

Im using cli of shopify to install my app, laravel and react js ,how can depoy on herooku this shopify-app-template-php

Expected behavior

Errors

-----> Building on the Heroku-22 stack -----> Using buildpacks:

  1. heroku/nodejs
  2. heroku/php -----> Node.js app detected

-----> Creating runtime environment

   NPM_CONFIG_LOGLEVEL=error
   NODE_VERBOSE=false
   NODE_ENV=production
   NODE_MODULES_CACHE=true

-----> Installing binaries engines.node (package.json): unspecified engines.npm (package.json): unspecified (use default)

   Resolving node version 18.x...
   Downloading and installing node 18.17.1...
   Using default npm version: 9.6.7

-----> Installing dependencies Installing node modules

   added 780 packages, and audited 782 packages in 12s

   146 packages are looking for funding
     run `npm fund` for details

   found 0 vulnerabilities
   npm notice 
   npm notice New major version of npm available! 9.6.7 -> 10.0.0
   npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.0.0>
   npm notice Run `npm install -g npm@10.0.0` to update!
   npm notice 

-----> Build Running build

   > applesting@1.0.0 build
   > shopify app build

── external error ───────────────────���────────────────────────────────────────── Error coming from composer build Command failed with ENOENT: composer build spawn composer ENOENT ──────────────────────────────────────────────────────────────────────────────── -----> Build failed

   We're sorry this build is failing! You can troubleshoot common issues here:
   https://devcenter.heroku.com/articles/troubleshooting-node-deploys

   Some possible problems:

   - Node version not specified in package.json
     https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version

   Love,
   Heroku

! Push rejected, failed to compile Node.js app. ! Push failed

NomanHameed commented 1 year ago

Deploy on heroku follow heroku documentation on Building Docker Images with heroku.yml.

Building Docker Images with heroku.yml

if still face issues feel free to ask. thanks

Lahoucine-hrird commented 1 year ago

λ git push heroku main
Enumerating objects: 11, done.
Counting objects: 100% (11/11), done.
Delta compression using up to 8 threads
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 798 bytes | 798.00 KiB/s, done.
Total 7 (delta 4), reused 0 (delta 0), pack-reused 0
remote: Updated 11076 paths from 6d3fe65c
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-22 stack
remote: -----> Using buildpacks:
remote: 1. heroku/nodejs
remote: 2. heroku/php
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_PRODUCTION=true
remote: NPM_CONFIG_LOGLEVEL=error
remote: USE_NPM_INSTALL=true
remote: NODE_VERBOSE=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=false
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): unspecified
remote: engines.npm (package.json): 8.15.0
remote:
remote: Resolving node version 18.x...
remote: Downloading and installing node 18.17.1...
remote: Bootstrapping npm 8.15.0 (replacing 9.6.7)...
remote: npm 8.15.0 installed
remote:
remote: -----> Restoring cache
remote: Caching has been disabled because NODE_MODULES_CACHE=false
remote:
remote: -----> Installing dependencies
remote: Installing node modules (package.json + package-lock)
remote:
remote: added 513 packages, and audited 515 packages in 7s
remote:
remote: 106 packages are looking for funding
remote: run npm fund for details
remote:
remote: found 0 vulnerabilities
remote:
remote: -----> Build
remote: Detected both "build" and "heroku-postbuild" scripts
remote: Running heroku-postbuild
remote:
remote: > applesting@1.0.0 heroku-postbuild
remote: > npm install && npm run build
remote:
remote:
remote: up to date, audited 515 packages in 1s
remote:
remote: 106 packages are looking for funding
remote: run npm fund for details
remote:
remote: found 0 vulnerabilities
remote:
remote: > applesting@1.0.0 build
remote: > shopify app build
remote:
remote: ── external error ───────────────────────────────────────────────────── remote:
remote: Error coming from composer build
remote:
remote: Command failed with ENOENT: composer build
remote: spawn composer ENOENT
remote:
remote: ─────────────────────────────────────────────────────────────────────── remote:
remote:
remote: -----> Build failed
remote:
remote: We're sorry this build is failing! You can troubleshoot common i remote: https://devcenter.heroku.com/articles/troubleshooting-node-deplo remote:
remote: Some possible problems:
remote:
remote: - Node version not specified in package.json
remote: https://devcenter.heroku.com/articles/nodejs-support#specifyin remote:
remote: Love,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to shopify-app25.
remote:
To https://git.heroku.com/shopify-app25.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/shopify-app25.git'

rafaelstz commented 1 year ago

If you're running the lasted template version, you won't be able to make it work without Docker. Heroku just works with your app in the root folder, but in this template, you have it in the web folder.

How to setup Docker + Heroku

Add a file called heroku.yml in your root folder.

setup:
  addons:
    - plan: heroku-postgresql
      as: DATABASE
    - plan: heroku-redis
      as: REDIS
build:
  docker:
    web: Dockerfile
  config:
    APP_NAME: "Laravel"
    APP_KEY: "base64:ijOdGTAH4faZfq5+yKSMAGAEGASJpZtgRSnxxljgnFXIrhrpCzI="
    APP_ENV: "production"
    APP_URL: "https://myapp.shopify.com"
    HOST: "https://myapp.shopify.com"
    SCOPES: "write_products,read_customers"
    LOG_CHANNEL: "stack"
#    LOG_LEVEL: "debug"
    APP_DEBUG: false
    API_VERSION: "2023-07"
    SHOPIFY_API_KEY: "1234asdfadvgthgqfb0463ce734g"
    SHOPIFY_API_SECRET: "313412341234fasdf0fb4770d5341"
    CACHE_DRIVER: "redis"
    REDIS_CLIENT: "phpredis"
    DB_CONNECTION: "pgsql"

Add these params in your Dockefile in the root folder, and override the initial ARG and ENV from Shopify.

ARG APP_NAME
ENV APP_NAME=$APP_NAME
ARG APP_KEY
ENV APP_KEY=$APP_KEY
ARG APP_DEBUG
ENV APP_DEBUG=$APP_DEBUG
ARG APP_ENV
ENV APP_ENV=$APP_ENV
ARG APP_URL
ENV APP_URL=$APP_URL
ARG LOG_CHANNEL
ENV LOG_CHANNEL=$LOG_CHANNEL
ARG HOST
ENV HOST=$HOST
ARG SCOPES
ENV SCOPES=$SCOPES
ARG SHOPIFY_API_KEY
ENV SHOPIFY_API_KEY=$SHOPIFY_API_KEY
ARG SHOPIFY_API_SECRET
ENV SHOPIFY_API_SECRET=$SHOPIFY_API_SECRET
ARG API_VERSION
ENV API_VERSION=$API_VERSION
ARG CACHE_DRIVER
ENV CACHE_DRIVER=$CACHE_DRIVER
ARG REDIS_CLIENT
ENV REDIS_CLIENT=$REDIS_CLIENT
ARG REDIS_URL
ENV REDIS_URL=$REDIS_URL
ARG REDIS_PORT
ENV REDIS_PORT=$REDIS_PORT
ARG DB_CONNECTION
ENV DB_CONNECTION=$DB_CONNECTION
ARG DB_HOST
ENV DB_HOST=$DB_HOST
ARG DB_PORT
ENV DB_PORT=$DB_PORT
ARG DB_DATABASE
ENV DB_DATABASE=$DB_DATABASE
ARG DB_USERNAME
ENV DB_USERNAME=$DB_USERNAME
ARG DB_PASSWORD
ENV DB_PASSWORD=$DB_PASSWORD

Then create a heroku-release.sh file in the root folder too with the content below:

if [[ -z "${DB_DATABASE}" ]]; then
  echo "Database not set up yet, skipping"
else
  php artisan migrate --force
fi

composer install --optimize-autoloader --no-dev &&
php artisan cache:clear &&
php artisan config:cache &&
php artisan route:cache &&
php artisan view:cache &&
php artisan optimize &&
npm run build &&

echo "Laravel App release done!"
Lahoucine-hrird commented 1 year ago

yes is lasted template version,I'm using sqlite,in storage folder,Do I need to create heroku-release.sh in the web folder Directory structure └── ├── shopify.app.toml ├── package.json ├── node_modules/ | └── ... ├── web/ | ├── composer.lock | ├── frontend/ | ├── public/ | ├── composer.json | ├── Dockerfile | ├── shopify.web.toml | └── .env | └── vendor/ | └── resources/ ├── extensions/ | ├── my-ui-extension | | ├── shopify.extension.toml | | ├── package.json | | └── ... | ├── my-function-extension | | ├── shopify.extension.toml | | ├── package.json | | └── ... | ├── my-theme-extension | | ├── shopify.extension.toml | | ├── package.json | | └── ... | └── ...

Lahoucine-hrird commented 1 year ago

-----> Using buildpacks:

  1. heroku/nodejs
  2. heroku/php
rafaelstz commented 1 year ago

@Lahoucine-hrird you won't need the heroku-release.sh. However, you will need to have the heroku.yml in your root folder and migrate from buildpacks to Docker.

Lahoucine-hrird commented 1 year ago

not need this addons??

Lahoucine-hrird commented 1 year ago

Illuminate\Database\QueryException could not find driver (SQL: select exists(select * from "sessions" where "shop" = myshop.myshopify.com and "access_token" is not null) as "exists")