-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
55 lines (51 loc) · 2.3 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# syntax=docker/dockerfile:1.7-labs
FROM php:8.3-alpine as base
WORKDIR /app
ENV COMPOSER_MEMORY_LIMIT=-1
######################################################
# Step 1 | Install Dependencies
######################################################
# 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 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 \
&& 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
######################################################
# Local Stage
######################################################
FROM base as local
######################################################
# Build Ziggy Package - Vite needs ziggy package available
######################################################
FROM base as vite-vendor-build
WORKDIR /app
RUN COMPOSER_ALLOW_SUPERUSER=1 | composer require tightenco/ziggy:^2 --ignore-platform-reqs
######################################################
# NodeJS Stage
######################################################
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
RUN npm install
COPY ./resources /app/resources
COPY --from=vite-vendor-build /app/vendor/tightenco/ziggy /app/vendor/tightenco/ziggy
RUN npm run build
######################################################
# Production Stage
######################################################
FROM base as production
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"