v1.12.26 운영 Compose 식별 통일 및 Docker 앱 배포 안내 정리
This commit is contained in:
32
tests/production-compose.test.js
Normal file
32
tests/production-compose.test.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { mkdtempSync, writeFileSync, readFileSync, rmSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join, relative, resolve } from 'node:path'
|
||||
import { spawnSync } from 'node:child_process'
|
||||
|
||||
const root = resolve('.')
|
||||
|
||||
for (const script of ['migrate-production-db.sh', 'backfill-post-thumbnails-production.sh', 'backfill-post-body-thumbnails-production.sh', 'backfill-page-cover-thumbnails-production.sh']) {
|
||||
test(`운영 ${script}는 명시한 Compose 파일·환경 파일만 사용한다`, () => {
|
||||
const directory = mkdtempSync(join(tmpdir(), 'sori-compose-test-'))
|
||||
try {
|
||||
const logPath = join(directory, 'docker.log')
|
||||
const envPath = join(directory, 'production.env')
|
||||
writeFileSync(envPath, 'COMPOSE_PROJECT_NAME=sori-studio\n')
|
||||
writeFileSync(join(directory, 'docker'), '#!/bin/sh\nprintf "<%s>" "$@" >> "$SORI_TEST_DOCKER_LOG"\nprintf "\\n" >> "$SORI_TEST_DOCKER_LOG"\n', { mode: 0o755 })
|
||||
const result = spawnSync('sh', [`scripts/${script}`, 'status'], {
|
||||
cwd: root, encoding: 'utf8',
|
||||
env: { ...process.env, PATH: `${directory}:${process.env.PATH}`, ENV_FILE: relative(root, envPath), SORI_TEST_DOCKER_LOG: logPath }
|
||||
})
|
||||
assert.equal(result.status, 0, result.stderr)
|
||||
const calls = readFileSync(logPath, 'utf8').trim().split('\n')
|
||||
assert.ok(calls.length > 0)
|
||||
for (const call of calls) {
|
||||
assert.ok(call.startsWith(`<compose><-f><${join(root, 'docker-compose.yml')}><--env-file><${relative(root, envPath)}>`))
|
||||
}
|
||||
} finally {
|
||||
rmSync(directory, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user