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 install-php-extensions \
|
||||||
RUN apt update -y
|
pdo_mysql \
|
||||||
RUN apt upgrade -y
|
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
|
COPY . /app
|
||||||
|
|
||||||
# Run composer
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN composer install
|
|
||||||
|
|
||||||
# Fix permissions
|
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||||
RUN chgrp -R 33 /app
|
|
||||||
RUN chown -hR 33:33 /app
|
|
||||||
|
|
||||||
# Remove .env if copied
|
RUN composer install --no-dev --optimize-autoloader
|
||||||
RUN rm /app/.env
|
|
||||||
|
|
||||||
# Copy the entrypoint script
|
ENV SERVER_NAME=:80
|
||||||
COPY ./docker/entrypoint.sh /entrypoint.sh
|
|
||||||
# Make it executable
|
|
||||||
RUN chmod +x /entrypoint.sh
|
|
||||||
|
|
||||||
STOPSIGNAL SIGTERM
|
|
||||||
|
|
||||||
# Run php-fpm
|
|
||||||
CMD ["/entrypoint.sh"]
|
|
||||||
6
docker/.gitignore
vendored
6
docker/.gitignore
vendored
@@ -1,7 +1 @@
|
|||||||
.Caddyfile
|
|
||||||
|
|
||||||
caddy-data/
|
|
||||||
|
|
||||||
caddy-config/
|
|
||||||
|
|
||||||
mariadb_data/
|
mariadb_data/
|
||||||
@@ -5,15 +5,13 @@ services:
|
|||||||
context: ../frontend
|
context: ../frontend
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
NUXT_PUBLIC_SANCTUM_BASE_URL: https://backend.example.com
|
||||||
|
NUXT_PUBLIC_SANCTUM_ORIGINAL: https://example.com
|
||||||
ports:
|
ports:
|
||||||
- 80:80
|
- 80:80
|
||||||
environment:
|
|
||||||
NUXT_PUBLIC_SANCTUM_BASE_URL: http://localhost:8080
|
|
||||||
NUXT_PUBLIC_SANCTUM_ORIGIN: http://localhost
|
|
||||||
PORT: 80
|
|
||||||
depends_on:
|
depends_on:
|
||||||
isop-backend:
|
- isop-backend
|
||||||
condition: service_healthy
|
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost"]
|
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost"]
|
||||||
start_period: 10s
|
start_period: 10s
|
||||||
@@ -21,68 +19,51 @@ services:
|
|||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
|
|
||||||
# Caddy webserver
|
|
||||||
isop-backend:
|
isop-backend:
|
||||||
container_name: 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:
|
build:
|
||||||
context: ../backend
|
context: ../backend
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
env_file:
|
|
||||||
- ../backend/.env
|
|
||||||
environment:
|
environment:
|
||||||
APP_URL: http://localhost:8080
|
APP_NAME: ISOP
|
||||||
FRONTEND_URL: http://localhost
|
APP_ENV: production
|
||||||
SESSION_DOMAIN: localhost
|
APP_KEY: SOME-KEY
|
||||||
SESSION_SECURE_COOKIE: false
|
APP_DEBUG: false
|
||||||
SANCTUM_STATEFUL_DOMAINS: localhost,localhost:80,localhost:8080
|
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_CONNECTION: mariadb
|
||||||
DB_HOST: isop-database
|
DB_HOST: isop-database
|
||||||
DB_PORT: 3306
|
DB_PORT: 3306
|
||||||
DB_DATABASE: isop
|
DB_DATABASE: isop
|
||||||
DB_USERNAME: root
|
DB_USERNAME: root
|
||||||
DB_PASSWORD: admin
|
DB_PASSWORD: admin
|
||||||
|
ports:
|
||||||
|
- 8111:80
|
||||||
depends_on:
|
depends_on:
|
||||||
isop-database:
|
isop-database:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "pgrep", "-x", "php-fpm"]
|
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost/api"]
|
||||||
start_period: 10s
|
start_period: 10s
|
||||||
interval: 1m
|
interval: 1m
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
|
|
||||||
# MariaDB database
|
|
||||||
# No ports are open, only Shopware itself has access
|
|
||||||
isop-database:
|
isop-database:
|
||||||
container_name: isop-database
|
container_name: isop-database
|
||||||
image: mariadb:11.8.2-noble
|
image: mariadb:11.8.2-noble
|
||||||
@@ -91,11 +72,9 @@ services:
|
|||||||
# Allow memory binding
|
# Allow memory binding
|
||||||
- SYS_NICE
|
- SYS_NICE
|
||||||
environment:
|
environment:
|
||||||
# Change these if needed
|
|
||||||
MARIADB_DATABASE: "isop"
|
MARIADB_DATABASE: "isop"
|
||||||
MARIADB_ROOT_PASSWORD: "admin"
|
MARIADB_ROOT_PASSWORD: "admin"
|
||||||
volumes:
|
volumes:
|
||||||
# Database data
|
|
||||||
- ./mariadb_data:/var/lib/mysql
|
- ./mariadb_data:/var/lib/mysql
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: [ "CMD", "healthcheck.sh", "--su-mysql", "--connect", "--innodb_initialized" ]
|
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
|
FROM node:22-alpine AS build
|
||||||
RUN apt update -y
|
|
||||||
RUN apt upgrade -y
|
|
||||||
|
|
||||||
# Copy the frontend project
|
|
||||||
COPY . /app
|
|
||||||
|
|
||||||
# Run NPM
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN npm install
|
|
||||||
|
|
||||||
# Build
|
RUN corepack enable
|
||||||
RUN npm run build
|
|
||||||
|
|
||||||
STOPSIGNAL SIGTERM
|
# Copy package.json and your lockfile
|
||||||
|
COPY package.json ./
|
||||||
|
|
||||||
# Run frontend web server
|
# Install dependencies
|
||||||
CMD ["node", ".output/server/index.mjs"]
|
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