Skip to content

Commit

Permalink
build: update docker setup with puppeteer config
Browse files Browse the repository at this point in the history
  • Loading branch information
alkrauss48 committed Mar 3, 2024
1 parent 6a3b297 commit 5af59a5
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ sail npm run dev

```

## To Generate Thumbnails for Presentations
This uses puppeteer and Browsershot, which requires some extra config on top of
Laravel Sail. To configure this, you need to attach to the container and run the
`./docker/sail-extra.sh` command:

```
docker compose exec laravel.test sh
> ./docker/sail-extra.sh
```

## Autoformatting
```
# Laravel
Expand Down
39 changes: 34 additions & 5 deletions docker/app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ ARG INSTALL_SQLSRV=false
ARG INSTALL_XDEBUG=false
ARG INSTALL_ZIP=true
ARG INSTALL_INTL=true
ARG PHP_UPLOAD_MAX_FILESIZE 64m
ARG PHP_POST_MAX_SIZE 64m
ARG PHP_MEMORY_LIMIT 512m
ARG DEPS='nodejs npm chromium'

# Backend build
FROM ghcr.io/clevyr/php:$PHP_VERSION-base as php-builder
Expand All @@ -37,10 +41,35 @@ RUN set -x \


# Frontend build
FROM node:18-alpine as node-builder
FROM node:lts-alpine as node-builder
WORKDIR /app

COPY package.json package-lock.json ./
RUN set -x \
&& apk add --no-cache \
autoconf \
automake \
bash \
g++ \
libc6-compat \
libjpeg-turbo \
libjpeg-turbo-dev \
libpng \
libpng-dev \
libtool \
libwebp \
libwebp-dev \
make \
nasm \
python3 \
cairo-dev \
jpeg-dev \
pango-dev \
giflib-dev

ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
ENV CHROMIUM_PATH /usr/bin/chromium-browser

COPY artisan package.json package-lock.json ./
RUN npm ci

COPY --from=php-builder /app .
Expand All @@ -49,11 +78,10 @@ RUN npm run build


# Local image
FROM ghcr.io/clevyr/php:$PHP_VERSION-onbuild as local-image
FROM ghcr.io/clevyr/php:$PHP_VERSION as local-image
WORKDIR /app

ENV PHP_UPLOAD_MAX_FILESIZE=64m
ENV PHP_POST_MAX_SIZE=64m
RUN npm --global install puppeteer@v17

# Install libraries for laravel-medialibrary
RUN set -x \
Expand All @@ -62,6 +90,7 @@ RUN set -x \
jpegoptim

COPY --chown=root docker/app/rootfs /

RUN crontab /etc/cron.d/scheduler

CMD ["s6-svscan", "/etc/s6/app"]
Expand Down
2 changes: 1 addition & 1 deletion docker/sail-extra.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

apt-get update
apt-get install -y gconf-service libasound2 libappindicator3-1 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget libgbm-dev libatk-bridge2.0-
npm install --global --unsafe-perm puppeteer@^17
apt-get install -y gconf-service libasound2 libappindicator3-1 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget libgbm-dev libatk-bridge2.0-
chmod -R o+rx /usr/lib/node_modules/puppeteer/.local-chromium

apt-get install -y ca-certificates fonts-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release wget xdg-utils

0 comments on commit 5af59a5

Please sign in to comment.