Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiritin committed Sep 15, 2024
1 parent 1cbf350 commit df831b0
Showing 1 changed file with 18 additions and 32 deletions.
50 changes: 18 additions & 32 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,53 +1,41 @@
FROM php:8.2-bullseye as base
# syntax=docker/dockerfile:1.7-labs
FROM php:8.3-alpine as base
WORKDIR /app

ENV COMPOSER_MEMORY_LIMIT=-1
######################################################
# Step 1 | Install Dependencies
######################################################
COPY .github/docker/install-php-extensions /usr/local/bin/
# Download install-php-extension
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/

RUN apt-get update \
&& chmod +x /usr/local/bin/install-php-extensions \
&& apt-get install -y curl git unzip openssl tar ca-certificates dnsutils \
RUN apk update \
&& apk add --no-cache curl git unzip openssl tar ca-certificates bind-tools \
&& install-php-extensions gd bcmath pdo_mysql zip intl opcache pcntl redis swoole @composer \
&& apt-get clean -y
&& rm -rf /var/cache/apk/*

RUN chown -R www-data:www-data /app
USER www-data

######################################################
# Copy Configuration
######################################################
COPY .github/docker/php/opcache.ini $PHP_INI_DIR/conf.d/opcache.ini
COPY .github/docker/php/php.ini $PHP_INI_DIR/conf.d/php.ini

######################################################
# Step 6 | Configure Credentials & Hosts for external Git (optional)
######################################################
COPY composer.json composer.lock /app/
RUN composer install --no-dev --no-scripts --no-autoloader
######################################################
# Local Stage
######################################################
FROM base as local
RUN addgroup -gid 1024 app \
&& adduser -uid 1024 --disabled-password --ingroup app app \
&& adduser www-data app \
&& curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
&& apt-get update \
&& apt-get install -y nodejs \
&& apt-get clean -y \
&& install-php-extensions xdebug
USER app
# yarn install as command
CMD sh -c "composer install && php artisan octane:start --watch --host=0.0.0.0 --port=80"
######################################################
# Build Ziggy Package - Vite needs ziggy package available
######################################################
FROM base as vite-vendor-build
WORKDIR /app
RUN COMPOSER_ALLOW_SUPERUSER=1 | rm composer.lock composer.json && composer require tightenco/ziggy --ignore-platform-reqs
RUN COMPOSER_ALLOW_SUPERUSER=1 | composer require tightenco/ziggy:^2 --ignore-platform-reqs
######################################################
# NodeJS Stage
######################################################
FROM node:16-buster as vite
FROM node:20-alpine as vite
WORKDIR /app
COPY package.json package-lock.json tailwind.config.js vite.config.js postcss.config.js ./
COPY .env.build ./.env
Expand All @@ -59,11 +47,9 @@ RUN npm run build
# Production Stage
######################################################
FROM base as production
COPY --from=vite /app/public/build ./public/build
COPY . /app/
RUN composer install --no-dev --optimize-autoloader \
&& chmod 777 -R bootstrap storage \
&& rm -rf .env bootstrap/cache/*.php auth.json \
&& chown -R www-data:www-data /app \
&& rm -rf ~/.composer
COPY --chown=www-data:www-data composer.json composer.lock /app/
RUN composer install --no-dev --optimize-autoloader --no-cache --no-scripts
COPY --chown=www-data:www-data . /app/
RUN composer dump-autoload --optimize
COPY --from=vite --chown=www-data:www-data /app/public/build ./public/build
CMD sh -c "php artisan octane:start --host=0.0.0.0 --port=80"

0 comments on commit df831b0

Please sign in to comment.