mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-14 15:37:53 +00:00
refactored dockerfile
This commit is contained in:
parent
eee79fd11f
commit
26c752d2e3
1 changed files with 39 additions and 20 deletions
59
Dockerfile
59
Dockerfile
|
|
@ -1,29 +1,48 @@
|
||||||
FROM bnussbau/serversideup-php:8.3-fpm-nginx-alpine-imagick-chromium
|
########################
|
||||||
|
# Base Image
|
||||||
|
########################
|
||||||
|
FROM bnussbau/serversideup-php:8.3-fpm-nginx-alpine-imagick-chromium AS base
|
||||||
|
|
||||||
USER www-data
|
ENV AUTORUN_ENABLED="true"
|
||||||
|
|
||||||
# Set working directory
|
# Switch to the root user so we can do root things
|
||||||
|
USER root
|
||||||
|
|
||||||
|
# Set the working directory
|
||||||
WORKDIR /var/www/html
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
# Create required directories
|
# Copy the application files
|
||||||
RUN mkdir -p storage/logs \
|
COPY --chown=www-data:www-data . /var/www/html
|
||||||
&& mkdir -p storage/framework/{cache,sessions,views} \
|
COPY --chown=www-data:www-data .env.example .env
|
||||||
&& mkdir -p bootstrap/cache \
|
|
||||||
&& mkdir -p database
|
|
||||||
|
|
||||||
COPY --chown=www-data:www-data ./.env.example ./.env
|
# Install the composer dependencies
|
||||||
|
|
||||||
# Install application dependencies
|
|
||||||
COPY --chown=www-data:www-data composer.json composer.lock ./
|
|
||||||
RUN composer install --no-interaction --prefer-dist --optimize-autoloader
|
RUN composer install --no-interaction --prefer-dist --optimize-autoloader
|
||||||
|
|
||||||
COPY --chown=www-data:www-data package.json package-lock.json ./
|
########################
|
||||||
RUN npm ci
|
# Assets Image
|
||||||
|
########################
|
||||||
|
FROM node:22-alpine AS assets
|
||||||
|
|
||||||
# Copy application files
|
# Copy the application
|
||||||
COPY --chown=www-data:www-data . .
|
COPY --from=base /var/www/html /app
|
||||||
RUN npm run build
|
|
||||||
|
|
||||||
ENV AUTORUN_ENABLED=true
|
# Set the working directory
|
||||||
# Expose port 80
|
WORKDIR /app
|
||||||
EXPOSE 8080
|
|
||||||
|
# Install the node dependencies and build the assets
|
||||||
|
RUN npm ci --no-audit \
|
||||||
|
&& npm run build
|
||||||
|
|
||||||
|
########################
|
||||||
|
# Production Image
|
||||||
|
########################
|
||||||
|
FROM base AS production
|
||||||
|
|
||||||
|
# Copy the assets from the assets image
|
||||||
|
COPY --chown=www-data:www-data --from=assets /app/public/build /var/www/html/public/build
|
||||||
|
|
||||||
|
# Drop back to the www-data user
|
||||||
|
USER www-data
|
||||||
|
|
||||||
|
# Create the sqlite database
|
||||||
|
RUN php -r "file_exists('database/database.sqlite') || touch('database/database.sqlite');"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue