UNPKG

@jin7942/ray

Version:

Lightweight CI/CD deployment tool powered by Docker and Git

33 lines (32 loc) 1.35 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.dockerBuildImage = dockerBuildImage; const child_process_1 = require("child_process"); const util_1 = require("util"); const logger_1 = require("../utils/logger"); const path_1 = __importDefault(require("path")); const execAsync = (0, util_1.promisify)(child_process_1.exec); /** * Builds a Docker image using the given Dockerfile and context. * * @param ctx - Pipeline execution context */ async function dockerBuildImage(ctx) { const { workspace, docker } = ctx; // workspace 기준으로 Dockerfile 경로 구성 const dockerfilePath = path_1.default.resolve(workspace, docker.path.dockerfile); const imageName = docker.image; logger_1.logger.info(`Building Docker image: ${imageName}`); logger_1.logger.info(`Using Dockerfile at: ${dockerfilePath}`); const cmd = `docker build -t ${imageName} -f ${dockerfilePath} ${workspace}`; try { await execAsync(cmd, { maxBuffer: 10 * 1024 * 1024 }); logger_1.logger.info('Docker image built successfully.'); } catch (e) { throw new Error(`Docker build failed: ${e instanceof Error ? e.message : String(e)}`); } }