diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 8781f49..df4b1d5 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,22 +22,50 @@ 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 +RUN chmod +x /entrypoint + # 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 -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/docking.sqlite +RUN chown www-data:www-data 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="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..5238851 --- /dev/null +++ b/.docker/entrypoint.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env sh +set -e + +# 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 + +echo "Welcome to DocKing"; +echo "Starting the application using supervisor..."; +exec /usr/bin/supervisord --nodaemon diff --git a/.docker/octane.Dockerfile b/.docker/octane.Dockerfile index 071e667..e467ad6 100644 --- a/.docker/octane.Dockerfile +++ b/.docker/octane.Dockerfile @@ -1,9 +1,3 @@ -### Docking Development Image - Octane Mode -# Single image to rule them all -# PHP 8.2 -# SQLite -# Local Storage -# Supervisor to run 5 concurrent workers FROM ghcr.io/roadrunner-server/roadrunner:latest AS roadrunner FROM php:8.2-fpm @@ -31,23 +25,50 @@ COPY . . COPY ./.docker/docking-octane.conf /etc/supervisor/conf.d/ COPY ./.docker/docking-host-octane.conf /etc/nginx/conf.d/default.conf +RUN cp .docker/entrypoint.sh /entrypoint +RUN chmod +x /entrypoint + # 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 -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/docking.sqlite +RUN chown www-data:www-data 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="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/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..fe31d01 --- /dev/null +++ b/.docker/scripts/caches.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +echo "Running config:cache..."; +php /var/www/html/artisan config:cache --no-ansi -q +echo "Successfully cached the configuration"; + +echo "Running route:cache..."; +php /var/www/html/artisan route:cache --no-ansi -q +echo "Successfully cached the routes"; + +echo "Running view:cache..."; +php /var/www/html/artisan view:cache --no-ansi -q +echo "Successfully cached the views"; diff --git a/.docker/scripts/migrate.sh b/.docker/scripts/migrate.sh new file mode 100755 index 0000000..0f463f3 --- /dev/null +++ b/.docker/scripts/migrate.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +echo "Running migration..."; +php /var/www/html/artisan migrate --no-ansi -q --force +echo "Successfully migrated"; diff --git a/.github/workflows/push-dev-image.yml b/.github/workflows/push-dev-image.yml index 4328046..c2e27f5 100644 --- a/.github/workflows/push-dev-image.yml +++ b/.github/workflows/push-dev-image.yml @@ -1,8 +1,8 @@ -name: Push Docker Dev Image +name: Push Docker Images env: DEV_IMAGE_ENV: ${{ secrets.DEV_IMAGE_ENV }} - IMAGE: 'shipsaas/docking-dev' - OCTANE_IMAGE: 'shipsaas/docking-dev-octane' + IMAGE: 'shipsaas/docking' + OCTANE_IMAGE: 'shipsaas/docking-on-steroid' REGISTRY: ghcr.io on: diff --git a/.github/workflows/test-build-for-push.yml b/.github/workflows/test-build-for-push.yml new file mode 100644 index 0000000..a50a7ef --- /dev/null +++ b/.github/workflows/test-build-for-push.yml @@ -0,0 +1,39 @@ +name: Test build Docker Image + +on: + pull_request: + branches: + - 'main' + types: [ opened, synchronize, reopened, ready_for_review ] + +jobs: + build_image: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + if: success() + + - name: Setup PHP with coverage driver + uses: shivammathur/setup-php@v2 + with: + php-version: 8.2 + + - name: Setup Node 16 + uses: actions/setup-node@v3 + with: + node-version: 16 + cache: 'npm' + + - name: Setup & Build + if: success() + run: | + composer install --no-interaction + npm ci && npm run build + + - name: Build Docker - Normal Image + if: success() + run: docker build -t docking:test -f .docker/Dockerfile . + + - name: Build Docker - Octane Image + if: success() + run: docker build -t docking:test -f .docker/octane.Dockerfile . diff --git a/resources/js/console/factories/axios.js b/resources/js/console/factories/axios.js index 8db2c15..cdf3751 100644 --- a/resources/js/console/factories/axios.js +++ b/resources/js/console/factories/axios.js @@ -2,7 +2,7 @@ import axios from 'axios'; import { authStorage } from '../utils/authStorage'; const options = { - baseURL: import.meta.env.VITE_APP_URL + '/api/v1', + baseURL: '/api/v1', timeout: 60_000, };