๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

์นดํ…Œ๊ณ ๋ฆฌ ์—†์Œ

[docker] dockerfile ์ž‘์„ฑ

728x90
๋ฐ˜์‘ํ˜•

๐Ÿ”ด dockerfle

- ์ฝ”๋“œ ํ•œ ์ค„ ํ•œ ์ค„์„ layer ๋ผ๊ณ  ๋ถ€๋ฅด๋ฉฐ, ์ƒ๋‹จ์— ์œ„์น˜ํ•  ์ˆ˜๋ก ๋ณ€ํ•˜์ง€ ์•Š๋Š” ๋ถ€๋ถ„์ด, ํ•˜๋‹จ์— ์œ„์น˜ํ•  ์ˆ˜๋ก ์ž์ฃผ ๋ณ€ํ•˜๋Š” ๋ถ€๋ถ„์ด ์œ„์น˜ํ•˜๊ฒŒ ํ•œ๋‹ค. ์˜ˆ๋ฅผ ๋“ค๋ฉด ์•„๋ž˜์ฝ”๋“œ์—์„œ

# Use the official Node.js image as the base image
FROM node:14

# Set the working directory
WORKDIR /app

# Copy the package.json and package-lock.json files to the working directory
COPY package*.json ./

# Install the dependencies
RUN npm install

# Copy the rest of the application code to the working directory
COPY . .

# Expose the port the application will run on
EXPOSE 3000

# Start the application
CMD ["npm", "start"]

npm install ๋‹ค์Œ ์ค„์ด working directory์—์„œ ๊ฐ€์ ธ์˜ฌ ํŒŒ์ผ๋“ค์„ ๋ช…์‹œํ•˜๋Š” ๊ฒƒ์ธ๋ฐ ์—ฌ๊ธฐ์— ๋ณดํ†ต index.ts ๋“ฑ์˜ ํŒŒ์ผ๋“ค์ด ์œ„์น˜ํ•˜๊ฒŒ ๋œ๋‹ค. package.json ์€ ๋ณ€ํ•  ๊ฐ€๋Šฅ์„ฑ์ด ๋งค์šฐ ๋‚ฎ์€ ๋ฐ˜๋ฉด, ๊ฐœ๋ฐœํ•˜๋Š” ํŒŒ์ผ๋“ค์€ ์ถ”ํ›„ ์‚ฌ์ •์— ๋”ฐ๋ผ ์ˆ˜์ •ํ•  ๊ฐ€๋Šฅ์„ฑ์ด ๋†ํ›„ํ•˜๋‹ค. ๋”ฐ๋ผ์„œ ์•„๋ž˜์ชฝ์— ์œ„์น˜ํ•˜๊ฒŒ ํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

- docker๋Š” ํŒŒ์ผ ๋ณ€๊ฒฝ์ด ์žˆ์„ ๋•Œ ๋ณ€๊ฒฝ๋œ ํŒŒ์ผ๋ถ€ํ„ฐ ์ƒˆ๋กœ ์ปดํŒŒ์ผํ•œ๋‹ค. ์ฆ‰ ํ•˜๋‹จ์—์„œ ๋ณ€๊ฒฝ ๋˜๋ฉด ์ƒ๋‹จ์€ ๊ทธ๋Œ€๋กœ ์œ ์ง€ํ•˜๊ณ  ํ•˜๋‹จ๋งŒ ๋น ๋ฅด๊ฒŒ ๋‹ค์‹œ ์ปดํŒŒ์ผ ํ•œ๋‹ค๋Š” ๋œป.

๐ŸŸก๐ŸŸฃ๐ŸŸ ๐ŸŸข

728x90
๋ฐ˜์‘ํ˜•


Calendar
ยซ   2024/11   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Archives
Visits
Today
Yesterday