修复发布镜像混入本地Laravel缓存 (#89)
This commit is contained in:
parent
604531adac
commit
073ffb6494
@ -11,6 +11,7 @@ runtime
|
||||
JetBrainsMono-字体
|
||||
node_modules
|
||||
vendor
|
||||
bootstrap/cache/*
|
||||
.caiwu-build
|
||||
public/js
|
||||
public/css/app.css
|
||||
|
||||
@ -346,6 +346,11 @@ try {
|
||||
.
|
||||
} '本机镜像构建失败。服务器未发生任何变更。'
|
||||
|
||||
# 在无网络、无生产配置的临时容器中引导 Laravel,拦截开发包缓存混入镜像。
|
||||
Invoke-Native {
|
||||
docker run --rm --network none --user www-data --entrypoint php $fullImage artisan --version
|
||||
} '发布镜像无法引导 Laravel。服务器未发生任何变更。'
|
||||
|
||||
$previousShaOutput = @(& ssh -i $keyFullPath -o BatchMode=yes -o StrictHostKeyChecking=accept-new $sshTarget "cat '$RemotePath/.deployed-sha' 2>/dev/null || true")
|
||||
$previousSha = ($previousShaOutput -join "`n").Trim()
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
|
||||
@ -6,6 +6,17 @@ use Tests\TestCase;
|
||||
|
||||
class ProductionBuildCachePolicyTest extends TestCase
|
||||
{
|
||||
public function testReleaseExcludesLocalBootstrapCachesAndBootsBeforeProductionAccess(): void
|
||||
{
|
||||
$ignore = file_get_contents(base_path('.dockerignore'));
|
||||
$this->assertContains('bootstrap/cache/*', preg_split('/\R/', $ignore));
|
||||
$script = file_get_contents(base_path('scripts/deploy-from-workstation.ps1'));
|
||||
$smoke = strpos($script, 'docker run --rm --network none --user www-data --entrypoint php $fullImage artisan --version');
|
||||
$remote = strpos($script, '$previousShaOutput =');
|
||||
$this->assertNotFalse($smoke);
|
||||
$this->assertLessThan($remote, $smoke);
|
||||
}
|
||||
|
||||
public function testProductionDockerfilePinsBaseImagesAndRetriesExternalDownloads(): void
|
||||
{
|
||||
$dockerfile = file_get_contents(base_path('deploy/Dockerfile'));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user