๐ณDocker
[Docker] ๋์ปค ์ค์น ๋ฐฉ๋ฒ ๋ฐ ํ๊ฒฝ์ค์ ํ๊ธฐ
๋ฃจ๋ฆฌ์ผใ
2024. 2. 27. 23:07
๋ฐ์ํ
1. ์ฐ์ ๋์ปค ํํ์ด์ง์์ ๋์ปค๋ฅผ ์ค์น ํ๋ค.
Docker: Accelerated Container Application Development
Docker is a platform designed to help developers build, share, and run container applications. We handle the tedious setup, so you can focus on the code.
www.docker.com
ํ์๊ฐ์ ์ ํ๊ณ
ํ์๊ฐ์ ์ด ๋๋๋ฉด Tell us about the wolrk you do์์๋ skip์ ํด๋ฆญํ๋ค.
๊ทธ๋ฆฌ๊ณ ์ค์น๋ ๋์ปค ๋ฐ์คํฌํฑ์ ์ด์ด ๋ก๊ทธ์ธ ํ๋ฉด ๋๋ค.
2. ๋์ปค ์คํ์ ์ํ ์ค์
2.1. serverless.yml ํ์ผ ์์
provider:
name: aws
runtime: python3.10
region: ap-northeast-2
ecr:
images:
appimage:
path: ./
functions:
app:
image:
name: appimage
timeout: 50
events:
- httpApi: '*'
2.2. requirements.txt ํ์ผ ์์ (์๋ ๋ด์ฉ ์ถ๊ฐ)
serverless-wsgi
flask-restful
mysql-connector-python
psycopg-binary
passlib
flask-jwt-extended
email-validator
2.3. app.py import
import serverless_wsgi
.
.
.
def handler(event, context):
return serverless_wsgi.handle_request(app, event, context)
if **name** == '**main**' :
app.run()
2.4. Dockerfile ์์ฑ
FROM public.ecr.aws/lambda/python:3.10
COPY . ${LAMBDA_TASK_ROOT}
COPY requirements.txt .
RUN yum -y install gcc
RUN pip3 install -r requirements.txt --target "${LAMBDA_TASK_ROOT}"
CMD ["app.handler"]
2.5. .dockerignore ํ์ผ ์์ฑ
#.dockerignore
pycache/
.git/
.serverless/
.gitignore
.dockerignore
serverless.yml
๋ฐ์ํ