-
Notifications
You must be signed in to change notification settings - Fork 9
DrFujiBot on AWS
EverOddish edited this page Jan 16, 2023
·
5 revisions
- Edit
~/.aws/credentialsto add access key in new profile namedpchal cd DrFujiBot_Djangoeb init --profile pchal- Open
DrFujiBot_Django/settings.pyand verify thatlocalis set toFalse - Edit
.ebextensions/db-migrate.configto uncomment the02_createsuperuserblock -
eb create drfujibot-env(creates environment and uploads source) - Edit
DrFujiBot_Django/settings.pyto add the environment URL toALLOWED_HOSTS - In the AWS Console, open the new environment, click "Configuration", then find "Database" and click "Edit"
- Engine: postgres
- Engine version: 14.5
- Instance class: db.t4g.micro
- Storage: 5 (GB)
- Availability: Low (one AZ)
- Database retention policy: Retain
- Run
eb deploywith updatedALLOWED_HOSTS
- Click "Clusters" and then "Create cluster", all default settings (Fargate)
- Click "Amazon ECR" on the left, create a repository ("Get started"), private, name "drfujibot"
- Open the new repository and click "View push commands"
- Copy and run the
aws ecrcommand to log in withdocker, and include--profile pchalin the copiedaws ecrcommand -
cd DrFujiBot_IRCand./build_image.shto build and push to ECR - Go back to ECS, then Task Definitions on the left, then "Create new task definition"
- Task definition family: DrFujiBot
- Container name: DrFujiBotIRC
- Image URI: (image URI from ECR)
- Remove any port mappings
- Set environment variables:
DJANGO_URLTWITCH_OAUTH_TOKENTWITCH_CHANNEL
- App environment: AWS Fargate (serverless)
- Operating system: Linux/X86_64
- CPU: .5 vCPU
- Memory: 1 GB
- Uncheck "Use log collection"
- Go back to ECS, then Services, then Deploy
- Compute options: Launch type
- Launch type: FARGATE
- Platform version: Latest
- Application type: Service
- Desired tasks: 1
Need to add an inbound rule on the Elastic Beanstalk security group to allow the IP address from which you run psql
pg_dump -U drfujibot -h localhost -f /home/everoddish/fuji_backup/drfujibot2.sql drfujibotpsql --host=<instance>.us-east-2.rds.amazonaws.com --port=5432 --username=drfujibot --dbname=ebdb --password < ~/fuji_backup/drfujibot2.sql