Replies: 5 comments 6 replies
-
You can add Looks about right to me! Here's a real Dockerfile for a production service if you want to compare notes: FROM dunglas/frankenphp:1-php8.3-bookworm AS builder
ARG EXTRA_EXTENSIONS="opcache"
RUN install-php-extensions @composer intl ctype mbstring apcu pdo pdo_pgsql zip $EXTRA_EXTENSIONS
RUN apt-get update && apt-get install -y inotify-tools && \
rm -rf /var/lib/apt/lists/*
RUN cp "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"; \
sed -i 's/variables_order = "GPCS"/variables_order = "EGPCS"/' "$PHP_INI_DIR/php.ini";
ENV SERVER_NAME=":8080" FRANKENPHP_CONFIG='worker /app/public/index.php'
RUN useradd -r -d /app -s /bin/bash -g root -G sudo -u 1000 caddy; \
mkdir /data; \
mkdir /config; \
chown caddy:root -R /data; \
chown caddy:root -R /config;
FROM builder AS production
COPY composer.json composer.lock /app/
RUN composer install --no-dev --optimize-autoloader --apcu-autoloader --no-scripts --no-plugins
COPY src /app/src
COPY public /app/public
COPY bin /app/bin
# run any plugins/scripts as needed
RUN COMPOSER_ALLOW_SUPERUSER=1 composer dump --optimize --apcu --no-dev
RUN echo "xdebug.mode=debug\nxdebug.discover_client_host=1\n" >> $PHP_INI_DIR/php.ini
USER 1000
FROM production AS tests
USER root
COPY . .
RUN composer install || composer install # silly workaround
RUN vendor/bin/pest The x-service-build: &build
context: .
pull: true
dockerfile: Dockerfile
target: production
args:
EXTRA_EXTENSIONS: "xdebug"
x-service-env: &senv
DATABASE_USER: root
DATABASE_PASSWORD: insecure
DATABASE_HOST: postgres
DATABASE_PORT: '5432'
DATABASE_NAME: postgres
XDEBUG_SESSION: 1
XDEBUG_CONFIG: "log_level=10"
# comment out below to enable worker mode and disable xdebug stepping
FRANKENPHP_CONFIG: ""
services:
translation-init:
image: funxtionatics/translation-system
depends_on:
postgres:
condition: service_healthy
build:
<<: *build
environment:
<<: *senv
restart: no
volumes:
- ./:/app
command: ['/app/bin/init.sh']
translation-tests:
image: funxtionatics/translation-system
depends_on:
translation-init:
condition: service_completed_successfully
profiles:
- tests
build:
<<: *build
environment:
<<: *senv
volumes:
- ./:/app
command: ["vendor/bin/pest"]
translation-service:
image: funxtionatics/translation-system
depends_on:
translation-init:
condition: service_completed_successfully
build:
<<: *build
environment:
<<: *senv
volumes:
- ./:/app
command: ['/app/bin/watch.sh', 'frankenphp run -c /etc/caddy/Caddyfile']
ports:
- "8881:8080"
stop_signal: SIGINT And if you are curious, here's #!/usr/bin/env bash
sigint_handler()
{
kill -9 $PID
exit
}
trap sigint_handler SIGINT
trap sigint_handler SIGTERM
while true; do
# commands to perform any work on changes
composer dump -o --apcu
bin/doctrine orm:schema-tool:update --force --complete
$@ &
PID=$!
inotifywait -e modify -e move -e create -e delete -e attrib -r "$(pwd)/src" "$(pwd)/public" "$(pwd)/vendor"
kill $PID
done |
Beta Was this translation helpful? Give feedback.
-
Thank you so much for this, this helps me a lot |
Beta Was this translation helpful? Give feedback.
-
Can I see your Caddyfile and what it looks like also I did not see in your Dockerfile that you copied the Caddyfile to the docker? |
Beta Was this translation helpful? Give feedback.
-
Is your app is Laravel?. because you have this folders
Thank you in advance |
Beta Was this translation helpful? Give feedback.
-
I tried to follow some of your dockerfile and using multi stage, after I build I get 917.1MB is this correct ? I'm expecting I can get 1mb or something. my laravel app is only using API and default code for the API. no other than that.
Thank you in advance. |
Beta Was this translation helpful? Give feedback.
-
Hi
When deploying to production should we need to use Caddyfile or is this enough to deploy?
Thank you in advance
Beta Was this translation helpful? Give feedback.
All reactions