Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 56 additions & 36 deletions Dockerfile.all-in-one
Original file line number Diff line number Diff line change
@@ -1,57 +1,77 @@
# --- Stage 1: Build the Frontend ---
FROM node:22-alpine AS node-frontend

WORKDIR /app/frontend

RUN apk add --no-cache yarn

# Increase network timeout for slow ARM emulation builds
RUN yarn config set network-timeout 600000

COPY ./frontend/package.json ./frontend/yarn.lock ./
# Build-time args for Vite (baked into the JS bundle — not runtime secrets)
# VITE_STRIPE_PUBLISHABLE_KEY is the client-side Stripe key; it is intentionally public
ARG VITE_FRONTEND_URL="http://localhost:5678"
ARG VITE_API_URL_CLIENT="http://localhost:8080/api"
ARG VITE_API_URL_SERVER="http://localhost:8000/api"
ARG VITE_STRIPE_PUBLISHABLE_KEY=""
ARG VITE_APP_NAME="Hi.Events"

# hadolint ignore=DL3044
ENV VITE_FRONTEND_URL=$VITE_FRONTEND_URL \
VITE_API_URL_CLIENT=$VITE_API_URL_CLIENT \
VITE_API_URL_SERVER=$VITE_API_URL_SERVER \
VITE_STRIPE_PUBLISHABLE_KEY=$VITE_STRIPE_PUBLISHABLE_KEY \
VITE_APP_NAME=$VITE_APP_NAME

COPY ./frontend/package.json ./frontend/yarn.lock ./
COPY ./frontend .
COPY ./VERSION /app/VERSION

RUN yarn install --network-timeout 600000 --frozen-lockfile && yarn build

# Use stable multi-arch serversideup/php image
FROM serversideup/php:8.3-fpm-alpine

ENV PHP_OPCACHE_ENABLE=1
# --- Stage 2: Build the Backend with FrankenPHP ---
FROM dunglas/frankenphp:php8.3-alpine

# Switch to root for installing extensions and packages
USER root
ENV SERVER_NAME=":8000"
ENV LARAVEL_OCTANE=1
ENV APP_ENV="production"

RUN install-php-extensions intl

RUN apk add --no-cache nodejs yarn nginx supervisor dos2unix
WORKDIR /app

COPY --from=node-frontend /app/frontend /app/frontend
# Install PHP extensions
RUN set -ex \
&& apk add --no-cache php83-pdo_pgsql php83-pgsql php83-redis php83-pcntl php83-bcmath php83-zip php83-intl php83-opcache curl supervisor \
&& install-php-extensions gd redis pdo_pgsql sodium curl intl mbstring xml zip bcmath pcntl imagick opcache

# Copy Backend
COPY ./backend /app/backend
COPY ./VERSION /app/backend/VERSION
RUN mkdir -p /app/backend/bootstrap/cache \
&& mkdir -p /app/backend/storage \
&& chown -R www-data:www-data /app/backend \
&& find /app/backend -type d -exec chmod 755 {} \; \
&& find /app/backend -type f -exec chmod 644 {} \; \
&& chmod -R 755 /app/backend/storage /app/backend/bootstrap/cache \
&& composer install --working-dir=/app/backend \
--ignore-platform-reqs \
--no-interaction \
--no-dev \
--optimize-autoloader \
--prefer-dist \
&& chmod -R 755 /app/backend/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer

COPY ./docker/all-in-one/nginx/nginx.conf /etc/nginx/nginx.conf
COPY ./docker/all-in-one/supervisor/supervisord.conf /etc/supervisord.conf

COPY ./docker/all-in-one/scripts/startup.sh /startup.sh
RUN dos2unix /startup.sh && chmod +x /startup.sh

EXPOSE 80

WORKDIR /app
# Setup Directories and Permissions
RUN chmod -R 775 /app/backend/storage \
&& mkdir -p /app/backend/bootstrap/cache \
&& chmod -R 775 /app/backend/bootstrap/cache \
&& chown -R root:root /app/backend/storage /app/backend/bootstrap/cache

# Install Composer Dependencies
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
RUN cd /app/backend \
&& composer install --no-interaction --no-dev --optimize-autoloader --prefer-dist

RUN mkdir -p /app/backend/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer \
&& chmod -R 775 /app/backend/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer \
&& chown -R root:root /app/backend/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer

# --- Stage 3: Combine Frontend, Supervisor, and Caddyfile ---
COPY --from=node-frontend /app/frontend/dist /app/frontend/dist

# Publish the FrankenPHP worker file (APP_KEY is only needed to bootstrap the app during install)
RUN cd /app/backend && APP_KEY="base64:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" php artisan octane:install --server=frankenphp --no-interaction

# Setup Supervisor and Startup Scripts
COPY ./docker/all-in-one/supervisord.conf /etc/supervisord.conf
COPY ./docker/all-in-one/Caddyfile /etc/caddy/Caddyfile
COPY ./docker/all-in-one/startup.sh /startup.sh

RUN sed -i 's/\r$//' /startup.sh && chmod +x /startup.sh

EXPOSE 8000

CMD ["/startup.sh"]
45 changes: 19 additions & 26 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
FROM serversideup/php:8.4-fpm-nginx-alpine
FROM dunglas/frankenphp:php8.3-alpine

ENV PHP_OPCACHE_ENABLE=1
ENV SERVER_NAME=":8000"
ENV LARAVEL_OCTANE=1

USER root
WORKDIR /app

# Set `www-data` as the user to start FPM
RUN echo "" >> /usr/local/etc/php-fpm.d/docker-php-serversideup-pool.conf && \
echo "user = www-data" >> /usr/local/etc/php-fpm.d/docker-php-serversideup-pool.conf && \
echo "group = www-data" >> /usr/local/etc/php-fpm.d/docker-php-serversideup-pool.conf
# Install PHP extensions via FrankenPHP's extension installer (not apk php83-* packages,
# which target the system PHP rather than FrankenPHP's embedded PHP).
RUN apk add --no-cache curl \
&& install-php-extensions gd redis pdo_pgsql sodium intl mbstring xml zip bcmath pcntl imagick opcache

RUN install-php-extensions intl imagick
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer

COPY --chown=www-data:www-data . .
COPY . /app

RUN chmod -R 755 storage \
&& mkdir -p bootstrap/cache \
&& chmod -R 775 bootstrap/cache \
&& mkdir -p /var/lib/nginx/tmp \
&& chown -R www-data:www-data /var/lib/nginx \
&& chmod -R 755 /var/lib/nginx
RUN mkdir -p storage bootstrap/cache \
&& chmod -R 775 storage bootstrap/cache \
&& chown -R root:root storage bootstrap/cache

RUN composer install \
--ignore-platform-reqs \
--no-interaction \
--no-dev \
--optimize-autoloader \
--prefer-dist
RUN composer install --no-interaction --no-dev --optimize-autoloader --prefer-dist \
&& mkdir -p /app/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer \
&& chmod -R 775 /app/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer \
&& chown -R root:root /app/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer

RUN mkdir -p /var/www/html/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer \
&& chmod -R 775 /var/www/html/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer \
&& chown -R www-data:www-data /var/www/html/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer

EXPOSE 8080
EXPOSE 8000
CMD ["php", "artisan", "octane:start", "--server=frankenphp", "--host=0.0.0.0", "--port=8000"]
25 changes: 10 additions & 15 deletions backend/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
FROM serversideup/php:8.4-fpm-nginx-alpine
FROM dunglas/frankenphp:php8.3-alpine

ENV PHP_OPCACHE_ENABLE=1
ENV NGINX_WEBROOT=/var/www/html/public
ENV SERVER_NAME=":8000"
ENV LARAVEL_OCTANE=1

WORKDIR /var/www/html
WORKDIR /app

RUN mkdir -p /var/www/html/storage /var/www/html/bootstrap/cache \
&& chown -R www-data:www-data /var/www/html
# Install PHP extensions via FrankenPHP's extension installer (not apk php83-* packages,
# which target the system PHP rather than FrankenPHP's embedded PHP).
RUN apk add --no-cache curl \
&& install-php-extensions gd redis pdo_pgsql sodium intl mbstring xml zip bcmath pcntl imagick opcache

COPY --chown=www-data:www-data . /var/www/html

# Switch to root user to install PHP extensions
USER root
RUN install-php-extensions intl imagick
USER www-data

RUN chmod -R 755 /var/www/html/storage \
&& chmod -R 775 /var/www/html/bootstrap/cache
EXPOSE 8000
CMD ["php", "artisan", "octane:start", "--server=frankenphp", "--host=0.0.0.0", "--port=8000", "--watch"]
1 change: 1 addition & 0 deletions backend/app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function boot(): void

$this->routes(function () {
Route::middleware('api')
->prefix('api')
->group(base_path('routes/api.php'));

Route::middleware('web')
Expand Down
3 changes: 2 additions & 1 deletion backend/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "hi.events - Ticket selling and event management.",
"keywords": ["ticketing", "events"],
"license": "AGPL-3.0",
"version": "1.8.0-beta",
"version": "v1.7.1-beta",
"require": {
"php": "^8.2",
"ext-intl": "*",
Expand All @@ -16,6 +16,7 @@
"guzzlehttp/guzzle": "^7.2",
"lab404/laravel-impersonate": "^1.7",
"laravel/framework": "^12.0",
"laravel/octane": "^2.15",
"laravel/sanctum": "^4.0",
"laravel/tinker": "^2.8",
"laravel/vapor-core": "^2.37",
Expand Down
Loading
Loading