diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 8781f49..0a5c197 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -1,11 +1,3 @@ -### Docking Development Image -# Single image to rule them all -# PHP 8.2 -# SQLite -# Nginx -# Local Storage -# Supervisor to run 5 concurrent workers - FROM php:8.2-fpm WORKDIR /var/www/html @@ -30,6 +22,8 @@ COPY . . COPY ./.docker/docking-worker.conf /etc/supervisor/conf.d/ COPY ./.docker/docking-host.conf /etc/nginx/conf.d/default.conf +RUN cp .docker/entrypoint.sh /entrypoint + # The bundle already built, no need to keep this to save size RUN rm -rf ./node_modules @@ -40,6 +34,8 @@ RUN php artisan migrate RUN chown -R www-data:www-data storage RUN chown -R www-data:www-data storage/app RUN chmod -R 777 storage/logs + +RUN touch /var/www/html/database.sqlite RUN chmod -R 777 docking.sqlite # Nginx remove default site @@ -47,5 +43,29 @@ RUN rm /etc/nginx/sites-enabled/default EXPOSE 80 +############# Default app ENV +ENV APP_ENV="production" +ENV APP_KEY="base64:/UnGygYvVBmIh+VgNhMj6MyI/ieXTtzUJsUL4OUtZGI=" +ENV DB_CONNECTION="sqlite" +ENV DATABASE_URL="sqlite:/var/www/html/docking.sqlite" + +############# Storage ENV + +# s3|local +ENV FILESYSTEM_DISK=public + +# if select s3, these must be defined +ENV AWS_ACCESS_KEY_ID="" +ENV AWS_SECRET_ACCESS_KEY="" +ENV AWS_DEFAULT_REGION="ap-southeast-1" +ENV AWS_BUCKET="shipsaas-docking" + +############# Docking Config +ENV DOCKING_PUBLIC_ACCESS_KEY="" +ENV DOCKING_CONSOLE_ENABLED=true +ENV DOCKING_CONSOLE_PASSWORD="" +ENV DOCKING_DEFAULT_PDF_DRIVER="gotenberg" +ENV DOCKING_GOTENBERG_ENDPOINT="http://127.0.0.1:9898" + # Start ALL -CMD ["/usr/bin/supervisord", "-n"] +ENTRYPOINT ["/entrypoint"] diff --git a/.docker/README.md b/.docker/README.md index 7e070ae..aaf2b1a 100644 --- a/.docker/README.md +++ b/.docker/README.md @@ -1,11 +1,11 @@ # Docker of DocKing -DocKing ships Docker Images too, in case you want boot it up as fast as you can for development, even production usage. +DocKing ships Docker Images too. -## Development +## 2024 updates -Check out: https://docking.shipsaas.tech/getting-started/run-on-local/docker +DocKing image can be used in both development & production 😎. You can inject your own ENVs in runtime. -## Production +## Run DocKing -Check out: https://docking.shipsaas.tech/deployment/docker +TBA diff --git a/.docker/entrypoint.sh b/.docker/entrypoint.sh new file mode 100755 index 0000000..40eace6 --- /dev/null +++ b/.docker/entrypoint.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env sh + +# Run user scripts, if they exist +for f in /var/www/html/.docker/scripts/*.sh; do + # Bail out this loop if any script exits with non-zero status code + bash "$f" || break +done +chown -R www-data:www-data /var/www/html + +if [ $# -gt 0 ]; then + # If we passed a command, run it as root + exec "$@" +else + exec /usr/bin/supervisord -n +fi diff --git a/.docker/octane.Dockerfile b/.docker/octane.Dockerfile index 071e667..ab842e2 100644 --- a/.docker/octane.Dockerfile +++ b/.docker/octane.Dockerfile @@ -41,13 +41,38 @@ RUN php artisan migrate RUN chown -R www-data:www-data storage RUN chown -R www-data:www-data storage/app RUN chmod -R 777 storage/logs -RUN chmod -R 777 docking.sqlite +RUN touch /var/www/html/database.sqlite +RUN chmod -R 777 docking.sqlite # Nginx remove default site RUN rm /etc/nginx/sites-enabled/default EXPOSE 80 +############# Default app ENV +ENV APP_ENV="production" +ENV APP_KEY="base64:/UnGygYvVBmIh+VgNhMj6MyI/ieXTtzUJsUL4OUtZGI=" +ENV DB_CONNECTION="sqlite" +ENV DATABASE_URL="sqlite:/var/www/html/docking.sqlite" + +############# Storage ENV + +# s3|local +ENV FILESYSTEM_DISK=public + +# if select s3, these must be defined +ENV AWS_ACCESS_KEY_ID="" +ENV AWS_SECRET_ACCESS_KEY="" +ENV AWS_DEFAULT_REGION="" +ENV AWS_BUCKET="" + +############# Docking Config +ENV DOCKING_PUBLIC_ACCESS_KEY="" +ENV DOCKING_CONSOLE_ENABLED=true +ENV DOCKING_CONSOLE_PASSWORD="" +ENV DOCKING_DEFAULT_PDF_DRIVER="gotenberg" +ENV DOCKING_GOTENBERG_ENDPOINT="http://127.0.0.1:9898" + # Start ALL -CMD ["/usr/bin/supervisord", "-n"] +ENTRYPOINT ["/entrypoint"] diff --git a/.docker/prod.Dockerfile b/.docker/prod.Dockerfile deleted file mode 100644 index f57cd36..0000000 --- a/.docker/prod.Dockerfile +++ /dev/null @@ -1,49 +0,0 @@ -### Docking Production Image -# Single image to rule them all -# PHP 8.2 -# MySQL (you can change this) -# Nginx -# Supervisor to run 5 concurrent workers -# Please configure and setup based on your needs - -FROM php:8.2-fpm - -WORKDIR /var/www/html - -RUN apt-get update && apt-get install -y \ - git \ - curl \ - libpng-dev \ - libonig-dev \ - libxml2-dev \ - zip \ - unzip \ - supervisor \ - nginx \ - wkhtmltopdf - -# Install PHP extensions -RUN docker-php-ext-install pdo pdo_pgsql pdo_mysql mbstring exif pcntl bcmath gd - -# Copy project files -COPY . . -COPY ./.docker/docking-worker.conf /etc/supervisor/conf.d/ -COPY ./.docker/docking-host.conf /etc/nginx/conf.d/default.conf - -# The bundle already built, no need to keep this to save size -RUN rm -rf ./node_modules - -RUN php artisan optimize -RUN php artisan storage:link - -# Set permissions -RUN chown -R www-data:www-data storage -RUN chown -R www-data:www-data bootstrap/cache - -# Nginx remove default site -RUN rm /etc/nginx/sites-enabled/default - -EXPOSE 80 - -# Start ALL -CMD ["/usr/bin/supervisord", "-n"] diff --git a/.docker/scripts/caches.sh b/.docker/scripts/caches.sh new file mode 100755 index 0000000..7ab868a --- /dev/null +++ b/.docker/scripts/caches.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +/usr/bin/php /var/www/html/artisan config:cache --no-ansi -q +/usr/bin/php /var/www/html/artisan route:cache --no-ansi -q +/usr/bin/php /var/www/html/artisan view:cache --no-ansi -q diff --git a/.docker/scripts/migrate.sh b/.docker/scripts/migrate.sh new file mode 100755 index 0000000..52aab25 --- /dev/null +++ b/.docker/scripts/migrate.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +/usr/bin/php /var/www/html/artisan migrate