๐ ํ๊ฒฝ
Python 3.8
VsCode
ELB
๐ ๊ฐ์
Django๋ฅผ eb์์ ์คํํ๊ธฐ ์ํ ์ธํ ์ ์งํํฉ๋๋ค.
๐ ๋ชฉ์ฐจ
- eb deploy setting
- ๋ณด๊ธฐ ์ฐธ์กฐ
- eb deploy setting
๋ณด๊ธฐ๋ ํ๋จ ์ฐธ์กฐ
- eb cli ์ค์น
- ํ๋ก์ ํธ์์ ๋ช
๋ น์ด-> eb init ํ๊ณ ์ค๋ช
์ ๋ง๊ฒ ์งํ
Do you wish to continue with CodeCommit? N์ ๋๋ฌ์ค๋๋ค
์ ์ฅ์๋ฅผ Aws์ ์ฝ๋์ปค๋ฐ์ผ๋ก ํ๊ฒ ๋๋ ์ง๋ฌธ - . elasticbeanstalk๋ด๋ถ์ config.yml ํ์ผ ์์ฑ๋จ
- . ebignore eb์ ์ฌ๋ผ๊ฐ์ง ์์๋ ๋ ํ์ผ ์์ฑ -> e.g) 5๋ฒ ๋ณด๊ธฐ
- . ebextensions eb์ ์ฌ์ฉ๋ pakaage ํน์ data ์ค์ -> e.g) 6๋ฒ ๋ณด๊ธฐ
โโโ 01_package.config
โโโ 02_gunicorn.config
โโโ 03_env.config - . platform eb์์ ์ฌ์ฉ๋ deploy ๋จ๊ณ์ ๋ง๊ฒ ์คํํ ๋ช
๋ น์ด ์ค์
aws_postdeploy_link ์ฌ์ฉ๋ฒ ๋งํฌ
โโโ hooks
โ โโโ postdeploy
โ โโโ 01_env.sh
โ โโโ 02_gunicorn.sh
โโโ nginx
โโโ conf.d
โโโ elasticbeanstalk
โโโ nginx_custom.conf - eb deploy
- ๋ณด๊ธฐ ์ฐธ์กฐ
# 4๋ฒ ๋ณด๊ธฐ
# file_name: .ebignore
.env
.git
.gitignore
/venv
# 5๋ฒ ๋ณด๊ธฐ
# file_name: 01_package.config
commands:
01-command:
command: sudo yum install -y mysql-devel
02-command:
command: sudo yum install -y jq
# 5๋ฒ ๋ณด๊ธฐ
# file_name: 02_gunicorn.config
files:
"/etc/systemd/system/gunicorn.service":
mode: "000755"
owner: root
group: root
content: |
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
WorkingDirectory=/var/app/current/<project_name> #project path
Environment="DJANGO_SETTINGS_MODULE=<project_name>.settings.local" #project settings path
ExecStart=/var/app/venv/staging-LQM1lest/bin/gunicorn \ #venv gunicorn path
--workers 3 --bind 0.0.0.0:8000 <project_name>.wsgi:application --timeout 120
[Install]
WantedBy=multi-user.target
container_commands:
1_command:
command: "systemctl enable gunicorn"
2_command:
command: "systemctl start gunicorn"
# 5๋ฒ ๋ณด๊ธฐ
# file_name: 03_env.config
option_settings:
aws:elasticbeanstalk:application:environment:
DJANGO_SETTINGS_MODULE: <project_name>.settings.local
LOCAL_ENV : False
DB_NAME_DEV : test_db_name
# 6๋ฒ ๋ณด๊ธฐ
# file_name: 01_env.sh
# env๋ฅผ ์ฝ์ด ์ฌ์ฉํ ๋๋ ํ ๋ฆฌ์ ์นดํผํ๋ ์์
, ์๋ 3์ค ํ์ค๋ก ๋ง๋ค์ด์ ์ฌ์ฉ
#!/bin/sh
/opt/elasticbeanstalk/bin/get-config environment
| jq -r 'to_entries | .[] | "\(.key) = \"\(.value)\""' >
/var/app/current/<project_name>/.env
# 6๋ฒ ๋ณด๊ธฐ
# file_name: 01_gunicorn.sh
# deploy๊ฐ ๋๋๊ณ restart
#!/bin/sh
sudo systemctl restart gunicorn
# 6๋ฒ ๋ณด๊ธฐ
# file_name: nginx_custom.conf
# nginx custom setting ํ์ํ ๋ ์ฌ์ฉ
๐ ๊ทผ๊ฑฐ ์๋ ์กฐ์ธ์ ์ธ์ ๋ ํ์ํฉ๋๋ค. ์ฑ์คํ ์ฝ๋ฉ ํ์ธ์.