You've already forked isop-mirror
Merge branch 'feature/docker-frankenphp' into feature/docker
This commit is contained in:
9
backend/.dockerignore
Normal file
9
backend/.dockerignore
Normal file
@@ -0,0 +1,9 @@
|
||||
.git
|
||||
.env
|
||||
storage/logs/*
|
||||
storage/framework/cache/*
|
||||
storage/framework/sessions/*
|
||||
storage/framework/views/*
|
||||
bootstrap/cache/*
|
||||
.phpunit.result.cache
|
||||
vendor/*
|
||||
@@ -1,73 +1,18 @@
|
||||
FROM php:8.3-fpm-bullseye
|
||||
FROM dunglas/frankenphp:1.10-php8.4-bookworm
|
||||
|
||||
# Update the system
|
||||
RUN apt update -y
|
||||
RUN apt upgrade -y
|
||||
RUN install-php-extensions \
|
||||
pdo_mysql \
|
||||
gd \
|
||||
intl \
|
||||
zip \
|
||||
opcache
|
||||
|
||||
RUN apt install -y build-essential
|
||||
RUN apt install -y libonig-dev zlib1g-dev libpng-dev libicu-dev libzip-dev libjpeg-dev libfreetype6-dev libwebp-dev libavif-dev libxpm-dev
|
||||
RUN apt install -y nano procps git
|
||||
|
||||
# Install extensions
|
||||
RUN docker-php-ext-install -j$(nproc) mbstring
|
||||
RUN docker-php-ext-install -j$(nproc) intl
|
||||
RUN docker-php-ext-install -j$(nproc) pdo_mysql
|
||||
RUN docker-php-ext-install -j$(nproc) zip
|
||||
RUN pecl install zstd
|
||||
RUN docker-php-ext-enable zstd
|
||||
|
||||
# Install GD module
|
||||
RUN docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg=/usr/local/lib --with-webp --with-xpm --with-avif
|
||||
RUN docker-php-ext-install -j$(nproc) gd
|
||||
|
||||
# Install EXIF module
|
||||
RUN docker-php-ext-configure exif --enable-exif
|
||||
RUN docker-php-ext-install -j$(nproc) exif
|
||||
|
||||
# Install OPCache
|
||||
RUN docker-php-ext-configure opcache --enable-opcache
|
||||
RUN docker-php-ext-install -j$(nproc) opcache
|
||||
|
||||
# Install Composer
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
|
||||
|
||||
# Add extra configuration options
|
||||
RUN echo 'memory_limit = 1024M' >> /usr/local/etc/php/conf.d/docker-php-memlimit.ini;
|
||||
RUN echo 'opcache.memory_consumption = 256' >> /usr/local/etc/php/conf.d/docker-php-opcache.ini;
|
||||
RUN echo 'max_execution_time = 180' >> /usr/local/etc/php/conf.d/docker-php-exec-time.ini;
|
||||
RUN echo 'pm.max_children = 32' >> /usr/local/etc/php-fpm.d/zz-docker.conf;
|
||||
RUN echo 'pm.max_requests = 32' >> /usr/local/etc/php-fpm.d/zz-docker.conf;
|
||||
RUN echo 'listen.backlog = 256' >> /usr/local/etc/php-fpm.d/zz-docker.conf;
|
||||
|
||||
# OPCache tuning
|
||||
RUN echo 'opcache.enable_file_override=1' >> /usr/local/etc/php/conf.d/docker-php-opcache.ini;
|
||||
RUN echo 'opcache.interned_strings_buffer=20' >> /usr/local/etc/php/conf.d/docker-php-opcache.ini;
|
||||
|
||||
# Performance optimizations
|
||||
RUN echo 'zend.assertions=-1' >> /usr/local/etc/php/conf.d/docker-php-sw-opts.ini;
|
||||
RUN echo 'zend.detect_unicode=0' >> /usr/local/etc/php/conf.d/docker-php-sw-opts.ini;
|
||||
RUN echo 'realpath_cache_ttl=3600' >> /usr/local/etc/php/conf.d/docker-php-sw-opts.ini;
|
||||
|
||||
# Copy the backend project
|
||||
COPY . /app
|
||||
|
||||
# Run composer
|
||||
WORKDIR /app
|
||||
RUN composer install
|
||||
|
||||
# Fix permissions
|
||||
RUN chgrp -R 33 /app
|
||||
RUN chown -hR 33:33 /app
|
||||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||
|
||||
# Remove .env if copied
|
||||
RUN rm /app/.env
|
||||
RUN composer install --no-dev --optimize-autoloader
|
||||
|
||||
# Copy the entrypoint script
|
||||
COPY ./docker/entrypoint.sh /entrypoint.sh
|
||||
# Make it executable
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
STOPSIGNAL SIGTERM
|
||||
|
||||
# Run php-fpm
|
||||
CMD ["/entrypoint.sh"]
|
||||
ENV SERVER_NAME=:80
|
||||
6
docker/.gitignore
vendored
6
docker/.gitignore
vendored
@@ -1,7 +1 @@
|
||||
.Caddyfile
|
||||
|
||||
caddy-data/
|
||||
|
||||
caddy-config/
|
||||
|
||||
mariadb_data/
|
||||
@@ -5,15 +5,13 @@ services:
|
||||
context: ../frontend
|
||||
dockerfile: Dockerfile
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
NUXT_PUBLIC_SANCTUM_BASE_URL: https://backend.example.com
|
||||
NUXT_PUBLIC_SANCTUM_ORIGINAL: https://example.com
|
||||
ports:
|
||||
- 80:80
|
||||
environment:
|
||||
NUXT_PUBLIC_SANCTUM_BASE_URL: http://localhost:8080
|
||||
NUXT_PUBLIC_SANCTUM_ORIGIN: http://localhost
|
||||
PORT: 80
|
||||
depends_on:
|
||||
isop-backend:
|
||||
condition: service_healthy
|
||||
- isop-backend
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost"]
|
||||
start_period: 10s
|
||||
@@ -21,68 +19,51 @@ services:
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
# Caddy webserver
|
||||
isop-backend:
|
||||
container_name: isop-backend
|
||||
image: caddy:2.10.0-alpine
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- 8080:80 # Needed for HTTP->HTTPS redirection
|
||||
- 443:443
|
||||
- 443:443/udp
|
||||
volumes:
|
||||
# Caddy routes files (read-only)
|
||||
- ./Caddyfile:/etc/caddy/Caddyfile:ro
|
||||
|
||||
# Caddy certificates and other temporary data
|
||||
- ./caddy-data:/data
|
||||
|
||||
# Caddy configuration
|
||||
- ./caddy-config:/config
|
||||
depends_on:
|
||||
isop-php-fpm:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:2019/metrics"]
|
||||
start_period: 10s
|
||||
interval: 1m
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
# Custom PHP container
|
||||
isop-php-fpm:
|
||||
container_name: isop-php-fpm
|
||||
user: 'www-data:www-data'
|
||||
build:
|
||||
context: ../backend
|
||||
dockerfile: Dockerfile
|
||||
restart: unless-stopped
|
||||
env_file:
|
||||
- ../backend/.env
|
||||
environment:
|
||||
APP_URL: http://localhost:8080
|
||||
FRONTEND_URL: http://localhost
|
||||
SESSION_DOMAIN: localhost
|
||||
SESSION_SECURE_COOKIE: false
|
||||
SANCTUM_STATEFUL_DOMAINS: localhost,localhost:80,localhost:8080
|
||||
APP_NAME: ISOP
|
||||
APP_ENV: production
|
||||
APP_KEY: SOME-KEY
|
||||
APP_DEBUG: false
|
||||
APP_URL: https://example.com
|
||||
FRONTEND_URL: https://example.com
|
||||
SANCTUM_STATEFUL_DOMAINS: backend.example.com,example.com
|
||||
SESSION_DOMAIN: .example.com # Note the first dot
|
||||
|
||||
APP_LOCALE: sk
|
||||
APP_FALLBACK_LOCALE: en_US
|
||||
|
||||
MAIL_MAILER: smtp
|
||||
MAIL_HOST: smtp.example.com
|
||||
MAIL_PORT: 2525
|
||||
MAIL_USERNAME: username
|
||||
MAIL_PASSWORD: password
|
||||
MAIL_FROM_ADDRESS: "noreply@example.com"
|
||||
MAIL_FROM_NAME: "ISOP"
|
||||
|
||||
DB_CONNECTION: mariadb
|
||||
DB_HOST: isop-database
|
||||
DB_PORT: 3306
|
||||
DB_DATABASE: isop
|
||||
DB_USERNAME: root
|
||||
DB_PASSWORD: admin
|
||||
ports:
|
||||
- 8111:80
|
||||
depends_on:
|
||||
isop-database:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "pgrep", "-x", "php-fpm"]
|
||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost/api"]
|
||||
start_period: 10s
|
||||
interval: 1m
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
# MariaDB database
|
||||
# No ports are open, only Shopware itself has access
|
||||
|
||||
isop-database:
|
||||
container_name: isop-database
|
||||
image: mariadb:11.8.2-noble
|
||||
@@ -91,11 +72,9 @@ services:
|
||||
# Allow memory binding
|
||||
- SYS_NICE
|
||||
environment:
|
||||
# Change these if needed
|
||||
MARIADB_DATABASE: "isop"
|
||||
MARIADB_ROOT_PASSWORD: "admin"
|
||||
volumes:
|
||||
# Database data
|
||||
- ./mariadb_data:/var/lib/mysql
|
||||
healthcheck:
|
||||
test: [ "CMD", "healthcheck.sh", "--su-mysql", "--connect", "--innodb_initialized" ]
|
||||
|
||||
8
frontend/.dockerignore
Normal file
8
frontend/.dockerignore
Normal file
@@ -0,0 +1,8 @@
|
||||
.nuxt/
|
||||
.output/
|
||||
.env*
|
||||
node_modules/
|
||||
cypress/
|
||||
cypress.config.ts
|
||||
package-lock.json
|
||||
*.md
|
||||
@@ -1,20 +1,37 @@
|
||||
FROM node:lts
|
||||
# Build Stage 1
|
||||
|
||||
# Update the system
|
||||
RUN apt update -y
|
||||
RUN apt upgrade -y
|
||||
|
||||
# Copy the frontend project
|
||||
COPY . /app
|
||||
|
||||
# Run NPM
|
||||
FROM node:22-alpine AS build
|
||||
WORKDIR /app
|
||||
RUN npm install
|
||||
|
||||
# Build
|
||||
RUN npm run build
|
||||
RUN corepack enable
|
||||
|
||||
STOPSIGNAL SIGTERM
|
||||
# Copy package.json and your lockfile
|
||||
COPY package.json ./
|
||||
|
||||
# Run frontend web server
|
||||
CMD ["node", ".output/server/index.mjs"]
|
||||
# Install dependencies
|
||||
RUN pnpm i
|
||||
|
||||
# Copy the entire project
|
||||
COPY . ./
|
||||
|
||||
# Prepare Nuxt (generates .nuxt with type definitions and auto-imports)
|
||||
RUN pnpm run postinstall
|
||||
|
||||
# Build the project
|
||||
RUN pnpm run build
|
||||
|
||||
# Build Stage 2
|
||||
|
||||
FROM node:22-alpine
|
||||
WORKDIR /app
|
||||
|
||||
# Only `.output` folder is needed from the build stage
|
||||
COPY --from=build /app/.output/ ./
|
||||
|
||||
# Change the port and host
|
||||
ENV PORT=80
|
||||
ENV HOST=0.0.0.0
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
CMD ["node", "/app/server/index.mjs"]
|
||||
|
||||
Reference in New Issue
Block a user