From 770da45dbf0b53c15061847d8dd5cdb203c60438 Mon Sep 17 00:00:00 2001 From: Darko Gjorgjijoski <5760249+gdarko@users.noreply.github.com> Date: Tue, 2 Sep 2025 03:27:26 +0200 Subject: [PATCH] Production docker improvements (#463) * Update production dockerfiles for testing * Add bash, nano and remove unecessary sqlite3 alpine package --- docker/production/Dockerfile | 2 +- ...e.example.yml => docker-compose.mysql.yml} | 26 ++++++++----------- docker/production/docker-compose.sqlite.yml | 2 +- docker/production/entrypoint.d/00-setup.sh | 2 +- 4 files changed, 14 insertions(+), 18 deletions(-) rename docker/production/{docker-compose.example.yml => docker-compose.mysql.yml} (84%) diff --git a/docker/production/Dockerfile b/docker/production/Dockerfile index 37d406c1..3930a4c4 100644 --- a/docker/production/Dockerfile +++ b/docker/production/Dockerfile @@ -5,7 +5,7 @@ FROM --platform=$BUILDPLATFORM node:20 AS static_builder FROM serversideup/php:8.3-fpm-nginx-alpine AS base USER root - RUN apk add --no-cache sqlite + RUN apk add --no-cache bash nano RUN install-php-extensions exif RUN install-php-extensions pgsql RUN install-php-extensions sqlite3 diff --git a/docker/production/docker-compose.example.yml b/docker/production/docker-compose.mysql.yml similarity index 84% rename from docker/production/docker-compose.example.yml rename to docker/production/docker-compose.mysql.yml index dbba080b..da63e1f6 100644 --- a/docker/production/docker-compose.example.yml +++ b/docker/production/docker-compose.mysql.yml @@ -25,23 +25,16 @@ services: retries: 10 webapp: - container_name: invoiceshelf-app + container_name: invoiceshelf-variant-mariadb build: context: ../../ dockerfile: docker/production/Dockerfile - ports: - - 90:8080 - volumes: - - invoiceshelf_storage:/var/www/html/storage/ - networks: - - invoiceshelf environment: - - CONTAINERIZED=true - APP_NAME=Laravel - APP_ENV=local - APP_DEBUG=true - - APP_URL=http://localhost:90 - - DB_CONNECTION=mysql + - APP_URL=http://localhost:8090 + - DB_CONNECTION=mariadb - DB_HOST=database - DB_PORT=3306 - DB_DATABASE=invoiceshelf @@ -50,12 +43,9 @@ services: - DB_PASSWORD_FILE= - CACHE_STORE=file - SESSION_DRIVER=file - - SESSION_LIFETIME=120 - - SESSION_ENCRYPT=false - - SESSION_PATH=/ + - SESSION_LIFETIME=240 - SESSION_DOMAIN=localhost - - SANCTUM_STATEFUL_DOMAINS=localhost:90 - - STARTUP_DELAY= + - SANCTUM_STATEFUL_DOMAINS=localhost:8090 #- MAIL_MAILER=smtp #- MAIL_HOST=smtp.mailtrap.io #- MAIL_PORT=2525 @@ -63,6 +53,12 @@ services: #- MAIL_PASSWORD=null #- MAIL_PASSWORD_FILE= #- MAIL_ENCRYPTION=null + volumes: + - invoiceshelf_storage:/var/www/html/storage/ + ports: + - "8090:8080" # 8090 is the public port. + networks: + - invoiceshelf restart: unless-stopped depends_on: - database diff --git a/docker/production/docker-compose.sqlite.yml b/docker/production/docker-compose.sqlite.yml index 276accc4..9de7b89f 100644 --- a/docker/production/docker-compose.sqlite.yml +++ b/docker/production/docker-compose.sqlite.yml @@ -5,7 +5,7 @@ services: webapp: - container_name: invoiceshelf-sqlite + container_name: invoiceshelf-variant-sqlite build: context: ../../ dockerfile: docker/production/Dockerfile diff --git a/docker/production/entrypoint.d/00-setup.sh b/docker/production/entrypoint.d/00-setup.sh index 42a7b834..48f36f98 100644 --- a/docker/production/entrypoint.d/00-setup.sh +++ b/docker/production/entrypoint.d/00-setup.sh @@ -28,7 +28,7 @@ if [ "$DB_CONNECTION" = "sqlite" ] || [ -z "$DB_CONNECTION" ]; then if [ ! -e "$DB_DATABASE" ]; then echo "**** Specified sqlite database doesn't exist. Creating it ****" echo "**** Please make sure your database is on a persistent volume ****" - sqlite3 "$DB_DATABASE" "VACUUM;" + cp /var/wwwp/html/database/stubs/sqlite.empty.db "$DB_DATABASE" fi chown www-data:www-data "$DB_DATABASE" fi