Laravel Local & Production

Laravel Development
php artisan view:clear
php artisan cache:clear
php artisan route:clear
php artisan config:clear
php artisan clear-compiled

composer dump-autoload
Laravel Production
php artisan view:clear
php artisan route:clear
php artisan config:clear
php artisan config:cache
php artisan route:cache
php artisan clear-compiled

composer dump-autoload -o --no-dev --classmap-authoritative

puppeteer – screenshot.js

https://try-puppeteer.appspot.com/

const browser = await puppeteer.launch();

const page = await browser.newPage();

await page.setViewport({
    width: 1920,
    height: 1080,
    deviceScaleFactor: 1,
});

await page.emulateMedia('screen');
await page.goto('https://csrone.com/');
await page.evaluate(function() {
    $('#GRI-content-included').remove();
    $('#back_to_top').remove();
    $('.cc-floating.cc-theme-classic').remove();
});

// force lazy loading
await page.evaluate(() => window.scrollTo(0, Number.MAX_SAFE_INTEGER));

// Here I'd love to use page.waitForNetworkIdle() instead of something similar
await page.waitFor(500);

await page.screenshot({
    path: 'screenshot.png',
    fullPage: true
});

await browser.close();

Docker connect from a container to a service on the host

如何從 Docker 容器連到本機的 host port

情境

SSH Tunnel 連至遠端伺服器 (localhost:8888 -> remote:3306)

想透過 docker 啟動的 web service (LNMP) 操作 adminer/phpmyadmin 連至遠端的資料庫。

原本想更改 docker network mode 為 host , 讓容器直接使用同一張網卡,但 windows 和 Mac 環境不支援 (只支援 Linux),查了好久終於找到解法。

https://docs.docker.com/docker-for-windows/networking/#use-cases-and-workarounds

The host has a changing IP address (or none if you have no network access). From 18.03 onwards our recommendation is to connect to the special DNS name host.docker.internal, which resolves to the internal IP address used by the host. This is for development purpose and will not work in a production environment outside of Docker Desktop for Windows.

The gateway is also reachable as gateway.docker.internal.

解法

使用 host.docker.internal:8888