-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: implement prod-ready docker image
And remove laravel sail image
- Loading branch information
1 parent
38a2d7f
commit 523ff32
Showing
23 changed files
with
200 additions
and
361 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
ARG PHP_VERSION=8.2 | ||
ARG INSTALL_BCMATH=true | ||
ARG INSTALL_CALENDAR=false | ||
ARG INSTALL_EXIF=true | ||
ARG INSTALL_GD=true | ||
ARG INSTALL_IMAGICK=true | ||
ARG INSTALL_MOSQUITTO=false | ||
ARG INSTALL_MYSQL=false | ||
ARG INSTALL_OPCACHE=true | ||
ARG INSTALL_PCNTL=true | ||
ARG INSTALL_PGSQL=true | ||
ARG INSTALL_REDIS=true | ||
ARG INSTALL_SQLSRV=false | ||
ARG INSTALL_XDEBUG=false | ||
ARG INSTALL_ZIP=true | ||
ARG INSTALL_INTL=true | ||
|
||
# Backend build | ||
FROM ghcr.io/clevyr/php:$PHP_VERSION-base as php-builder | ||
WORKDIR /app | ||
|
||
COPY composer.json composer.lock ./ | ||
RUN composer install \ | ||
--ignore-platform-reqs \ | ||
--no-autoloader \ | ||
--no-interaction \ | ||
--no-progress \ | ||
--no-suggest | ||
|
||
COPY . . | ||
RUN set -x \ | ||
&& export TELESCOPE_ENABLED=false \ | ||
&& composer dump-autoload \ | ||
--classmap-authoritative \ | ||
--no-interaction \ | ||
&& php artisan vendor:publish --tag=public | ||
|
||
|
||
# Frontend build | ||
FROM node:18-alpine as node-builder | ||
WORKDIR /app | ||
|
||
COPY package.json package-lock.json ./ | ||
RUN npm ci | ||
|
||
COPY --from=php-builder /app . | ||
ARG NODE_ENV=production | ||
RUN npm run build | ||
|
||
|
||
# Local image | ||
FROM ghcr.io/clevyr/php:$PHP_VERSION-onbuild as local-image | ||
WORKDIR /app | ||
|
||
ENV PHP_UPLOAD_MAX_FILESIZE=64m | ||
ENV PHP_POST_MAX_SIZE=64m | ||
|
||
# Install libraries for laravel-medialibrary | ||
RUN set -x \ | ||
&& apk add --no-cache \ | ||
ffmpeg \ | ||
jpegoptim | ||
|
||
COPY --chown=root docker/app/rootfs / | ||
RUN crontab /etc/cron.d/scheduler | ||
|
||
CMD ["s6-svscan", "/etc/s6/app"] | ||
|
||
|
||
# Deployed image | ||
FROM local-image | ||
|
||
COPY --from=php-builder --chown=82:82 /app . | ||
COPY --from=node-builder --chown=82:82 /app/public public/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/sh | ||
set -ex | ||
|
||
cd /app | ||
|
||
( | ||
if [ -f .env ]; then | ||
source .env | ||
fi | ||
|
||
if [ "$APP_ENV" != "local" ]; then | ||
php artisan config:cache | ||
else | ||
composer install --ignore-platform-reqs --no-interaction --no-progress | ||
php artisan config:clear | ||
php artisan vendor:publish --tag=public | ||
fi | ||
|
||
if [ -L public/storage ]; then | ||
rm public/storage | ||
fi | ||
ln -s ../storage/app/public public/storage | ||
|
||
php artisan vendor:publish --force --tag=telescope-assets --tag=horizon-assets | ||
|
||
if [ "$DB_FRESH_ON_START" = "true" ]; then | ||
php artisan migrate:fresh | ||
php artisan db:seed | ||
else | ||
php artisan migrate --force | ||
fi | ||
) | ||
|
||
exec php-fpm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* * * * * s6-setuidgid "${PUID:-www-data}" php /app/artisan schedule:run -n | grep -v 'No scheduled commands are ready to run.' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
server { | ||
listen 80; | ||
listen [::]:80 default ipv6only=on; | ||
|
||
server_name _; | ||
|
||
access_log off; | ||
|
||
root /app/public; | ||
index index.php index.html index.htm; | ||
|
||
client_max_body_size 64m; | ||
|
||
location / { | ||
try_files $uri $uri/ /index.php?$query_string; | ||
} | ||
|
||
location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ { | ||
try_files $uri $uri/ /index.php?$query_string; | ||
expires 7d; | ||
} | ||
|
||
location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ { | ||
try_files $uri $uri/ /index.php?$query_string; | ||
add_header Access-Control-Allow-Origin "*"; | ||
expires 7d; | ||
} | ||
|
||
location ~ [^/]\.php(/|$) { | ||
fastcgi_pass 127.0.0.1:9000; | ||
|
||
# regex to split $uri to $fastcgi_script_name and $fastcgi_path | ||
fastcgi_split_path_info ^(.+\.php)(/.+)$; | ||
|
||
# Check that the PHP script exists before passing it | ||
try_files $fastcgi_script_name =404; | ||
|
||
# Bypass the fact that try_files resets $fastcgi_path_info | ||
# see: http://trac.nginx.org/nginx/ticket/321 | ||
set $path_info $fastcgi_path_info; | ||
fastcgi_param PATH_INFO $path_info; | ||
|
||
fastcgi_index index.php; | ||
|
||
fastcgi_param SCRIPT_FILENAME /app/public/index.php; | ||
|
||
include fastcgi.conf; | ||
} | ||
|
||
location ~* \.(htaccess|htpasswd) { | ||
deny all; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SIGQUIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
exec nginx -g 'daemon off;' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SIGQUIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
exec /entrypoint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
set -x | ||
|
||
exec crond -f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
set -x | ||
|
||
exec s6-setuidgid "${PUID:-www-data}" php /app/artisan queue:work -n --delay=90 --tries=3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
|
||
HEALTH_CHECK_IP="${1:-127.0.0.1}" | ||
|
||
REDIRECT_STATUS=true \ | ||
SCRIPT_NAME=/ping \ | ||
SCRIPT_FILENAME=/ping \ | ||
REQUEST_METHOD=GET \ | ||
cgi-fcgi -bind -connect "$HEALTH_CHECK_IP:9000" \ | ||
| grep pong | ||
exit $? |
6 changes: 6 additions & 0 deletions
6
docker/app/rootfs/usr/local/etc/php/conf.d/99-docker-php-ext-xdebug-config.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[xdebug] | ||
xdebug.remote_autostart = 0 | ||
xdebug.remote_enable = 1 | ||
xdebug.remote_host = "host.docker.internal" | ||
xdebug.remote_port = 9000 | ||
xdebug.remote_profiler_enable_trigger = 1 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.