FLY Launch failing again and again after The New Launch

I’ve been working on a private Shopify app using their PHP template and opted for fly.io as the hosting platform. Until yesterday, deploying changes or creating new apps was seamless. However, starting today, my ‘flyctl launch’ command consistently failed, despite the application working perfectly fine in my local environment. I’m uncertain about the sudden issues
Whenever I attempt ‘flyctl launch’, I encounter an error.

#0 46.61 Generating optimized autoload files
#0 48.71 > Illuminate\Foundation\ComposerScripts::postAutoloadDump
#0 48.73 > @php artisan package:discover --ansi
#0 48.84 
#0 48.84    Shopify\Exception\MissingArgumentException 
#0 48.84 
#0 48.84   Cannot initialize Shopify API Library. Missing values for: apiKey
#0 48.84 
#0 48.84   at vendor/shopify/shopify-api/src/Context.php:105
#0 48.84     101▕         }
#0 48.84     102▕ 
#0 48.84     103▕         if (!empty($missing)) {
#0 48.84     104▕             $missing = implode(', ', $missing);
#0 48.84   ➜ 105▕             throw new MissingArgumentException(
#0 48.84     106▕                 "Cannot initialize Shopify API Library. Missing values for: $missing"
#0 48.84     107▕             );
#0 48.84     108▕         }
#0 48.84     109▕
#0 48.84 
#0 48.84   1   app/Providers/AppServiceProvider.php:52
#0 48.84       Shopify\Context::initialize()
#0 48.84 
#0 48.84       +7 vendor frames 
#0 48.84   9   [internal]:0
#0 48.84       Illuminate\Foundation\Application::Illuminate\Foundation\{closure}()
#0 48.84 Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
------
Error: failed to fetch an image or build from source: error building: failed to solve: executor failed running [/bin/sh -c composer install]: exit code: 1

This is perplexing, as the same app was consistently launching successfully until yesterday. It’s frustrating to experience these failures now.
I’m using the official Shopify PHP template’s Dockerfile for deployment purposes

FROM php:8.1-fpm-alpine

ARG SHOPIFY_API_KEY
ENV SHOPIFY_API_KEY=$SHOPIFY_API_KEY

RUN apk update && apk add --update nodejs npm \
    composer php-pdo_sqlite php-pdo_mysql php-pdo_pgsql php-simplexml php-fileinfo php-dom php-tokenizer php-xml php-xmlwriter php-session \
    openrc bash nginx

RUN docker-php-ext-install pdo

COPY --chown=www-data:www-data web /app
WORKDIR /app

# Overwrite default nginx config
COPY web/nginx.conf /etc/nginx/nginx.conf

# Use the default production configuration
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

RUN composer install
RUN touch /app/storage/db.sqlite
RUN chown www-data:www-data /app/storage/db.sqlite

RUN cd frontend && npm install && npm run build
RUN composer build

ENTRYPOINT [ "/app/entrypoint.sh" ]

t’s important to note that the same project was deploying flawlessly until yesterday but has encountered deployment failures throughout today.".

Hi, are you trying to create a new app? If not, what you should use is fly deploy instead of fly launch.

The error message is saying you haven’t specified your SHOPIFY_API_KEY at build time. You should be passing this with a --build-args parameter to fly deploy:

fly deploy --build-args SHOPIFY_API_KEY=yaddayaddayadda

it’s interesting that you say this worked before; but I wonder if you recently added this Shopify code that needs the API key, and that explains why things aren’t working with that additional value anymore.

Hi Roadmr,
Yes, I am trying to create a new app. That’s why I am using the fly launch command.
I was able to do so smoothly by following three steps

fly launch
fly set secrets (if any) 
flyctl deploy --build-arg SHOPIFY_API_KEY=<API KEY HERE> --remote-only

but now it automatically starts deploying without prompting for that --build-arg

Note: I am creating a new app and I do understand that I will have to use flyctl deploy in case of an already created app Also I have added nothing much of new code which also annoys me in this issue.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.