How to built a production ready app with custom Laravel-Nova Component (Docker)

Im trying to produce a production ready docker container which could have all the nova features, but my custom component (field) is missing when i build the image. Dockerfile

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code># Stage 1
FROM node:20 AS build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install --legacy-peer-deps
COPY . .
RUN npm install laravel-mix@latest
RUN npm run build:icons
RUN npm run build
RUN npm run build-location_search-prod
# Stage 2
FROM php:8.3.2-fpm
ARG UID=1000
ARG GID=1000
ENV COMPOSER_ALLOW_SUPERUSER=1
RUN apt-get update && apt-get install -y
git
curl
libpng-dev
libonig-dev
libxml2-dev
zip
unzip
libzip-dev
gnupg2
libicu-dev
&& pecl install mongodb
&& docker-php-ext-enable mongodb
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd zip intl
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
WORKDIR /var/www
COPY . /var/www
RUN composer install --no-dev --optimize-autoloader
COPY --from=build-stage /app/public/build /var/www/public/build
COPY --from=build-stage /app/nova-components /var/www/nova-components
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
RUN groupadd -g ${GID} appgroup &&
useradd -u ${UID} -g appgroup -m appuser &&
chown -R appuser:appgroup /var/www
USER appuser
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["php-fpm"]
</code>
<code># Stage 1 FROM node:20 AS build-stage WORKDIR /app COPY package*.json ./ RUN npm install --legacy-peer-deps COPY . . RUN npm install laravel-mix@latest RUN npm run build:icons RUN npm run build RUN npm run build-location_search-prod # Stage 2 FROM php:8.3.2-fpm ARG UID=1000 ARG GID=1000 ENV COMPOSER_ALLOW_SUPERUSER=1 RUN apt-get update && apt-get install -y git curl libpng-dev libonig-dev libxml2-dev zip unzip libzip-dev gnupg2 libicu-dev && pecl install mongodb && docker-php-ext-enable mongodb RUN apt-get clean && rm -rf /var/lib/apt/lists/* RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd zip intl COPY --from=composer:latest /usr/bin/composer /usr/bin/composer WORKDIR /var/www COPY . /var/www RUN composer install --no-dev --optimize-autoloader COPY --from=build-stage /app/public/build /var/www/public/build COPY --from=build-stage /app/nova-components /var/www/nova-components COPY docker-entrypoint.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/docker-entrypoint.sh RUN groupadd -g ${GID} appgroup && useradd -u ${UID} -g appgroup -m appuser && chown -R appuser:appgroup /var/www USER appuser ENTRYPOINT ["docker-entrypoint.sh"] CMD ["php-fpm"] </code>
# Stage 1
FROM node:20 AS build-stage

WORKDIR /app

COPY package*.json ./

RUN npm install --legacy-peer-deps

COPY . .

RUN npm install laravel-mix@latest

RUN npm run build:icons
RUN npm run build
RUN npm run build-location_search-prod


# Stage 2
FROM php:8.3.2-fpm

ARG UID=1000
ARG GID=1000
ENV COMPOSER_ALLOW_SUPERUSER=1

RUN apt-get update && apt-get install -y 
    git 
    curl 
    libpng-dev 
    libonig-dev 
    libxml2-dev 
    zip 
    unzip 
    libzip-dev 
    gnupg2 
    libicu-dev 
    && pecl install mongodb 
    && docker-php-ext-enable mongodb

RUN apt-get clean && rm -rf /var/lib/apt/lists/*

RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd zip intl

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

WORKDIR /var/www

COPY . /var/www

RUN composer install --no-dev --optimize-autoloader

COPY --from=build-stage /app/public/build /var/www/public/build
COPY --from=build-stage /app/nova-components /var/www/nova-components

COPY docker-entrypoint.sh /usr/local/bin/

RUN chmod +x /usr/local/bin/docker-entrypoint.sh

RUN groupadd -g ${GID} appgroup && 
    useradd -u ${UID} -g appgroup -m appuser && 
    chown -R appuser:appgroup /var/www

USER appuser

ENTRYPOINT ["docker-entrypoint.sh"]

CMD ["php-fpm"]

Can’t understand where should I put the nova components dist folder then that it could be accessible in production env.

My app consists of Laravel + Vite (Vue) + Laravel Nova

Everything works fine expect my laravel nova custom field.

The package.json itself has script as well like this which is executing:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>"build-location_search-prod": "cd nova-components/LocationSearch && npm run prod"
</code>
<code>"build-location_search-prod": "cd nova-components/LocationSearch && npm run prod" </code>
"build-location_search-prod": "cd nova-components/LocationSearch && npm run prod"

So basically after container builds the LocationSearch/dist folder is generated by running the script, but the field inside the nova resource is not shown. It was showing when I ran development environment. Now when serving via nginx and build directories its hidden.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật