Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New & Better Docker Image #29

Merged
merged 11 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 31 additions & 11 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"]
10 changes: 5 additions & 5 deletions .docker/README.md
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions .docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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
39 changes: 30 additions & 9 deletions .docker/octane.Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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"]
49 changes: 0 additions & 49 deletions .docker/prod.Dockerfile

This file was deleted.

13 changes: 13 additions & 0 deletions .docker/scripts/caches.sh
Original file line number Diff line number Diff line change
@@ -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";
5 changes: 5 additions & 0 deletions .docker/scripts/migrate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

echo "Running migration...";
php /var/www/html/artisan migrate --no-ansi -q --force
echo "Successfully migrated";
6 changes: 3 additions & 3 deletions .github/workflows/push-dev-image.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/test-build-for-push.yml
Original file line number Diff line number Diff line change
@@ -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 .
2 changes: 1 addition & 1 deletion resources/js/console/factories/axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
Loading