mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 15:07:49 +00:00
ci: optimize docker build
chore: update docker
This commit is contained in:
parent
295b2e45bd
commit
1f0771a19c
2 changed files with 64 additions and 42 deletions
53
.github/workflows/docker-build.yml
vendored
Normal file
53
.github/workflows/docker-build.yml
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
name: Build and Push Docker Images
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: ghcr.io
|
||||||
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Log in to GitHub Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract metadata for Docker
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
tags: |
|
||||||
|
type=ref,event=tag
|
||||||
|
latest
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
cache-from: type=registry,ref=user/app:buildcache
|
||||||
|
cache-to: type=registry,ref=user/app:buildcache,mode=max
|
||||||
53
Dockerfile
53
Dockerfile
|
|
@ -1,37 +1,4 @@
|
||||||
FROM php:8.3-fpm-alpine3.20
|
FROM bnussbau/php:8.3-fpm-opcache-imagick-puppeteer-alpine3.20
|
||||||
|
|
||||||
# Install system dependencies
|
|
||||||
RUN apk add --no-cache \
|
|
||||||
nginx \
|
|
||||||
supervisor \
|
|
||||||
libpq \
|
|
||||||
nodejs \
|
|
||||||
npm \
|
|
||||||
git \
|
|
||||||
curl \
|
|
||||||
zip \
|
|
||||||
unzip \
|
|
||||||
imagemagick-dev \
|
|
||||||
chromium
|
|
||||||
|
|
||||||
# Configure Chromium Path
|
|
||||||
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
|
|
||||||
ENV PUPPETEER_DOCKER=1
|
|
||||||
|
|
||||||
#RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS imagemagick-dev \
|
|
||||||
#&& pecl install imagick \
|
|
||||||
#&& docker-php-ext-enable imagick \
|
|
||||||
#&& apk del .build-deps \
|
|
||||||
|
|
||||||
#RUN docker-php-ext-install imagick \
|
|
||||||
# && docker-php-ext-enable imagick
|
|
||||||
|
|
||||||
RUN mkdir -p /usr/src/php/ext/imagick
|
|
||||||
RUN chmod 777 /usr/src/php/ext/imagick
|
|
||||||
RUN curl -fsSL https://github.com/Imagick/imagick/archive/refs/tags/3.7.0.tar.gz | tar xvz -C "/usr/src/php/ext/imagick" --strip 1
|
|
||||||
|
|
||||||
# Install PHP extensions
|
|
||||||
RUN docker-php-ext-install opcache imagick
|
|
||||||
|
|
||||||
# Install composer
|
# Install composer
|
||||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||||
|
|
@ -39,14 +6,6 @@ COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /var/www/html
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
# Copy application files
|
|
||||||
COPY --chown=www-data:www-data . .
|
|
||||||
COPY --chown=www-data:www-data ./.env.example ./.env
|
|
||||||
|
|
||||||
# Install application dependencies
|
|
||||||
RUN composer install --no-interaction --prefer-dist --optimize-autoloader
|
|
||||||
RUN npm install && npm run build
|
|
||||||
|
|
||||||
# Copy configuration files
|
# Copy configuration files
|
||||||
COPY docker/nginx.conf /etc/nginx/http.d/default.conf
|
COPY docker/nginx.conf /etc/nginx/http.d/default.conf
|
||||||
COPY docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
COPY docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||||
|
|
@ -57,10 +16,20 @@ RUN mkdir -p /var/log/supervisor \
|
||||||
&& mkdir -p storage/logs \
|
&& mkdir -p storage/logs \
|
||||||
&& mkdir -p storage/framework/{cache,sessions,views} \
|
&& mkdir -p storage/framework/{cache,sessions,views} \
|
||||||
&& chmod -R 775 storage \
|
&& chmod -R 775 storage \
|
||||||
|
&& mkdir -p bootstrap/cache \
|
||||||
&& chmod -R 775 bootstrap/cache \
|
&& chmod -R 775 bootstrap/cache \
|
||||||
|
&& mkdir -p database \
|
||||||
&& touch database/database.sqlite \
|
&& touch database/database.sqlite \
|
||||||
&& chmod -R 777 database
|
&& chmod -R 777 database
|
||||||
|
|
||||||
|
# Copy application files
|
||||||
|
COPY --chown=www-data:www-data . .
|
||||||
|
COPY --chown=www-data:www-data ./.env.example ./.env
|
||||||
|
|
||||||
|
# Install application dependencies
|
||||||
|
RUN composer install --no-interaction --prefer-dist --optimize-autoloader
|
||||||
|
RUN npm ci && npm run build
|
||||||
|
|
||||||
# Expose port 80
|
# Expose port 80
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue