{"id":1433,"date":"2025-07-18T16:46:08","date_gmt":"2025-07-18T07:46:08","guid":{"rendered":"https:\/\/route-zero.com\/recruit\/?post_type=route&#038;p=1433"},"modified":"2025-07-31T09:47:24","modified_gmt":"2025-07-31T00:47:24","slug":"%e3%80%90%e4%bf%9d%e5%ad%98%e7%89%88%e3%80%91typescript%e3%82%a2%e3%83%97%e3%83%aa%e3%82%92docker%e5%8c%96%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95%ef%bd%9c%e6%9c%ac%e7%95%aa%e5%af%be%e5%bf%9c%e3%83%bb","status":"publish","type":"route","link":"https:\/\/route-zero.com\/recruit\/route\/1433\/","title":{"rendered":"\u3010\u4fdd\u5b58\u7248\u3011TypeScript\u30a2\u30d7\u30ea\u3092Docker\u5316\u3059\u308b\u65b9\u6cd5\uff5c\u672c\u756a\u5bfe\u5fdc\u30fb\u8efd\u91cf\u30fbCI\/CD\u306b\u3082\u5bfe\u5fdc"},"content":{"rendered":"<div>\n<h2>TypeScript + Docker \u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\uff5c\u8efd\u91cf &#038; \u9ad8\u901f\u306a\u958b\u767a\u74b0\u5883\u306e\u4f5c\u308a\u65b9\u3010Dockerfile\u4ed8\u304d\u3011<\/h2>\n<p>\u300cTypeScript \u30a2\u30d7\u30ea\u3092 Docker \u306b\u8f09\u305b\u305f\u3051\u3069\u3001Docker \u30a4\u30e1\u30fc\u30b8\u304c\u5de8\u5927\u3001\u30db\u30c3\u30c8\u30ea\u30ed\u30fc\u30c9\u304c\u52b9\u304b\u306a\u3044\u3001\u578b\u63a8\u8ad6\u304c\u5d29\u308c\u308b\u2026\u300d \u305d\u3093\u306a\u60a9\u307f\u3001\u62b1\u3048\u3066\u3044\u307e\u305b\u3093\u304b\uff1f<\/p>\n<p>\n    \u672c\u8a18\u4e8b\u3067\u306f\u3001<b>Dockerfile \u306e\u6700\u9069\u5316\u306b\u3088\u308b\u300c\u30a4\u30e1\u30fc\u30b8\u30b5\u30a4\u30ba\u306e\u8efd\u91cf\u5316\u300d\u300c\u30d3\u30eb\u30c9\u6642\u9593\u306e\u77ed\u7e2e\u300d\u300c\u30db\u30c3\u30c8\u30ea\u30ed\u30fc\u30c9\u5bfe\u5fdc\u300d\u306a\u3069\u306e\u3088\u304f\u3042\u308b\u8ab2\u984c\u3092\u3001\u5b9f\u52d9\u76ee\u7dda\u3067\u89e3\u6c7a<\/b>\u3057\u307e\u3059\u3002 \u3055\u3089\u306b\u3001\u958b\u767a\u7528\u3068\u672c\u756a\u7528\u306b\u5206\u3051\u305f Dockerfile \u306e\u69cb\u6210\u3084 CI\/CD \u3092\u898b\u636e\u3048\u305f\u8a2d\u8a08\u601d\u60f3\u3082\u8a73\u3057\u304f\u89e3\u8aac\u3002<b>ChatGPT \u6d3b\u7528\u30d7\u30ed\u30f3\u30d7\u30c8\u4f8b\u3082\u4f75\u305b\u3066\u7d39\u4ecb<\/b\n    >\u3057\u307e\u3059\u3002\n  <\/p>\n<hr \/>\n<h2>\u3088\u304f\u3042\u308b TypeScript + Docker \u306e\u8ab2\u984c\u3068\u305d\u306e\u80cc\u666f<\/h2>\n<p>\u958b\u767a\u73fe\u5834\u3067\u3088\u304f\u898b\u304b\u3051\u308b\u306e\u304c\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u8ab2\u984c\u3067\u3059\uff1a<\/p>\n<ul>\n<li>\n<p><code>node_modules<\/code> \u3092\u542b\u3093\u3060\u307e\u307e\u306e Docker \u30a4\u30e1\u30fc\u30b8\u3067\u30b5\u30a4\u30ba\u304c1GB\u8d85\u3048<\/p>\n<\/li>\n<li>\n<p>\u30d3\u30eb\u30c9\u30ad\u30e3\u30c3\u30b7\u30e5\u304c\u52b9\u304b\u305a\u3001\u6bce\u56de <code>npm install<\/code><\/p>\n<\/li>\n<li>\n<p><code>tsconfig.json<\/code> \u306e\u8a2d\u5b9a\u30df\u30b9\u3067 <code>node_modules<\/code> \u3092\u30c8\u30e9\u30f3\u30b9\u30d1\u30a4\u30eb\u5bfe\u8c61\u306b<\/p>\n<\/li>\n<li>\n<p>\u30db\u30c3\u30c8\u30ea\u30ed\u30fc\u30c9\u304c\u52b9\u304b\u305a\u3001\u6bce\u56de\u30b3\u30f3\u30c6\u30ca\u518d\u8d77\u52d5<\/p>\n<\/li>\n<\/ul>\n<p>\u3053\u308c\u3089\u306f\u3001<b>Dockerfile \u3084 tsconfig.json \u306e\u8a2d\u8a08\u4e0d\u5099\u306b\u3088\u3063\u3066\u767a\u751f<\/b>\u3059\u308b\u3053\u3068\u304c\u591a\u3044\u3067\u3059\u3002<\/p>\n<hr \/>\n<h2>Dockerfile \u6700\u9069\u5316\uff1a\u3088\u304f\u3042\u308b\u5931\u6557\u3068\u6539\u5584\u4f8b<\/h2>\n<h3>NG\u306a Dockerfile\uff08\u30ad\u30e3\u30c3\u30b7\u30e5\u52b9\u7387\u3084\u8efd\u91cf\u5316\u3092\u7121\u8996\uff09<\/h3>\n<pre><code>FROM node:18\r\n\r\nWORKDIR \/app\r\nCOPY . .\r\nRUN npm install\r\nRUN npm run build\r\n\r\nCMD [\"node\", \"dist\/index.js\"]<\/code><\/pre>\n<p><b>\u554f\u984c\u70b9\uff1a<\/b><\/p>\n<ul>\n<li>\n<p><code>COPY . .<\/code> \u304c\u65e9\u3059\u304e\u3066\u30ad\u30e3\u30c3\u30b7\u30e5\u304c\u52b9\u304b\u306a\u3044<\/p>\n<\/li>\n<li>\n<p>\u958b\u767a\u7528\u4f9d\u5b58\uff08<code>devDependencies<\/code>\uff09\u3082\u542b\u307e\u308c\u3066\u3057\u307e\u3046<\/p>\n<\/li>\n<li>\n<p><code>node_modules<\/code> \u306e\u72b6\u614b\u304c\u30ed\u30fc\u30ab\u30eb\u3068\u305a\u308c\u3066\u4e0d\u5b89\u5b9a\u306b<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>\u6539\u5584\u3055\u308c\u305f Dockerfile\uff08multi-stage + \u8efd\u91cf &#038; \u30bb\u30ad\u30e5\u30a2\uff09<\/h3>\n<pre><code># builder \u30b9\u30c6\u30fc\u30b8\uff08\u958b\u767a\u30fb\u30c6\u30b9\u30c8\u7528\uff09\r\nFROM node:18 AS builder\r\n\r\nWORKDIR \/app\r\nCOPY package*.json .\/\r\nRUN npm ci\r\nCOPY . .\r\nRUN npm run build\r\n\r\n# production \u30b9\u30c6\u30fc\u30b8\uff08\u672c\u756a\u7528\uff09\r\nFROM node:18-slim\r\n\r\nWORKDIR \/app\r\nCOPY --from=builder \/app\/dist .\/dist\r\nCOPY --from=builder \/app\/package*.json .\/\r\nRUN npm ci --only=production\r\n\r\nCMD [\"node\", \"dist\/index.js\"]<\/code><\/pre>\n<p><b>\u6539\u5584\u30dd\u30a4\u30f3\u30c8\uff1a<\/b><\/p>\n<ul>\n<li>\n<p><code>package*.json<\/code> \u3092\u5148\u306b\u30b3\u30d4\u30fc\u3057\u3001<b>\u30ad\u30e3\u30c3\u30b7\u30e5\u52b9\u7387\u3092\u6700\u5927\u5316<\/b><\/p>\n<\/li>\n<li>\n<p><code>multi-stage build<\/code> \u3067\u958b\u767a\u7528\u30c4\u30fc\u30eb\u3092\u6392\u9664\u3057\u3001<b>\u672c\u756a\u7528\u3092\u8efd\u91cf\u5316<\/b><\/p>\n<\/li>\n<li>\n<p><code>node:18-slim<\/code> \u306b\u3088\u308a <b>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3068\u5b89\u5b9a\u6027\u3092\u4e21\u7acb<\/b><\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h2>TypeScript + Docker \u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u4f8b\uff08CI\/CD\u30fb\u8efd\u91cf\u5316\u5bfe\u5fdc\uff09<\/h2>\n<h3>tsconfig.json \u306e\u4e00\u4f8b\uff08\u6700\u5c0f\u9650\u3067\u53b3\u683c\uff09<\/h3>\n<pre><code>{\r\n\"compilerOptions\": {\r\n\"outDir\": \".\/dist\",\r\n\"rootDir\": \".\/src\",\r\n\"target\": \"ES2020\",\r\n\"module\": \"commonjs\",\r\n\"strict\": true,\r\n\"esModuleInterop\": true\r\n},\r\n\"include\": [\"src\/**\/*\"],\r\n\"exclude\": [\"node_modules\", \"dist\"]\r\n}<\/code><\/pre>\n<h3>.dockerignore\uff08\u30d3\u30eb\u30c9\u8efd\u91cf\u5316\u306e\u9375\uff09<\/h3>\n<pre><code>node_modules\r\ndist\r\n.git\r\nDockerfile\r\ndocker-compose.*<\/code><\/pre>\n<h3>docker-compose.dev.yml\uff08\u30db\u30c3\u30c8\u30ea\u30ed\u30fc\u30c9\u5bfe\u5fdc\uff09<\/h3>\n<pre><code>version: '3.8'\r\nservices:\r\napp:\r\nbuild:\r\ncontext: .\r\ndockerfile: Dockerfile\r\nvolumes:\r\n- .:\/app\r\n- \/app\/node_modules\r\ncommand: npm run dev\r\nports:\r\n- \"3000:3000\"<\/code><\/pre>\n<hr \/>\n<h2>TypeScript \u00d7 Docker\uff1a\u8a2d\u8a08\u306e\u539f\u5247\u3068\u9078\u5b9a\u306e\u30dd\u30a4\u30f3\u30c8<\/h2>\n<h3>\u30de\u30eb\u30c1\u30b9\u30c6\u30fc\u30b8\u30d3\u30eb\u30c9\u306e\u5229\u70b9<\/h3>\n<ul>\n<li>\n<p><b>\u958b\u767a\u74b0\u5883\u3068\u672c\u756a\u74b0\u5883\u306e\u5206\u96e2<\/b><\/p>\n<\/li>\n<li>\n<p><b>\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u6d3b\u304b\u3057\u305f CI\/CD \u5bfe\u5fdc<\/b><\/p>\n<\/li>\n<li>\n<p><b>\u6700\u5c0f\u9650\u306e\u4f9d\u5b58\u3067\u8efd\u91cf &#038; \u30bb\u30ad\u30e5\u30a2\u306a\u30a4\u30e1\u30fc\u30b8\u69cb\u7bc9<\/b><\/p>\n<\/li>\n<\/ul>\n<table>\n<thead>\n<tr>\n<th>\u30d9\u30fc\u30b9\u30a4\u30e1\u30fc\u30b8<\/th>\n<th>\u7279\u5fb4<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>node:18-alpine<\/code><\/td>\n<td>\u975e\u5e38\u306b\u8efd\u91cf\u3060\u304c\u4f9d\u5b58\u3067\u8a70\u307e\u308a\u3084\u3059\u3044<\/td>\n<\/tr>\n<tr>\n<td><code>node:18-slim<\/code><\/td>\n<td>\u3084\u3084\u91cd\u3044\u304c\u5b89\u5b9a\u6027\u30fb\u4e92\u63db\u6027\u306b\u512a\u308c\u308b<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h2>ChatGPT \u30d7\u30ed\u30f3\u30d7\u30c8\u3067\u52b9\u7387\u30a2\u30c3\u30d7\uff08\u5b9f\u4f8b\u4ed8\u304d\uff09<\/h2>\n<pre><code>\u300cNode.js + TypeScript \u30a2\u30d7\u30ea\u3092 multi-stage \u3067 Docker \u5316\u3057\u305f\u3044\u3067\u3059\u3002\r\n\u958b\u767a\u7528\uff08\u30db\u30c3\u30c8\u30ea\u30ed\u30fc\u30c9\u3042\u308a\uff09\u3068\u672c\u756a\u7528\u306b\u5206\u3051\u305f Dockerfile \u3092\u66f8\u3044\u3066\u304f\u3060\u3055\u3044\u3002\r\n\u8efd\u91cf\u3067\u30bb\u30ad\u30e5\u30a2\u306b\u4fdd\u3061\u3064\u3064\u3001npm ci \u3092\u4f7f\u3063\u3066\u304f\u3060\u3055\u3044\u3002\u300d<\/code><\/pre>\n<p>\u3053\u306e\u3088\u3046\u306b <b>\u8a2d\u8a08\u610f\u56f3\uff08\u30ad\u30e3\u30c3\u30b7\u30e5\u6d3b\u7528\u3001\u8efd\u91cf\u5316\u3001\u4f9d\u5b58\u306e\u5206\u96e2\uff09\u3092\u660e\u78ba\u5316<\/b>\u3059\u308b\u3068\u3001\u3088\u308a\u5b9f\u52d9\u306b\u4f7f\u3048\u308b\u51fa\u529b\u304c\u5f97\u3089\u308c\u307e\u3059\u3002<\/p>\n<hr \/>\n<h2>\u3088\u304f\u3042\u308b\u843d\u3068\u3057\u7a74\u3068 CI\/CD \u5bfe\u5fdc\u306e\u6ce8\u610f\u70b9<\/h2>\n<ul>\n<li>\n<p><code>COPY<\/code> \u306e\u9806\u756a\u3067\u30ad\u30e3\u30c3\u30b7\u30e5\u52b9\u7387\u304c\u5287\u7684\u306b\u5909\u308f\u308b<\/p>\n<\/li>\n<li>\n<p>\u30db\u30b9\u30c8\u3068\u306e\u30dc\u30ea\u30e5\u30fc\u30e0\u30de\u30a6\u30f3\u30c8\u304c <code>node_modules<\/code> \u3092\u58ca\u3059\u539f\u56e0\u306b<\/p>\n<\/li>\n<li>\n<p><code>alpine<\/code> \u30d9\u30fc\u30b9\u3067 <code>glibc<\/code> \u5fc5\u9808\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u30d3\u30eb\u30c9\u5931\u6557\u3059\u308b<\/p>\n<\/li>\n<li>\n<p>CI \u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u3067\u306f <b>builder \u30b9\u30c6\u30fc\u30b8\u5185\u3067\u30c6\u30b9\u30c8\u5b9f\u884c\u3057\u3001\u672c\u756a\u30a4\u30e1\u30fc\u30b8\u306b\u306f\u6210\u679c\u7269\u306e\u307f\u30b3\u30d4\u30fc<\/b>\u304c\u63a8\u5968<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h2>\u95a2\u9023\u8a18\u4e8b\u30ea\u30f3\u30af\uff08\u5185\u90e8\u30ea\u30f3\u30af\uff09<\/h2>\n<ul>\n<li>\n<p><a href=\"https:\/\/route-zero.com\/recruit\/route\/1050\/\">Vue.js\u3092Docker\u3067\u7acb\u3061\u4e0a\u3052\uff01\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u4f5c\u6210\u304b\u3089\u8d77\u52d5\u307e\u3067\u5b8c\u5168\u89e3\u8aac<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/route-zero.com\/recruit\/route\/1291\/\">TypeScript\u306e\u59cb\u3081\u65b9\uff5cNode.js\u3068VSCode\u3067\u5b66\u3076\u958b\u767a\u74b0\u5883\u69cb\u7bc9\u30ac\u30a4\u30c9\u3010\u521d\u5fc3\u8005\u5411\u3051\u5b8c\u5168\u89e3\u8aac\u3011<\/a><\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h2>FAQ\uff08\u3088\u304f\u3042\u308b\u8cea\u554f\uff09<\/h2>\n<h3>Q1. \u306a\u305c\u30de\u30eb\u30c1\u30b9\u30c6\u30fc\u30b8\u69cb\u6210\u304c\u63a8\u5968\u3055\u308c\u308b\u306e\uff1f<\/h3>\n<p>A. <b>\u4e0d\u8981\u306a\u958b\u767a\u4f9d\u5b58\u3092\u524a\u9664\u3057\u3001\u8efd\u91cf\u3067\u5b89\u5168\u306a\u672c\u756a\u74b0\u5883\u3092\u4f5c\u308c\u308b\u304b\u3089\u3067\u3059\u3002<\/b><\/p>\n<hr \/>\n<h3>Q2. Alpine \u30d9\u30fc\u30b9\u306f\u672c\u5f53\u306b\u8efd\u3044\uff1f<\/h3>\n<p>\n    A. \u8efd\u91cf\u3067\u3059\u304c <code>node-gyp<\/code> \u306a\u3069\u3092\u4f7f\u3046\u74b0\u5883\u3067\u306f\u4f9d\u5b58\u89e3\u6c7a\u304c\u96e3\u3057\u3044\u305f\u3081\u3001<b>\u6700\u521d\u306f <code>slim<\/code> \u30d9\u30fc\u30b9\u304c\u304a\u3059\u3059\u3081<\/b>\u3067\u3059\u3002\n  <\/p>\n<hr \/>\n<h3>Q3. TypeScript \u306e\u30c6\u30b9\u30c8\u306f\u3069\u3046\u3059\u308b\uff1f<\/h3>\n<p>A. builder \u30b9\u30c6\u30fc\u30b8\u5185\u3067 <code>npm test<\/code> \u3092\u5b9f\u884c\u3057\u3001<b>\u30c6\u30b9\u30c8\u901a\u904e\u5f8c\u306b dist \u3060\u3051\u3092\u672c\u756a\u30a4\u30e1\u30fc\u30b8\u3078<\/b>\u3002<\/p>\n<hr \/>\n<h3>Q4. \u30db\u30c3\u30c8\u30ea\u30ed\u30fc\u30c9\u306f\u53ef\u80fd\uff1f<\/h3>\n<p>A. <code>ts-node-dev<\/code> \u3084 <code>nodemon<\/code> + volume \u30de\u30a6\u30f3\u30c8 + <code>docker-compose.dev.yml<\/code> \u3067 <b>\u958b\u767a\u7528\u30db\u30c3\u30c8\u30ea\u30ed\u30fc\u30c9\u74b0\u5883<\/b>\u3092\u69cb\u7bc9\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<hr \/>\n<h3>Q5. ChatGPT \u306b\u4f9d\u983c\u3059\u308b\u969b\u306e\u30b3\u30c4\u306f\uff1f<\/h3>\n<p>A. <b>\u300cmulti-stage\u300d\u300cproduction dependencies\u300d\u300c\u30ad\u30e3\u30c3\u30b7\u30e5\u6700\u9069\u5316\u300d\u306a\u3069\u3001\u8a2d\u8a08\u601d\u60f3\u3092\u30d7\u30ed\u30f3\u30d7\u30c8\u306b\u542b\u3081\u308b\u3053\u3068<\/b>\u304c\u6210\u529f\u306e\u9375\u3067\u3059\u3002<\/p>\n<hr \/>\n<h2>\u307e\u3068\u3081\uff1aTypeScript + Docker \u306e\u6700\u9069\u89e3\u3092\u518d\u78ba\u8a8d<\/h2>\n<ul>\n<li>\n<p>\u3088\u304f\u3042\u308b\u5931\u6557\u4f8b\u3068\u6539\u5584\u6e08\u307f Dockerfile \u306e\u6bd4\u8f03<\/p>\n<\/li>\n<li>\n<p>tsconfig \/ .dockerignore \/ Compose \u69cb\u6210\u306e\u5b9f\u4f8b<\/p>\n<\/li>\n<li>\n<p>\u8a2d\u8a08\u306e\u80cc\u666f\u3068\u8efd\u91cf\u30fb\u5b89\u5b9a\u6027\u306e\u30d0\u30e9\u30f3\u30b9<\/p>\n<\/li>\n<li>\n<p>ChatGPT \u6d3b\u7528\u306b\u3088\u308b\u81ea\u52d5\u751f\u6210\u306e\u30b3\u30c4<\/p>\n<\/li>\n<li>\n<p>CI\/CD \u3092\u898b\u636e\u3048\u305f\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/p>\n<\/li>\n<\/ul>\n<p><b>\u3053\u308c\u3089\u3092\u7406\u89e3\u3059\u308c\u3070\u3001\u300c\u52d5\u304f\u3051\u3069\u9045\u3044\u300d\u300c\u91cd\u3059\u304e\u308b\u300dDocker \u74b0\u5883\u304b\u3089\u5352\u696d\u3067\u304d\u307e\u3059\u3002<\/b><\/p>\n<hr \/>\n<h2>\u53c2\u8003\u6587\u732e\u30fb\u60c5\u5831\u6e90\uff08\u5916\u90e8\u30ea\u30f3\u30af\uff09<\/h2>\n<ul>\n<li>\n<p><a href=\"https:\/\/www.typescriptlang.org\/docs\/\">TypeScript\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.docker.com\/language\/nodejs\/\">Docker \u516c\u5f0f Node.js \u30ac\u30a4\u30c9<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.docker.com\/develop\/develop-images\/dockerfile_best-practices\/\">Dockerfile \u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n","protected":false},"featured_media":1435,"template":"","_links":{"self":[{"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/route\/1433"}],"collection":[{"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/route"}],"about":[{"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/types\/route"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/media\/1435"}],"wp:attachment":[{"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/media?parent=1433"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}