diff --git a/.docker/base.Dockerfile b/.docker/base.Dockerfile index 07c024b4..69d50a9a 100644 --- a/.docker/base.Dockerfile +++ b/.docker/base.Dockerfile @@ -1,14 +1,12 @@ -FROM php:8.3.36-fpm AS php +FROM dunglas/frankenphp:1.12.7-php8.3-bookworm AS php WORKDIR /app -RUN ls /app RUN apt-get update -RUN apt-get install -y rsync libcurl3-dev apt-utils zlib1g-dev libpng-dev libicu-dev libonig-dev unzip poppler-utils libpng-dev libjpeg-dev default-mysql-client libzip-dev imagemagick libmagickwand-dev +RUN apt-get install -y rsync curl apt-utils unzip poppler-utils default-mysql-client imagemagick RUN apt-get install -y --no-install-recommends texlive-base texlive-latex-base texlive-pictures texlive-latex-extra texlive-lang-german texlive-plain-generic texlive-fonts-recommended texlive-fonts-extra texlive-extra-utils -RUN docker-php-ext-install pdo_mysql curl exif intl mbstring pcntl zip -RUN pecl install redis && docker-php-ext-enable redis -RUN pecl install imagick && docker-php-ext-enable imagick -RUN docker-php-ext-configure gd --with-jpeg -RUN docker-php-ext-install gd +RUN install-php-extensions pdo_mysql curl exif intl mbstring pcntl zip redis imagick gd RUN usermod -s /bin/bash www-data RUN echo 'memory_limit = 2G' >> /usr/local/etc/php/conf.d/99-custom-php-memlimit.ini +# Allow FrankenPHP to bind to port 80 and write its state when running as www-data +RUN setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/frankenphp \ + && chown -R www-data:www-data /data/caddy /config/caddy diff --git a/.docker/frankenphp/Caddyfile b/.docker/frankenphp/Caddyfile new file mode 100644 index 00000000..6266ba9b --- /dev/null +++ b/.docker/frankenphp/Caddyfile @@ -0,0 +1,34 @@ +{ + auto_https off + admin off + frankenphp +} + +:80 { + root * /app/public + encode zstd gzip + header -Server + + request_body { + max_size 10MB + } + + @hidden { + path */.* + not path /.well-known/* + } + + route { + redir /.well-known/carddav /dav 301 + redir /.well-known/caldav /dav 301 + respond @hidden 403 + + reverse_proxy /app/adremakey* socketi:6001 + reverse_proxy /indexes/members/search meilisearch:7700 + + header Access-Control-Allow-Credentials "true" + header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" + header Access-Control-Allow-Headers "Accept,Authorization,Client-Id,Client-Secret,Cache-Control,Content-Type,Pragma,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With,App-Platform,App-Version,Idempotency-Key" + php_server + } +} diff --git a/.docker/nginx.Dockerfile b/.docker/nginx.Dockerfile deleted file mode 100644 index cebd7d61..00000000 --- a/.docker/nginx.Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -FROM composer:2.7.9 AS composer -WORKDIR /app -COPY . /app -RUN composer install --ignore-platform-reqs --no-dev -RUN php artisan telescope:publish - -FROM node:20.15.0-slim AS node -WORKDIR /app -COPY . /app -RUN npm ci && npm run prod && npm run img && rm -R node_modules - -FROM nginx:1.21.6-alpine AS nginx -WORKDIR /app -COPY --from=node /app /app -COPY --from=composer /app/public/vendor /app/public/vendor -COPY ./.docker/nginx/nginx.conf /etc/nginx/nginx.conf -EXPOSE 80 - -VOLUME ["/app/public/storage"] - -CMD ["nginx", "-g", "daemon off;"] diff --git a/.docker/nginx/nginx.conf b/.docker/nginx/nginx.conf deleted file mode 100644 index 6a4d9b30..00000000 --- a/.docker/nginx/nginx.conf +++ /dev/null @@ -1,77 +0,0 @@ -events { - worker_connections 768; - # multi_accept on; -} - -http { - include mime.types; - include fastcgi.conf; - default_type application/octet-stream; - sendfile on; - tcp_nopush on; - server_tokens off; - client_max_body_size 10M; - gzip on; - gzip_disable "msie6"; - gzip_vary on; - gzip_proxied any; - gzip_comp_level 6; - gzip_buffers 16 8k; - gzip_http_version 1.1; - gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript; - - server { - listen 80; - root /app/public; - charset utf-8; - index index.php; - location /app/adremakey { - proxy_pass http://socketi:6001; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "Upgrade"; - proxy_set_header Host $host; - proxy_cache_bypass $http_upgrade; - proxy_redirect off; - proxy_read_timeout 60; - proxy_connect_timeout 60; - } - location /indexes/members/search { - proxy_pass http://meilisearch:7700/indexes/members/search; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "Upgrade"; - proxy_set_header Host $host; - proxy_cache_bypass $http_upgrade; - proxy_redirect off; - proxy_read_timeout 60; - proxy_connect_timeout 60; - } - location / { - try_files $uri $uri/ /index.php?$query_string; - } - location = /favicon.ico { access_log off; log_not_found off; } - location = /robots.txt { access_log off; log_not_found off; } - error_page 404 /index.php; - location = /.well-known/carddav { - return 301 $scheme://$host/dav; - } - location = /.well-known/caldav { - return 301 $scheme://$host/dav; - } - location ~ /\.ht { - deny all; - } - location ~ /\.(?!well-known).* { - deny all; - } - location ~ \.php$ { - add_header 'Access-Control-Allow-Credentials' 'true' always; - add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always; - add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Client-Id,Client-Secret,Cache-Control,Content-Type,Pragma,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With,App-Platform,App-Version,Idempotency-Key' always; - fastcgi_pass php:9000; - fastcgi_index index.php; - } - } -} - diff --git a/.docker/php.Dockerfile b/.docker/php.Dockerfile index 7ed6053e..e8711f32 100644 --- a/.docker/php.Dockerfile +++ b/.docker/php.Dockerfile @@ -16,12 +16,14 @@ COPY --chown=www-data:www-data --from=composer /app/vendor /app/vendor USER www-data RUN php artisan telescope:publish RUN php artisan horizon:publish +RUN php artisan storage:link USER root COPY ./.docker/php /bin +COPY ./.docker/frankenphp/Caddyfile /etc/caddy/Caddyfile VOLUME ["/app/packages/laravel-nami/.cookies", "/app/storage/app", "/app/resources/views/tex/invoice"] -EXPOSE 9000 +EXPOSE 80 -CMD /bin/php-entrypoint +CMD ["/bin/entrypoint", "app"] diff --git a/.docker/php/entrypoint b/.docker/php/entrypoint index 46ecb3c0..66d64dfb 100755 --- a/.docker/php/entrypoint +++ b/.docker/php/entrypoint @@ -31,7 +31,7 @@ if [ $1 == "app" ]; then php -r '$connection = new PDO("mysql:host='$DB_HOST';dbname='$DB_DATABASE'", "'$DB_USERNAME'", "'$DB_PASSWORD'"); $connection->query("DESCRIBE migrations");' > /dev/null || php artisan migrate --seed --force su www-data -c 'php artisan migrate --force' php artisan scout:sync-index-settings - php-fpm -F -R -O + exec su www-data -c 'frankenphp run --config /etc/caddy/Caddyfile' fi diff --git a/.drone.yml b/.drone.yml index 52776f7c..a1fca5cf 100644 --- a/.drone.yml +++ b/.drone.yml @@ -92,21 +92,6 @@ steps: when: event: tag - - name: docker_webservice_push - image: plugins/docker - settings: - dockerfile: ./.docker/nginx.Dockerfile - repo: zoomyboy/adrema-webservice - username: zoomyboy - password: - from_secret: docker_hub_token - tags: - - latest - - ${DRONE_TAG} - pull_image: true - when: - event: tag - - name: deploy image: zoomyboy/adrema-base:latest environment: diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 863cbeed..9d624a23 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -1,14 +1,5 @@ version: '3' services: - webservice: - image: zoomyboy/adrema-webservice:latest - depends_on: - - php - ports: - - '8000:80' - volumes: - - ./data/storage/public:/app/storage/app/public - php: image: zoomyboy/adrema-app:latest depends_on: @@ -16,6 +7,8 @@ services: - redis - socketi command: /bin/entrypoint app + ports: + - '8000:80' env_file: - .app.env environment: diff --git a/docker-compose.yml b/docker-compose.yml index aa27c717..41ddb0ac 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,16 +1,5 @@ version: '3' services: - webservice: - build: - context: . - dockerfile: ./.docker/nginx.Dockerfile - depends_on: - - php - ports: - - '8000:80' - volumes: - - ./data/storage/public:/app/public/storage - php: build: context: . @@ -20,6 +9,8 @@ services: - redis - socketi command: /bin/entrypoint app + ports: + - '8000:80' env_file: - .app.env environment: