Merge branch 'next' into separate-success-and-failure-notifications
This commit is contained in:
@@ -47,7 +47,7 @@ jobs:
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: docker/prod/Dockerfile
|
||||
file: docker/production/Dockerfile
|
||||
platforms: linux/amd64
|
||||
push: true
|
||||
tags: |
|
||||
@@ -82,7 +82,7 @@ jobs:
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: docker/prod/Dockerfile
|
||||
file: docker/production/Dockerfile
|
||||
platforms: linux/aarch64
|
||||
push: true
|
||||
tags: |
|
||||
|
||||
4
.github/workflows/coolify-staging-build.yml
vendored
4
.github/workflows/coolify-staging-build.yml
vendored
@@ -42,7 +42,7 @@ jobs:
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: docker/prod/Dockerfile
|
||||
file: docker/production/Dockerfile
|
||||
platforms: linux/amd64
|
||||
push: true
|
||||
tags: |
|
||||
@@ -75,7 +75,7 @@ jobs:
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: docker/prod/Dockerfile
|
||||
file: docker/production/Dockerfile
|
||||
platforms: linux/aarch64
|
||||
push: true
|
||||
tags: |
|
||||
|
||||
@@ -76,7 +76,5 @@ class Dev extends Command
|
||||
} else {
|
||||
echo "Instance already initialized.\n";
|
||||
}
|
||||
// Set permissions
|
||||
Process::run(['chmod', '-R', 'o+rwx', '.']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class Horizon extends Command
|
||||
public function handle()
|
||||
{
|
||||
if (config('constants.horizon.is_horizon_enabled')) {
|
||||
$this->info('[x]: Horizon is enabled. Starting.');
|
||||
$this->info('Horizon is enabled on this server.');
|
||||
$this->call('horizon');
|
||||
exit(0);
|
||||
} else {
|
||||
|
||||
@@ -55,10 +55,8 @@ class Init extends Command
|
||||
} else {
|
||||
$this->cleanup_in_progress_application_deployments();
|
||||
}
|
||||
echo "[3]: Cleanup Redis keys.\n";
|
||||
$this->call('cleanup:redis');
|
||||
|
||||
echo "[4]: Cleanup stucked resources.\n";
|
||||
$this->call('cleanup:stucked-resources');
|
||||
|
||||
try {
|
||||
@@ -114,7 +112,6 @@ class Init extends Command
|
||||
|
||||
private function optimize()
|
||||
{
|
||||
echo "[1]: Optimizing Laravel (caching config, routes, views).\n";
|
||||
Artisan::call('optimize:clear');
|
||||
Artisan::call('optimize');
|
||||
}
|
||||
@@ -189,7 +186,6 @@ class Init extends Command
|
||||
}
|
||||
}
|
||||
if ($commands->isNotEmpty()) {
|
||||
echo "Cleaning up unused networks from coolify proxy\n";
|
||||
remote_process(command: $commands, type: ActivityTypes::INLINE->value, server: $server, ignore_errors: false);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
@@ -232,15 +228,14 @@ class Init extends Command
|
||||
$settings = instanceSettings();
|
||||
$do_not_track = data_get($settings, 'do_not_track');
|
||||
if ($do_not_track == true) {
|
||||
echo "[2]: Skipping sending live signal as do_not_track is enabled\n";
|
||||
echo "Do_not_track is enabled\n";
|
||||
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Http::get("https://undead.coolify.io/v4/alive?appId=$id&version=$version");
|
||||
echo "[2]: Sending live signal!\n";
|
||||
} catch (\Throwable $e) {
|
||||
echo "[2]: Error in sending live signal: {$e->getMessage()}\n";
|
||||
echo "Error in sending live signal: {$e->getMessage()}\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,7 +248,6 @@ class Init extends Command
|
||||
}
|
||||
$queued_inprogress_deployments = ApplicationDeploymentQueue::whereIn('status', [ApplicationDeploymentStatus::IN_PROGRESS->value, ApplicationDeploymentStatus::QUEUED->value])->get();
|
||||
foreach ($queued_inprogress_deployments as $deployment) {
|
||||
echo "Cleaning up deployment: {$deployment->id}\n";
|
||||
$deployment->status = ApplicationDeploymentStatus::FAILED->value;
|
||||
$deployment->save();
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class Scheduler extends Command
|
||||
public function handle()
|
||||
{
|
||||
if (config('constants.horizon.is_scheduler_enabled')) {
|
||||
$this->info('[x]: Scheduler is enabled. Starting.');
|
||||
$this->info('Scheduler is enabled on this server.');
|
||||
$this->call('schedule:work');
|
||||
exit(0);
|
||||
} else {
|
||||
|
||||
@@ -20,7 +20,7 @@ abstract class BaseModel extends Model
|
||||
});
|
||||
}
|
||||
|
||||
public function name(): Attribute
|
||||
public function sanitizedName(): Attribute
|
||||
{
|
||||
return new Attribute(
|
||||
get: fn () => sanitize_string($this->getRawOriginal('name')),
|
||||
|
||||
517
composer.lock
generated
517
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -22,9 +22,9 @@ class ProductionSeeder extends Seeder
|
||||
public function run(): void
|
||||
{
|
||||
if (isCloud()) {
|
||||
echo "[x]: Running in cloud mode.\n";
|
||||
echo " Running in cloud mode.\n";
|
||||
} else {
|
||||
echo "[x]: Running in self-hosted mode.\n";
|
||||
echo " Running in self-hosted mode.\n";
|
||||
}
|
||||
|
||||
// Fix for 4.0.0-beta.37
|
||||
|
||||
@@ -2,15 +2,14 @@ services:
|
||||
coolify:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./docker/dev/Dockerfile
|
||||
dockerfile: ./docker/development/Dockerfile
|
||||
args:
|
||||
- USER_ID=${USERID:-1000}
|
||||
- GROUP_ID=${GROUPID:-1000}
|
||||
ports:
|
||||
- "${APP_PORT:-8000}:80"
|
||||
environment:
|
||||
PUID: "${USERID:-1000}"
|
||||
PGID: "${GROUPID:-1000}"
|
||||
SSL_MODE: "off"
|
||||
AUTORUN_LARAVEL_STORAGE_LINK: "false"
|
||||
AUTORUN_LARAVEL_MIGRATION: "false"
|
||||
AUTORUN_ENABLED: false
|
||||
PUSHER_HOST: "${PUSHER_HOST}"
|
||||
PUSHER_PORT: "${PUSHER_PORT}"
|
||||
PUSHER_SCHEME: "${PUSHER_SCHEME:-http}"
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
# Versions
|
||||
# https://hub.docker.com/r/serversideup/php/tags?name=8.3-fpm-nginx-alpine
|
||||
ARG SERVERSIDEUP_PHP_VERSION=8.2-fpm-nginx-v2.2.1
|
||||
# https://github.com/minio/mc/releases
|
||||
ARG MINIO_VERSION=RELEASE.2024-11-05T11-29-45Z
|
||||
# https://github.com/cloudflare/cloudflared/releases
|
||||
ARG CLOUDFLARED_VERSION=2024.11.0
|
||||
# https://www.postgresql.org/support/versioning/ - Can not updated automatically so keep it at 15
|
||||
ARG POSTGRES_VERSION=15
|
||||
|
||||
FROM minio/mc:${MINIO_VERSION} AS minio-client
|
||||
|
||||
FROM serversideup/php:${SERVERSIDEUP_PHP_VERSION}
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
ARG CLOUDFLARED_VERSION
|
||||
ARG MINIO_VERSION
|
||||
ARG POSTGRES_VERSION
|
||||
|
||||
# Use build arguments for caching
|
||||
ARG BUILDTIME_DEPS="dirmngr ca-certificates software-properties-common gnupg gnupg2 apt-transport-https curl"
|
||||
ARG RUNTIME_DEPS="postgresql-client-$POSTGRES_VERSION php8.2-pgsql openssh-client git git-lfs jq lsof"
|
||||
|
||||
# Install dependencies
|
||||
RUN --mount=type=cache,target=/var/cache/apt \
|
||||
apt-get update && \
|
||||
apt-get install -y $BUILDTIME_DEPS && \
|
||||
curl -fSsL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /usr/share/keyrings/postgresql.gpg > /dev/null && \
|
||||
echo deb [arch=amd64,arm64,ppc64el signed-by=/usr/share/keyrings/postgresql.gpg] http://apt.postgresql.org/pub/repos/apt/ jammy-pgdg main | tee -a /etc/apt/sources.list.d/postgresql.list && \
|
||||
apt-get update && \
|
||||
apt-get install -y $RUNTIME_DEPS && \
|
||||
apt-get -y autoremove && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
|
||||
|
||||
COPY --chmod=755 docker/dev/etc/s6-overlay/ /etc/s6-overlay/
|
||||
|
||||
COPY docker/dev/nginx.conf /etc/nginx/conf.d/custom.conf
|
||||
|
||||
RUN echo "alias ll='ls -al'" >>/etc/bash.bashrc && \
|
||||
echo "alias a='php artisan'" >>/etc/bash.bashrc
|
||||
|
||||
RUN mkdir -p /usr/local/bin
|
||||
|
||||
RUN --mount=type=cache,target=/root/.cache \
|
||||
/bin/bash -c "if [[ ${TARGETPLATFORM} == 'linux/amd64' ]]; then \
|
||||
echo 'amd64' && \
|
||||
curl -sSL https://github.com/cloudflare/cloudflared/releases/download/${CLOUDFLARED_VERSION}/cloudflared-linux-amd64 -o /usr/local/bin/cloudflared && chmod +x /usr/local/bin/cloudflared \
|
||||
;fi"
|
||||
|
||||
RUN --mount=type=cache,target=/root/.cache \
|
||||
/bin/bash -c "if [[ ${TARGETPLATFORM} == 'linux/arm64' ]]; then \
|
||||
echo 'arm64' && \
|
||||
curl -L https://github.com/cloudflare/cloudflared/releases/download/${CLOUDFLARED_VERSION}/cloudflared-linux-arm64 -o /usr/local/bin/cloudflared && chmod +x /usr/local/bin/cloudflared \
|
||||
;fi"
|
||||
|
||||
COPY --from=minio-client /usr/bin/mc /usr/bin/mc
|
||||
RUN chmod +x /usr/bin/mc
|
||||
|
||||
RUN { \
|
||||
echo 'upload_max_filesize=256M'; \
|
||||
echo 'post_max_size=256M'; \
|
||||
} > /etc/php/current_version/cli/conf.d/upload-limits.ini
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/command/execlineb -P
|
||||
foreground {
|
||||
s6-sleep 5
|
||||
su - webuser -c "php /var/www/html/artisan start:horizon"
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/command/execlineb -P
|
||||
foreground { composer -d /var/www/html/ install }
|
||||
foreground { php /var/www/html/artisan migrate --step }
|
||||
foreground { php /var/www/html/artisan dev --init }
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/command/execlineb -P
|
||||
foreground {
|
||||
s6-sleep 5
|
||||
su - webuser -c "php /var/www/html/artisan start:scheduler"
|
||||
}
|
||||
81
docker/development/Dockerfile
Normal file
81
docker/development/Dockerfile
Normal file
@@ -0,0 +1,81 @@
|
||||
# Versions
|
||||
# https://hub.docker.com/r/serversideup/php/tags?name=8.4-fpm-nginx-alpine
|
||||
ARG SERVERSIDEUP_PHP_VERSION=8.4-fpm-nginx-alpine
|
||||
# https://github.com/minio/mc/releases
|
||||
ARG MINIO_VERSION=RELEASE.2024-11-05T11-29-45Z
|
||||
# https://github.com/cloudflare/cloudflared/releases
|
||||
ARG CLOUDFLARED_VERSION=2024.11.0
|
||||
# https://www.postgresql.org/support/versioning/ - Upgraded to 16 if the we have a manual upgrade guide?
|
||||
ARG POSTGRES_VERSION=15
|
||||
|
||||
# =================================================================
|
||||
# Get MinIO client
|
||||
# =================================================================
|
||||
FROM minio/mc:${MINIO_VERSION} AS minio-client
|
||||
|
||||
# =================================================================
|
||||
# Final Stage: Production image
|
||||
# =================================================================
|
||||
FROM serversideup/php:${SERVERSIDEUP_PHP_VERSION}
|
||||
|
||||
ARG USER_ID
|
||||
ARG GROUP_ID
|
||||
ARG TARGETPLATFORM
|
||||
ARG POSTGRES_VERSION
|
||||
ARG CLOUDFLARED_VERSION
|
||||
|
||||
WORKDIR /var/www/html
|
||||
|
||||
USER root
|
||||
|
||||
RUN docker-php-serversideup-set-id www-data $USER_ID:$GROUP_ID && \
|
||||
docker-php-serversideup-set-file-permissions --owner $USER_ID:$GROUP_ID --service nginx
|
||||
|
||||
# Install PostgreSQL repository and keys
|
||||
RUN apk add --no-cache gnupg && \
|
||||
mkdir -p /usr/share/keyrings && \
|
||||
curl -fSsL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor > /usr/share/keyrings/postgresql.gpg
|
||||
|
||||
# Install system dependencies
|
||||
RUN apk add --no-cache \
|
||||
postgresql${POSTGRES_VERSION}-client \
|
||||
openssh-client \
|
||||
git \
|
||||
git-lfs \
|
||||
jq \
|
||||
lsof \
|
||||
vim
|
||||
|
||||
# Configure shell aliases
|
||||
RUN echo "alias ll='ls -al'" >> /etc/profile && \
|
||||
echo "alias a='php artisan'" >> /etc/profile && \
|
||||
echo "alias logs='tail -f storage/logs/laravel.log'" >> /etc/profile
|
||||
|
||||
# Install Cloudflared based on architecture
|
||||
RUN mkdir -p /usr/local/bin && \
|
||||
if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \
|
||||
curl -sSL "https://github.com/cloudflare/cloudflared/releases/download/${CLOUDFLARED_VERSION}/cloudflared-linux-amd64" -o /usr/local/bin/cloudflared; \
|
||||
elif [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \
|
||||
curl -sSL "https://github.com/cloudflare/cloudflared/releases/download/${CLOUDFLARED_VERSION}/cloudflared-linux-arm64" -o /usr/local/bin/cloudflared; \
|
||||
fi && \
|
||||
chmod +x /usr/local/bin/cloudflared
|
||||
|
||||
# Configure PHP
|
||||
COPY docker/development/etc/php/conf.d/zzz-custom-php.ini /usr/local/etc/php/conf.d/zzz-custom-php.ini
|
||||
ENV PHP_OPCACHE_ENABLE=0
|
||||
|
||||
# Configure Nginx and S6 overlay
|
||||
COPY docker/development/etc/nginx/conf.d/custom.conf /etc/nginx/conf.d/custom.conf
|
||||
COPY docker/development/etc/nginx/site-opts.d/http.conf /etc/nginx/site-opts.d/http.conf
|
||||
COPY --chmod=755 docker/development/etc/s6-overlay/ /etc/s6-overlay/
|
||||
|
||||
RUN mkdir -p /etc/nginx/conf.d && \
|
||||
chown -R www-data:www-data /etc/nginx && \
|
||||
chmod -R 755 /etc/nginx
|
||||
|
||||
# Install MinIO client
|
||||
COPY --from=minio-client /usr/bin/mc /usr/bin/mc
|
||||
RUN chmod +x /usr/bin/mc
|
||||
|
||||
# Switch to non-root user
|
||||
USER www-data
|
||||
45
docker/development/etc/nginx/site-opts.d/http.conf
Normal file
45
docker/development/etc/nginx/site-opts.d/http.conf
Normal file
@@ -0,0 +1,45 @@
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
listen 8080 default_server;
|
||||
listen [::]:8080 default_server;
|
||||
|
||||
root /var/www/html/public;
|
||||
|
||||
# Set allowed "index" files
|
||||
index index.html index.htm index.php;
|
||||
|
||||
server_name _;
|
||||
|
||||
charset utf-8;
|
||||
|
||||
# Set max upload to 2048M
|
||||
client_max_body_size 2048M;
|
||||
|
||||
# Healthchecks: Set /healthcheck to be the healthcheck URL
|
||||
location /healthcheck {
|
||||
access_log off;
|
||||
|
||||
# set max 5 seconds for healthcheck
|
||||
fastcgi_read_timeout 5s;
|
||||
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_NAME /healthcheck;
|
||||
fastcgi_param SCRIPT_FILENAME /healthcheck;
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
}
|
||||
|
||||
# Have NGINX try searching for PHP files as well
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
# Pass "*.php" files to PHP-FPM
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
fastcgi_buffers 8 8k;
|
||||
fastcgi_buffer_size 8k;
|
||||
fastcgi_read_timeout 99;
|
||||
}
|
||||
9
docker/development/etc/php/conf.d/zzz-custom-php.ini
Normal file
9
docker/development/etc/php/conf.d/zzz-custom-php.ini
Normal file
@@ -0,0 +1,9 @@
|
||||
error_reporting = E_ERROR
|
||||
error_log = /dev/stderr
|
||||
log_errors = On
|
||||
log_errors_max_len = 8192
|
||||
ignore_repeated_errors = On
|
||||
ignore_repeated_source = On
|
||||
|
||||
upload_max_filesize = 256M
|
||||
post_max_size = 256M
|
||||
12
docker/development/etc/s6-overlay/s6-rc.d/horizon/run
Normal file
12
docker/development/etc/s6-overlay/s6-rc.d/horizon/run
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/command/execlineb -P
|
||||
|
||||
# Use with-contenv to ensure environment variables are available
|
||||
with-contenv
|
||||
cd /var/www/html
|
||||
|
||||
foreground {
|
||||
php
|
||||
artisan
|
||||
start:horizon
|
||||
}
|
||||
|
||||
22
docker/development/etc/s6-overlay/s6-rc.d/init-setup/up
Normal file
22
docker/development/etc/s6-overlay/s6-rc.d/init-setup/up
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/command/execlineb -P
|
||||
|
||||
# Use with-contenv to ensure environment variables are available
|
||||
with-contenv
|
||||
cd /var/www/html
|
||||
foreground {
|
||||
composer
|
||||
install
|
||||
}
|
||||
foreground {
|
||||
php
|
||||
artisan
|
||||
migrate
|
||||
--step
|
||||
}
|
||||
foreground {
|
||||
php
|
||||
artisan
|
||||
dev
|
||||
--init
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#!/command/execlineb -P
|
||||
|
||||
# Use with-contenv to ensure environment variables are available
|
||||
with-contenv
|
||||
cd /var/www/html
|
||||
|
||||
foreground {
|
||||
php
|
||||
artisan
|
||||
start:scheduler
|
||||
}
|
||||
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
# Versions
|
||||
# https://hub.docker.com/r/serversideup/php/tags?name=8.3-fpm-nginx-alpine
|
||||
ARG SERVERSIDEUP_PHP_VERSION=8.2-fpm-nginx-v2.2.1
|
||||
# https://github.com/minio/mc/releases
|
||||
ARG MINIO_VERSION=RELEASE.2024-11-05T11-29-45Z
|
||||
# https://github.com/cloudflare/cloudflared/releases
|
||||
ARG CLOUDFLARED_VERSION=2024.11.0
|
||||
# https://www.postgresql.org/support/versioning/ - Can not updated automatically so keep it at 15
|
||||
ARG POSTGRES_VERSION=15
|
||||
|
||||
|
||||
FROM serversideup/php:${SERVERSIDEUP_PHP_VERSION} AS base
|
||||
WORKDIR /var/www/html
|
||||
|
||||
COPY composer.json composer.lock ./
|
||||
RUN composer install --no-dev --no-interaction --no-plugins --no-scripts --prefer-dist
|
||||
|
||||
FROM node:20 AS static-assets
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
COPY --from=base --chown=9999:9999 /var/www/html .
|
||||
RUN npm install
|
||||
RUN npm run build
|
||||
|
||||
FROM minio/mc:${MINIO_VERSION} AS minio-client
|
||||
|
||||
FROM serversideup/php:${SERVERSIDEUP_PHP_VERSION}
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
ARG CLOUDFLARED_VERSION
|
||||
ARG POSTGRES_VERSION
|
||||
ARG CI=true
|
||||
|
||||
WORKDIR /var/www/html
|
||||
|
||||
RUN apt-get update
|
||||
# Postgres version requirements
|
||||
RUN apt install dirmngr ca-certificates software-properties-common gnupg gnupg2 apt-transport-https curl -y
|
||||
RUN curl -fSsL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /usr/share/keyrings/postgresql.gpg > /dev/null
|
||||
|
||||
RUN echo deb [arch=amd64,arm64,ppc64el signed-by=/usr/share/keyrings/postgresql.gpg] http://apt.postgresql.org/pub/repos/apt/ jammy-pgdg main | tee -a /etc/apt/sources.list.d/postgresql.list
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt-get install postgresql-client-${POSTGRES_VERSION} -y
|
||||
|
||||
# Coolify requirements
|
||||
RUN apt-get install -y php8.2-pgsql openssh-client git git-lfs jq lsof vim
|
||||
RUN apt-get -y autoremove && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
|
||||
|
||||
COPY docker/prod/nginx.conf /etc/nginx/conf.d/custom.conf
|
||||
|
||||
COPY --from=base --chown=9999:9999 /var/www/html .
|
||||
|
||||
COPY --chown=9999:9999 . .
|
||||
RUN composer dump-autoload
|
||||
|
||||
COPY --from=static-assets --chown=9999:9999 /app/public/build ./public/build
|
||||
COPY --chmod=755 docker/prod/etc/s6-overlay/ /etc/s6-overlay/
|
||||
|
||||
RUN echo "alias ll='ls -al'" >>/etc/bash.bashrc
|
||||
RUN echo "alias a='php artisan'" >>/etc/bash.bashrc
|
||||
RUN echo "alias logs='tail -f storage/logs/laravel.log'" >>/etc/bash.bashrc
|
||||
|
||||
RUN mkdir -p /usr/local/bin
|
||||
|
||||
RUN /bin/bash -c "if [[ ${TARGETPLATFORM} == 'linux/amd64' ]]; then \
|
||||
echo 'amd64' && \
|
||||
curl -sSL https://github.com/cloudflare/cloudflared/releases/download/${CLOUDFLARED_VERSION}/cloudflared-linux-amd64 -o /usr/local/bin/cloudflared && chmod +x /usr/local/bin/cloudflared \
|
||||
;fi"
|
||||
|
||||
RUN /bin/bash -c "if [[ ${TARGETPLATFORM} == 'linux/arm64' ]]; then \
|
||||
echo 'arm64' && \
|
||||
curl -L https://github.com/cloudflare/cloudflared/releases/download/${CLOUDFLARED_VERSION}/cloudflared-linux-arm64 -o /usr/local/bin/cloudflared && chmod +x /usr/local/bin/cloudflared \
|
||||
;fi"
|
||||
|
||||
RUN { \
|
||||
echo 'upload_max_filesize=256M'; \
|
||||
echo 'post_max_size=256M'; \
|
||||
} > /etc/php/current_version/cli/conf.d/upload-limits.ini
|
||||
|
||||
COPY --from=minio-client /usr/bin/mc /usr/bin/mc
|
||||
RUN chmod +x /usr/bin/mc
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/command/execlineb -P
|
||||
php /var/www/html/artisan migrate --force --isolated
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/command/execlineb -P
|
||||
foreground {
|
||||
s6-sleep 5
|
||||
su - webuser -c "php /var/www/html/artisan start:horizon"
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/command/execlineb -P
|
||||
s6-setuidgid webuser
|
||||
php /var/www/html/artisan app:init
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/command/execlineb -P
|
||||
php /var/www/html/artisan db:seed --class ProductionSeeder --force
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/command/execlineb -P
|
||||
foreground {
|
||||
s6-sleep 5
|
||||
su - webuser -c "php /var/www/html/artisan start:scheduler"
|
||||
}
|
||||
136
docker/production/Dockerfile
Normal file
136
docker/production/Dockerfile
Normal file
@@ -0,0 +1,136 @@
|
||||
# Versions
|
||||
# https://hub.docker.com/r/serversideup/php/tags?name=8.4-fpm-nginx-alpine
|
||||
ARG SERVERSIDEUP_PHP_VERSION=8.4-fpm-nginx-alpine
|
||||
# https://github.com/minio/mc/releases
|
||||
ARG MINIO_VERSION=RELEASE.2024-11-05T11-29-45Z
|
||||
# https://github.com/cloudflare/cloudflared/releases
|
||||
ARG CLOUDFLARED_VERSION=2024.11.0
|
||||
# https://www.postgresql.org/support/versioning/ - Upgraded to 16 if the we have a manual upgrade guide?
|
||||
ARG POSTGRES_VERSION=15
|
||||
|
||||
# Add user/group
|
||||
ARG USER_ID=9999
|
||||
ARG GROUP_ID=9999
|
||||
|
||||
# =================================================================
|
||||
# Stage 1: Composer dependencies
|
||||
# =================================================================
|
||||
FROM serversideup/php:${SERVERSIDEUP_PHP_VERSION} AS base
|
||||
|
||||
USER root
|
||||
|
||||
ARG USER_ID
|
||||
ARG GROUP_ID
|
||||
|
||||
RUN docker-php-serversideup-set-id www-data $USER_ID:$GROUP_ID && \
|
||||
docker-php-serversideup-set-file-permissions --owner $USER_ID:$GROUP_ID --service nginx
|
||||
|
||||
WORKDIR /var/www/html
|
||||
COPY --chown=www-data:www-data composer.json composer.lock ./
|
||||
RUN composer install --no-dev --no-interaction --no-plugins --no-scripts --prefer-dist
|
||||
|
||||
USER www-data
|
||||
|
||||
# =================================================================
|
||||
# Stage 2: Frontend assets compilation
|
||||
# =================================================================
|
||||
FROM node:20-alpine AS static-assets
|
||||
|
||||
WORKDIR /app
|
||||
COPY package*.json vite.config.js tailwind.config.js postcss.config.cjs ./
|
||||
RUN npm ci
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
# =================================================================
|
||||
# Stage 3: Get MinIO client
|
||||
# =================================================================
|
||||
FROM minio/mc:${MINIO_VERSION} AS minio-client
|
||||
|
||||
# =================================================================
|
||||
# Final Stage: Production image
|
||||
# =================================================================
|
||||
FROM serversideup/php:${SERVERSIDEUP_PHP_VERSION}
|
||||
|
||||
ARG USER_ID
|
||||
ARG GROUP_ID
|
||||
ARG TARGETPLATFORM
|
||||
ARG POSTGRES_VERSION
|
||||
ARG CLOUDFLARED_VERSION
|
||||
ARG CI=true
|
||||
|
||||
WORKDIR /var/www/html
|
||||
|
||||
USER root
|
||||
|
||||
RUN docker-php-serversideup-set-id www-data $USER_ID:$GROUP_ID && \
|
||||
docker-php-serversideup-set-file-permissions --owner $USER_ID:$GROUP_ID --service nginx
|
||||
|
||||
# Install PostgreSQL repository and keys
|
||||
RUN apk add --no-cache gnupg && \
|
||||
mkdir -p /usr/share/keyrings && \
|
||||
curl -fSsL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor > /usr/share/keyrings/postgresql.gpg
|
||||
|
||||
# Install system dependencies
|
||||
RUN apk add --no-cache \
|
||||
postgresql${POSTGRES_VERSION}-client \
|
||||
openssh-client \
|
||||
git \
|
||||
git-lfs \
|
||||
jq \
|
||||
lsof \
|
||||
vim
|
||||
|
||||
# Configure shell aliases
|
||||
RUN echo "alias ll='ls -al'" >> /etc/profile && \
|
||||
echo "alias a='php artisan'" >> /etc/profile && \
|
||||
echo "alias logs='tail -f storage/logs/laravel.log'" >> /etc/profile
|
||||
|
||||
# Install Cloudflared based on architecture
|
||||
RUN mkdir -p /usr/local/bin && \
|
||||
if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \
|
||||
curl -sSL "https://github.com/cloudflare/cloudflared/releases/download/${CLOUDFLARED_VERSION}/cloudflared-linux-amd64" -o /usr/local/bin/cloudflared; \
|
||||
elif [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \
|
||||
curl -sSL "https://github.com/cloudflare/cloudflared/releases/download/${CLOUDFLARED_VERSION}/cloudflared-linux-arm64" -o /usr/local/bin/cloudflared; \
|
||||
fi && \
|
||||
chmod +x /usr/local/bin/cloudflared
|
||||
|
||||
# Configure PHP
|
||||
COPY docker/production/etc/php/conf.d/zzz-custom-php.ini /usr/local/etc/php/conf.d/zzz-custom-php.ini
|
||||
ENV PHP_OPCACHE_ENABLE=1
|
||||
|
||||
# Copy application files from previous stages
|
||||
COPY --from=base --chown=www-data:www-data /var/www/html/vendor ./vendor
|
||||
COPY --from=static-assets --chown=www-data:www-data /app/public/build ./public/build
|
||||
|
||||
# Copy application source code
|
||||
COPY --chown=www-data:www-data composer.json composer.lock ./
|
||||
COPY --chown=www-data:www-data app ./app
|
||||
COPY --chown=www-data:www-data bootstrap ./bootstrap
|
||||
COPY --chown=www-data:www-data config ./config
|
||||
COPY --chown=www-data:www-data database ./database
|
||||
COPY --chown=www-data:www-data lang ./lang
|
||||
COPY --chown=www-data:www-data public ./public
|
||||
COPY --chown=www-data:www-data routes ./routes
|
||||
COPY --chown=www-data:www-data storage ./storage
|
||||
COPY --chown=www-data:www-data templates ./templates
|
||||
COPY --chown=www-data:www-data resources/views ./resources/views
|
||||
COPY --chown=www-data:www-data artisan artisan
|
||||
|
||||
RUN composer dump-autoload
|
||||
|
||||
# Configure Nginx and S6 overlay
|
||||
COPY docker/production/etc/nginx/conf.d/custom.conf /etc/nginx/conf.d/custom.conf
|
||||
COPY docker/production/etc/nginx/site-opts.d/http.conf /etc/nginx/site-opts.d/http.conf
|
||||
COPY --chmod=755 docker/production/etc/s6-overlay/ /etc/s6-overlay/
|
||||
|
||||
RUN mkdir -p /etc/nginx/conf.d && \
|
||||
chown -R www-data:www-data /etc/nginx && \
|
||||
chmod -R 755 /etc/nginx
|
||||
|
||||
# Install MinIO client
|
||||
COPY --from=minio-client /usr/bin/mc /usr/bin/mc
|
||||
RUN chmod +x /usr/bin/mc
|
||||
|
||||
# Switch to non-root user
|
||||
USER www-data
|
||||
45
docker/production/etc/nginx/site-opts.d/http.conf
Normal file
45
docker/production/etc/nginx/site-opts.d/http.conf
Normal file
@@ -0,0 +1,45 @@
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
listen 8080 default_server;
|
||||
listen [::]:8080 default_server;
|
||||
|
||||
root /var/www/html/public;
|
||||
|
||||
# Set allowed "index" files
|
||||
index index.html index.htm index.php;
|
||||
|
||||
server_name _;
|
||||
|
||||
charset utf-8;
|
||||
|
||||
# Set max upload to 2048M
|
||||
client_max_body_size 2048M;
|
||||
|
||||
# Healthchecks: Set /healthcheck to be the healthcheck URL
|
||||
location /healthcheck {
|
||||
access_log off;
|
||||
|
||||
# set max 5 seconds for healthcheck
|
||||
fastcgi_read_timeout 5s;
|
||||
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_NAME /healthcheck;
|
||||
fastcgi_param SCRIPT_FILENAME /healthcheck;
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
}
|
||||
|
||||
# Have NGINX try searching for PHP files as well
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
# Pass "*.php" files to PHP-FPM
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
fastcgi_buffers 8 8k;
|
||||
fastcgi_buffer_size 8k;
|
||||
fastcgi_read_timeout 99;
|
||||
}
|
||||
9
docker/production/etc/php/conf.d/zzz-custom-php.ini
Normal file
9
docker/production/etc/php/conf.d/zzz-custom-php.ini
Normal file
@@ -0,0 +1,9 @@
|
||||
error_reporting = E_ERROR
|
||||
error_log = /var/www/html/storage/logs/php-error.log
|
||||
log_errors = Off
|
||||
log_errors_max_len = 8192
|
||||
ignore_repeated_errors = On
|
||||
ignore_repeated_source = On
|
||||
|
||||
upload_max_filesize = 256M
|
||||
post_max_size = 256M
|
||||
13
docker/production/etc/s6-overlay/s6-rc.d/db-migration/up
Normal file
13
docker/production/etc/s6-overlay/s6-rc.d/db-migration/up
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/command/execlineb -P
|
||||
|
||||
# Use with-contenv to ensure environment variables are available
|
||||
with-contenv
|
||||
cd /var/www/html
|
||||
foreground {
|
||||
php
|
||||
artisan
|
||||
migrate
|
||||
--force
|
||||
--isolated
|
||||
}
|
||||
|
||||
11
docker/production/etc/s6-overlay/s6-rc.d/horizon/run
Normal file
11
docker/production/etc/s6-overlay/s6-rc.d/horizon/run
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/command/execlineb -P
|
||||
|
||||
# Use with-contenv to ensure environment variables are available
|
||||
with-contenv
|
||||
cd /var/www/html
|
||||
foreground {
|
||||
php
|
||||
artisan
|
||||
start:horizon
|
||||
}
|
||||
|
||||
12
docker/production/etc/s6-overlay/s6-rc.d/init-script/up
Normal file
12
docker/production/etc/s6-overlay/s6-rc.d/init-script/up
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/command/execlineb -P
|
||||
|
||||
# Use with-contenv to ensure environment variables are available
|
||||
with-contenv
|
||||
cd /var/www/html
|
||||
foreground {
|
||||
php
|
||||
artisan
|
||||
app:init
|
||||
}
|
||||
|
||||
|
||||
15
docker/production/etc/s6-overlay/s6-rc.d/init-seeder/up
Normal file
15
docker/production/etc/s6-overlay/s6-rc.d/init-seeder/up
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/command/execlineb -P
|
||||
|
||||
# Use with-contenv to ensure environment variables are available
|
||||
with-contenv
|
||||
cd /var/www/html
|
||||
foreground {
|
||||
php
|
||||
artisan
|
||||
db:seed
|
||||
--class
|
||||
ProductionSeeder
|
||||
--force
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#!/command/execlineb -P
|
||||
|
||||
# Use with-contenv to ensure environment variables are available
|
||||
with-contenv
|
||||
cd /var/www/html
|
||||
foreground {
|
||||
php
|
||||
artisan
|
||||
start:scheduler
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user