Assets are not published when run from GitHub Actions (Laravel)

I am running a script to deploy to fly with GitHub Actions as well as my local development environment.

I like this a lot, but I noticed that when I deploy with GitHub Actions, the styling sheet is not being applied to my Laravel built site. The cause is simple, it seems that assets such as styling sheets and JavaScript are not compiling.

They compile fine in my local development environment, but don’t seem to work on GitHub Actions.

What is updating the assets based on …?


Can you post the Dockerfile you have, and let us know if your GHA definition might be over-writing it (perhaps it uses fly launch to re-create a new Dockerfile that might over-write some things? That part is unlikely, but I just want to be sure).

In theory the multi-stage Dockerfile that Fly sets up builds the NodeJS assets in a separate build-step, and then copies that into the code files into the “main” docker image created.

That’s done here: flyctl/Dockerfile at master · superfly/flyctl · GitHub

Your Dockerfile may be slightly different depending on when it was generated (if you used fly launch to first generate it).

Thanks for the reply!
Before making this post, I compared it to the code of the fly body you presented and I could not find any problems.
And I’m suspicious why, in that it works correctly locally, but this problem occurs in GitHub Actions.

# Multi-stage build: Build static assets
# This allows us to not include Node within the final container
FROM node:${NODE_VERSION} as node_modules_go_brrr

RUN mkdir /app

RUN mkdir -p  /app
COPY . .
COPY --from=base /var/www/html/vendor /app/vendor

# Use yarn or npm depending on what type of
# lock file we might find. Defaults to
# NPM if no lock file is found.
# Note: We run "production" for Mix and "build" for Vite
RUN if [ -f "vite.config.js" ]; then \
        ASSET_CMD="build"; \
    else \
        ASSET_CMD="production"; \
    fi; \
    if [ -f "yarn.lock" ]; then \
        yarn install --frozen-lockfile; \
        yarn $ASSET_CMD; \
    elif [ -f "package-lock.json" ]; then \
        npm ci --no-audit; \
        npm run $ASSET_CMD; \
    else \
        npm install; \
        npm run $ASSET_CMD; \

# From our base container created above, we
# create our final image, adding in static
# assets that we generated above
FROM base

# Packages like Laravel Nova may have added assets to the public directory
# or maybe some custom assets were added manually! Either way, we merge
# in the assets we generated above rather than overwrite them
COPY --from=node_modules_go_brrr /app/public /var/www/html/public-npm
RUN rsync -ar /var/www/html/public-npm/ /var/www/html/public/ \
    && rm -rf /var/www/html/public-npm \
    && chown -R webuser:webgroup /var/www/html/public

Hmmmm - Do you have a yarn.lock or package.lock file locally that’s not committed to the git repository?

Also be sure to double check build output. You should be able to add env var NO_COLOR=1 before running fly deploy in order to get the “plain” version of the docker build output, which can help uncover errors when building.

(Although I think it would fail to build the Docker image there, but there might be some clues. You could even add some debugging information - echo "foo"; in the conditionals of the Dockerfile to see which if / elif statement is being run).