diff --git a/.docker/horizon-entrypoint b/.docker/horizon-entrypoint index c5b9131b..6dd4f62a 100755 --- a/.docker/horizon-entrypoint +++ b/.docker/horizon-entrypoint @@ -10,4 +10,4 @@ function wait_for_db { done } -php artisan horizon +su www-data -c 'php artisan horizon' diff --git a/.docker/nginx.Dockerfile b/.docker/nginx.Dockerfile index 2cdf54c8..9c66ed22 100644 --- a/.docker/nginx.Dockerfile +++ b/.docker/nginx.Dockerfile @@ -15,6 +15,7 @@ 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 +RUN cd public && ln -s ../storage/app/public ./storage EXPOSE 80 VOLUME ["/app/storage/app"] diff --git a/.docker/php-entrypoint b/.docker/php-entrypoint index ec615462..8237941e 100755 --- a/.docker/php-entrypoint +++ b/.docker/php-entrypoint @@ -22,4 +22,9 @@ wait_for_db 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 php artisan migrate --force +mkdir /app/packages/laravel-nami/.cookies || true +mkdir /app/storage/app || true +chown -R www-data:www-data /app/packages/laravel-nami/.cookies +chown -R www-data:www-data /app/storage/app + php-fpm -F -R -O diff --git a/.docker/php.Dockerfile b/.docker/php.Dockerfile index 67654ec6..3d97dbbd 100644 --- a/.docker/php.Dockerfile +++ b/.docker/php.Dockerfile @@ -19,6 +19,11 @@ COPY --chown=www-data:www-data . /app COPY --chown=www-data:www-data --from=node /app/public /app/public 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 + +USER root COPY ./.docker/php-entrypoint /bin/php-entrypoint COPY ./.docker/horizon-entrypoint /bin/horizon-entrypoint diff --git a/.dockerignore b/.dockerignore index 59ab8289..9163726b 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,3 +7,4 @@ bootstrap/cache/services.php bootstrap/cache/packages.php bootstrap/cache/routes.php packages/laravel-nami/.cookies +app/storage/app diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml new file mode 100644 index 00000000..b744e2c8 --- /dev/null +++ b/docker-compose.prod.yml @@ -0,0 +1,63 @@ +version: '3' +services: + webservice: + image: zoomyboy/adrema-webservice:latest + depends_on: + - php + ports: + - '8000:80' + volumes: + - ./data/storage:/app/storage/app + + php: + image: zoomyboy/adrema-app:latest + depends_on: + - db + env_file: + - .app.env + environment: + DB_HOST: db + DB_DATABASE: db + DB_USERNAME: db + QUEUE_CONNECTION: redis + XELATEX_BIN: /usr/bin/xelatex + PDFLATEX_BIN: /usr/bin/pdflatex + REDIS_HOST: redis + volumes: + - ./data/storage:/app/storage/app + - ./cookies:/app/packages/laravel-nami/.cookies + + horizon: + image: zoomyboy/adrema-app:latest + depends_on: + - db + - php + command: /bin/horizon-entrypoint + env_file: + - .app.env + environment: + DB_HOST: db + DB_DATABASE: db + DB_USERNAME: db + QUEUE_CONNECTION: redis + XELATEX_BIN: /usr/bin/xelatex + PDFLATEX_BIN: /usr/bin/pdflatex + REDIS_HOST: redis + volumes: + - ./data/storage:/app/storage/app + - ./cookies:/app/packages/laravel-nami/.cookies + + db: + image: mariadb:10.6.5 + env_file: + - .app.env + environment: + MARIADB_RANDOM_ROOT_PASSWORD: yes + MYSQL_DATABASE: db + MYSQL_USER: db + volumes: + - ./data/db:/var/lib/mysql + + redis: + image: redis:alpine3.18 + container_name: redis diff --git a/docker-compose.yml b/docker-compose.yml index 438b431e..c745f5dc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,16 +1,20 @@ version: '3' services: webservice: - image: zoomyboy/adrema-webservice:latest + build: + context: . + dockerfile: ./.docker/nginx.Dockerfile depends_on: - php ports: - '8000:80' volumes: - - ./storage:/app/storage/app + - ./data/storage:/app/storage/app php: - image: zoomyboy/adrema-app:latest + build: + context: . + dockerfile: ./.docker/php.Dockerfile depends_on: - db env_file: @@ -24,11 +28,13 @@ services: PDFLATEX_BIN: /usr/bin/pdflatex REDIS_HOST: redis volumes: - - ./storage:/app/storage/app + - ./data/storage:/app/storage/app - ./cookies:/app/packages/laravel-nami/.cookies horizon: - image: zoomyboy/adrema-app:latest + build: + context: . + dockerfile: ./.docker/php.Dockerfile depends_on: - db - php