Skip to content

Commit 76d7950

Browse files
authored
New & Better Docker Image (#29)
* WIP * Build action * Build action * migrate when run, not build * fixed db name lol * wip * wip * WIP * done * change image name * change image name
1 parent 94d0efa commit 76d7950

File tree

10 files changed

+139
-78
lines changed

10 files changed

+139
-78
lines changed

.docker/Dockerfile

+31-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
### Docking Development Image
2-
# Single image to rule them all
3-
# PHP 8.2
4-
# SQLite
5-
# Nginx
6-
# Local Storage
7-
# Supervisor to run 5 concurrent workers
8-
91
FROM php:8.2-fpm
102

113
WORKDIR /var/www/html
@@ -30,22 +22,50 @@ COPY . .
3022
COPY ./.docker/docking-worker.conf /etc/supervisor/conf.d/
3123
COPY ./.docker/docking-host.conf /etc/nginx/conf.d/default.conf
3224

25+
RUN cp .docker/entrypoint.sh /entrypoint
26+
RUN chmod +x /entrypoint
27+
3328
# The bundle already built, no need to keep this to save size
3429
RUN rm -rf ./node_modules
3530

3631
RUN php artisan optimize
3732
RUN php artisan storage:link
38-
RUN php artisan migrate
3933

4034
RUN chown -R www-data:www-data storage
4135
RUN chown -R www-data:www-data storage/app
4236
RUN chmod -R 777 storage/logs
43-
RUN chmod -R 777 docking.sqlite
37+
38+
RUN touch /var/www/html/docking.sqlite
39+
RUN chown www-data:www-data docking.sqlite
4440

4541
# Nginx remove default site
4642
RUN rm /etc/nginx/sites-enabled/default
4743

4844
EXPOSE 80
4945

46+
############# Default app ENV
47+
ENV APP_ENV="production"
48+
ENV APP_KEY="base64:/UnGygYvVBmIh+VgNhMj6MyI/ieXTtzUJsUL4OUtZGI="
49+
ENV DB_CONNECTION="sqlite"
50+
ENV DATABASE_URL="sqlite:////var/www/html/docking.sqlite"
51+
52+
############# Storage ENV
53+
54+
# s3|local
55+
ENV FILESYSTEM_DISK=public
56+
57+
# if select s3, these must be defined
58+
ENV AWS_ACCESS_KEY_ID=""
59+
ENV AWS_SECRET_ACCESS_KEY=""
60+
ENV AWS_DEFAULT_REGION="ap-southeast-1"
61+
ENV AWS_BUCKET="shipsaas-docking"
62+
63+
############# Docking Config
64+
ENV DOCKING_PUBLIC_ACCESS_KEY=""
65+
ENV DOCKING_CONSOLE_ENABLED=true
66+
ENV DOCKING_CONSOLE_PASSWORD=""
67+
ENV DOCKING_DEFAULT_PDF_DRIVER="gotenberg"
68+
ENV DOCKING_GOTENBERG_ENDPOINT="http://127.0.0.1:9898"
69+
5070
# Start ALL
51-
CMD ["/usr/bin/supervisord", "-n"]
71+
ENTRYPOINT ["/entrypoint"]

.docker/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Docker of DocKing
22

3-
DocKing ships Docker Images too, in case you want boot it up as fast as you can for development, even production usage.
3+
DocKing ships Docker Images too.
44

5-
## Development
5+
## 2024 updates
66

7-
Check out: https://docking.shipsaas.tech/getting-started/run-on-local/docker
7+
DocKing image can be used in both development & production 😎. You can inject your own ENVs in runtime.
88

9-
## Production
9+
## Run DocKing
1010

11-
Check out: https://docking.shipsaas.tech/deployment/docker
11+
TBA

.docker/entrypoint.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env sh
2+
set -e
3+
4+
# Run user scripts, if they exist
5+
for f in /var/www/html/.docker/scripts/*.sh; do
6+
# Bail out this loop if any script exits with non-zero status code
7+
bash "$f" || break
8+
done
9+
10+
echo "Welcome to DocKing";
11+
echo "Starting the application using supervisor...";
12+
exec /usr/bin/supervisord --nodaemon

.docker/octane.Dockerfile

+30-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
### Docking Development Image - Octane Mode
2-
# Single image to rule them all
3-
# PHP 8.2
4-
# SQLite
5-
# Local Storage
6-
# Supervisor to run 5 concurrent workers
71
FROM ghcr.io/roadrunner-server/roadrunner:latest AS roadrunner
82
FROM php:8.2-fpm
93

@@ -31,23 +25,50 @@ COPY . .
3125
COPY ./.docker/docking-octane.conf /etc/supervisor/conf.d/
3226
COPY ./.docker/docking-host-octane.conf /etc/nginx/conf.d/default.conf
3327

28+
RUN cp .docker/entrypoint.sh /entrypoint
29+
RUN chmod +x /entrypoint
30+
3431
# The bundle already built, no need to keep this to save size
3532
RUN rm -rf ./node_modules
3633

3734
RUN php artisan optimize
3835
RUN php artisan storage:link
39-
RUN php artisan migrate
4036

4137
RUN chown -R www-data:www-data storage
4238
RUN chown -R www-data:www-data storage/app
4339
RUN chmod -R 777 storage/logs
44-
RUN chmod -R 777 docking.sqlite
4540

41+
RUN touch /var/www/html/docking.sqlite
42+
RUN chown www-data:www-data docking.sqlite
4643

4744
# Nginx remove default site
4845
RUN rm /etc/nginx/sites-enabled/default
4946

5047
EXPOSE 80
5148

49+
############# Default app ENV
50+
ENV APP_ENV="production"
51+
ENV APP_KEY="base64:/UnGygYvVBmIh+VgNhMj6MyI/ieXTtzUJsUL4OUtZGI="
52+
ENV DB_CONNECTION="sqlite"
53+
ENV DATABASE_URL="sqlite:////var/www/html/docking.sqlite"
54+
55+
############# Storage ENV
56+
57+
# s3|local
58+
ENV FILESYSTEM_DISK=public
59+
60+
# if select s3, these must be defined
61+
ENV AWS_ACCESS_KEY_ID=""
62+
ENV AWS_SECRET_ACCESS_KEY=""
63+
ENV AWS_DEFAULT_REGION="ap-southeast-1"
64+
ENV AWS_BUCKET="shipsaas-docking"
65+
66+
############# Docking Config
67+
ENV DOCKING_PUBLIC_ACCESS_KEY=""
68+
ENV DOCKING_CONSOLE_ENABLED=true
69+
ENV DOCKING_CONSOLE_PASSWORD=""
70+
ENV DOCKING_DEFAULT_PDF_DRIVER="gotenberg"
71+
ENV DOCKING_GOTENBERG_ENDPOINT="http://127.0.0.1:9898"
72+
5273
# Start ALL
53-
CMD ["/usr/bin/supervisord", "-n"]
74+
ENTRYPOINT ["/entrypoint"]

.docker/prod.Dockerfile

-49
This file was deleted.

.docker/scripts/caches.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
echo "Running config:cache...";
4+
php /var/www/html/artisan config:cache --no-ansi -q
5+
echo "Successfully cached the configuration";
6+
7+
echo "Running route:cache...";
8+
php /var/www/html/artisan route:cache --no-ansi -q
9+
echo "Successfully cached the routes";
10+
11+
echo "Running view:cache...";
12+
php /var/www/html/artisan view:cache --no-ansi -q
13+
echo "Successfully cached the views";

.docker/scripts/migrate.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
echo "Running migration...";
4+
php /var/www/html/artisan migrate --no-ansi -q --force
5+
echo "Successfully migrated";

.github/workflows/push-dev-image.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
name: Push Docker Dev Image
1+
name: Push Docker Images
22
env:
33
DEV_IMAGE_ENV: ${{ secrets.DEV_IMAGE_ENV }}
4-
IMAGE: 'shipsaas/docking-dev'
5-
OCTANE_IMAGE: 'shipsaas/docking-dev-octane'
4+
IMAGE: 'shipsaas/docking'
5+
OCTANE_IMAGE: 'shipsaas/docking-on-steroid'
66
REGISTRY: ghcr.io
77

88
on:
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Test build Docker Image
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- 'main'
7+
types: [ opened, synchronize, reopened, ready_for_review ]
8+
9+
jobs:
10+
build_image:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
if: success()
15+
16+
- name: Setup PHP with coverage driver
17+
uses: shivammathur/setup-php@v2
18+
with:
19+
php-version: 8.2
20+
21+
- name: Setup Node 16
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: 16
25+
cache: 'npm'
26+
27+
- name: Setup & Build
28+
if: success()
29+
run: |
30+
composer install --no-interaction
31+
npm ci && npm run build
32+
33+
- name: Build Docker - Normal Image
34+
if: success()
35+
run: docker build -t docking:test -f .docker/Dockerfile .
36+
37+
- name: Build Docker - Octane Image
38+
if: success()
39+
run: docker build -t docking:test -f .docker/octane.Dockerfile .

resources/js/console/factories/axios.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import axios from 'axios';
22
import { authStorage } from '../utils/authStorage';
33

44
const options = {
5-
baseURL: import.meta.env.VITE_APP_URL + '/api/v1',
5+
baseURL: '/api/v1',
66
timeout: 60_000,
77
};
88

0 commit comments

Comments
 (0)