Skip to content
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
22 changes: 22 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.git
.github
.gitignore
.env
.env.example
.editorconfig
node_modules
vendor
storage/logs/*
storage/framework/cache/*
storage/framework/sessions/*
storage/framework/views/*
bootstrap/cache/*
docker
tests
phpunit.xml
README.md
*.md
.vscode
.idea
.DS_Store
Thumbs.db
60 changes: 60 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Docker Publish

on:
push:
branches:
- master
tags:
- "v*.*.*"
pull_request:
branches:
- master

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix=sha-
type=raw,value=latest,enable={{is_default_branch}}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
42 changes: 42 additions & 0 deletions .rr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: "3"

server:
command: "php artisan octane:start --server=roadrunner --host=0.0.0.0 --port=8080 --workers=auto --max-requests=1000 --rpc-port=6001"
relay: pipes

http:
address: "0.0.0.0:8080"
middleware:
- gzip
- static
static:
dir: "/var/www/html/public"
forbid:
- ".php"
- ".htaccess"
response:
X-Request-ID: ""
pool:
num_workers: 0
max_jobs: 1000
allocate_timeout: 60s
destroy_timeout: 60s
supervisor:
max_worker_memory: 128

logs:
mode: production
level: warn
encoding: json
output: stderr

status:
address: "0.0.0.0:2114"

reload:
interval: 1s
patterns: [".php"]
services:
http:
recursive: true
dirs: ["/var/www/html"]
100 changes: 100 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Stage 1 — Frontend Build
FROM node:20-alpine AS frontend

WORKDIR /app

COPY package.json package-lock.json* yarn.lock* ./

RUN if [ -f yarn.lock ]; then \
yarn install --frozen-lockfile; \
elif [ -f package-lock.json ]; then \
npm ci; \
else \
npm install; \
fi

COPY resources/ resources/
COPY vite.config.js ./
COPY postcss.config.js* ./
COPY tailwind.config.js* ./

RUN npm run build

# Stage 2 — Composer Dependencies
FROM composer:2 AS composer

WORKDIR /app

COPY composer.json composer.lock ./
RUN composer install --no-dev --no-interaction --no-scripts --no-autoloader --prefer-dist --ignore-platform-reqs

COPY . .
RUN composer dump-autoload --optimize --no-dev --ignore-platform-reqs

# Stage 3 — RoadRunner Binary
FROM ghcr.io/roadrunner-server/roadrunner:2024 AS roadrunner

# Stage 4 — Production Image
FROM php:8.3-cli-alpine AS production

LABEL maintainer="codenteq" \
org.opencontainers.image.source="https://github.com/codenteq/eventeq" \
org.opencontainers.image.description="Eventeq production image"

ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/

RUN apk add --no-cache wget imagemagick \
&& install-php-extensions \
pdo_mysql \
pdo_pgsql \
pgsql \
gd \
zip \
bcmath \
intl \
xml \
mbstring \
soap \
pcntl \
sockets \
opcache \
redis \
imagick

RUN cp "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

RUN { \
echo "memory_limit=256M"; \
echo "upload_max_filesize=64M"; \
echo "post_max_size=64M"; \
echo "max_execution_time=120"; \
echo "opcache.enable=1"; \
echo "opcache.validate_timestamps=0"; \
} > "$PHP_INI_DIR/conf.d/app.ini"

WORKDIR /var/www/html

COPY --from=roadrunner /usr/bin/rr /usr/local/bin/rr
COPY --from=composer /app/vendor ./vendor
COPY --from=composer /app .
COPY --from=frontend /app/public/build ./public/build

RUN mkdir -p \
storage/logs \
storage/framework/sessions \
storage/framework/views \
storage/framework/cache/data \
bootstrap/cache \
&& chown -R www-data:www-data storage bootstrap/cache \
&& chmod -R 775 storage bootstrap/cache

COPY .rr.yaml .

EXPOSE 8080

HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD wget -qO- http://localhost:8080/up || exit 1

USER www-data

CMD ["sh", "-c", "php artisan config:cache && php artisan route:cache && php artisan view:cache && php artisan migrate --force && rr serve -c /var/www/html/.rr.yaml"]
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"filament/filament": "^3.2",
"inertiajs/inertia-laravel": "^1.2",
"laravel/framework": "^11.9",
"laravel/octane": "^2.0",
"laravel/pulse": "^1.4",
"laravel/tinker": "^2.9",
"maatwebsite/excel": "^3.1",
Expand Down
Loading