added docker-compose file for production
This commit is contained in:
parent
ec6d7e2a80
commit
b532c51c32
42
.dockerignore
Normal file
42
.dockerignore
Normal file
@ -0,0 +1,42 @@
|
||||
.git
|
||||
.gitattributes
|
||||
.github
|
||||
|
||||
.env
|
||||
.env.*
|
||||
auth.json
|
||||
|
||||
node_modules
|
||||
vendor
|
||||
|
||||
public/build
|
||||
public/hot
|
||||
public/storage
|
||||
|
||||
storage/*.key
|
||||
storage/app/*
|
||||
storage/framework/cache/*
|
||||
storage/framework/sessions/*
|
||||
storage/framework/testing/*
|
||||
storage/framework/views/*
|
||||
storage/logs/*
|
||||
storage/pail
|
||||
!storage/app/.gitignore
|
||||
!storage/framework/**/.gitignore
|
||||
!storage/logs/.gitignore
|
||||
|
||||
database/database.sqlite
|
||||
|
||||
tests
|
||||
.phpunit.cache
|
||||
.phpunit.result.cache
|
||||
|
||||
.devcontainer
|
||||
.claude
|
||||
.idea
|
||||
.vscode
|
||||
.fleet
|
||||
.zed
|
||||
|
||||
docker-compose.yml
|
||||
Dockerfile
|
||||
54
Dockerfile
Normal file
54
Dockerfile
Normal file
@ -0,0 +1,54 @@
|
||||
# syntax=docker/dockerfile:1.7
|
||||
ARG PHP_VERSION=8.5
|
||||
|
||||
# --- frontend assets -------------------------------------------------------
|
||||
FROM node:22-alpine AS frontend
|
||||
WORKDIR /app
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci
|
||||
COPY vite.config.js ./
|
||||
COPY resources ./resources
|
||||
RUN npm run build
|
||||
|
||||
# --- application -------------------------------------------------------
|
||||
FROM php:${PHP_VERSION}-apache AS app
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
libsqlite3-dev \
|
||||
libicu-dev \
|
||||
libzip-dev \
|
||||
unzip \
|
||||
git \
|
||||
curl \
|
||||
&& docker-php-ext-install \
|
||||
pdo_sqlite \
|
||||
intl \
|
||||
zip \
|
||||
bcmath \
|
||||
pcntl \
|
||||
opcache \
|
||||
&& a2enmod rewrite \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
||||
|
||||
COPY docker/apache/000-default.conf /etc/apache2/sites-available/000-default.conf
|
||||
COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||
|
||||
WORKDIR /var/www/html
|
||||
|
||||
COPY . .
|
||||
COPY --from=frontend /app/public/build ./public/build
|
||||
|
||||
# auth.json holds the Filament composer repository credentials; it's
|
||||
# gitignored and must never end up baked into an image layer, so it's
|
||||
# supplied as a BuildKit secret and mounted only for this RUN step.
|
||||
RUN --mount=type=secret,id=composer_auth,target=/var/www/html/auth.json \
|
||||
composer install --no-dev --no-interaction --no-progress --optimize-autoloader
|
||||
|
||||
RUN mkdir -p storage/app storage/framework/cache storage/framework/sessions storage/framework/views storage/logs bootstrap/cache \
|
||||
&& chown -R www-data:www-data storage bootstrap/cache
|
||||
|
||||
ENTRYPOINT ["entrypoint.sh"]
|
||||
CMD ["apache2-foreground"]
|
||||
41
docker-compose.yml
Normal file
41
docker-compose.yml
Normal file
@ -0,0 +1,41 @@
|
||||
x-app: &app
|
||||
image: z-lab-cockpit:latest
|
||||
env_file: .env
|
||||
# environment:
|
||||
# DB_CONNECTION: sqlite
|
||||
# DB_DATABASE: /var/www/html/storage/app/database.sqlite
|
||||
volumes:
|
||||
- ./storage:/var/www/html/storage
|
||||
depends_on:
|
||||
app:
|
||||
condition: service_healthy
|
||||
restart: unless-stopped
|
||||
|
||||
services:
|
||||
app:
|
||||
<<: *app
|
||||
build:
|
||||
context: .
|
||||
secrets:
|
||||
- composer_auth
|
||||
depends_on: []
|
||||
ports:
|
||||
- "8000:80"
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost/up"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
start_period: 30s
|
||||
|
||||
queue:
|
||||
<<: *app
|
||||
command: ["php", "artisan", "queue:work", "--tries=3", "--backoff=10"]
|
||||
|
||||
scheduler:
|
||||
<<: *app
|
||||
command: ["php", "artisan", "schedule:work"]
|
||||
|
||||
secrets:
|
||||
composer_auth:
|
||||
file: ./auth.json
|
||||
12
docker/apache/000-default.conf
Normal file
12
docker/apache/000-default.conf
Normal file
@ -0,0 +1,12 @@
|
||||
<VirtualHost *:80>
|
||||
DocumentRoot /var/www/html/public
|
||||
|
||||
<Directory /var/www/html/public>
|
||||
Options -Indexes +FollowSymLinks
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
||||
ErrorLog ${APACHE_LOG_DIR}/error.log
|
||||
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
||||
</VirtualHost>
|
||||
23
docker/entrypoint.sh
Normal file
23
docker/entrypoint.sh
Normal file
@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
cd /var/www/html
|
||||
|
||||
mkdir -p storage/app storage/framework/cache storage/framework/sessions storage/framework/views storage/logs bootstrap/cache
|
||||
chown -R www-data:www-data storage bootstrap/cache
|
||||
|
||||
if [ -n "$DB_DATABASE" ] && [ "$DB_CONNECTION" = "sqlite" ]; then
|
||||
mkdir -p "$(dirname "$DB_DATABASE")"
|
||||
touch -a "$DB_DATABASE"
|
||||
chown www-data:www-data "$DB_DATABASE"
|
||||
fi
|
||||
|
||||
# Only the web process runs bootstrap steps, so the queue/scheduler
|
||||
# containers (which override CMD) don't race each other on migrations.
|
||||
if [ "$1" = "apache2-foreground" ]; then
|
||||
php artisan config:clear
|
||||
php artisan migrate --force
|
||||
php artisan storage:link || true
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
Loading…
Reference in New Issue
Block a user