-
Notifications
You must be signed in to change notification settings - Fork 59
Deploy
Tips: You may comment out unused dependencies in
requirements.txt
before installation.
- Install dependencies:
pip install -r requirements.txt
- Set the required environment variables or place them in
.env
file, you may refer to.env.example
as an example - Start the bot:
python -m nazurin
- Configure the options in
.env
- Run
docker-compose up -d
to use the lastet pre-built Docker images. (Alternatively, you may build the image yourself:docker-compose up -d --build
)
Note: The 256MB free RAM on fly.io is not enough to run ffmpeg convertion (Pixiv ugoira to mp4), scaling to 512MB should work but will introduce extra costs.
-
Install flyctl, sign up and sign in, refer to https://fly.io/docs/hands-on/install-flyctl/
-
Run
fly launch --copy-config --image ghcr.io/y-young/nazurin:latest
, enter required information and skip deployment- It's recommended to choose a hard-to-guess name for your application to improve security, you may use a generated name if you wish
- It's recommended to locate your app in European regions since the Telegram bot API server is said to be in Netherlands. Also, this helps to reduce outbound bandwidth to Asia since the free quota is smaller than North America/Europe (30GB vs 100GB).
- We choose not to deploy the app at this time because we haven't set the environment variables and the app will throw errors at startup
> fly launch --copy-config --image ghcr.io/y-young/nazurin:latest An existing fly.toml file was found for app nazurin Creating app in /nazurin Using image ghcr.io/y-young/nazurin:latest ? App Name (leave blank to use an auto-generated name): {Your Application Name} Automatically selected personal organization: {Your Organization Name} ? Select region: ams (Amsterdam, Netherlands) Created app nazurin in organization personal Wrote config file fly.toml ? Would you like to set up a Postgresql database now? No ? Would you like to deploy now? No Your app is ready. Deploy with `flyctl deploy`
-
Update configuration in
.env
, referring to.env.example
as an example. The webhook URL should look likehttps://xxx.fly.dev/
, and you don't have to specify a port since it's already setup infly.toml
-
Run
python ./tools/set_fly_secrets.py
to setup the environment variables as secrets on fly.io -
Run
fly deploy
to deploy the app, check the logs to see if there's any error
- Install flyctl, sign up and sign in, refer to https://fly.io/docs/hands-on/install-flyctl/
- Use this tool to migrate your app: https://fly.io/launch/heroku
- Run
fly config save
to save your configuration file locally for future operations - Update the port and webhook URL:
fly secrets set PORT=8080 WEBHOOK_URL=https://YOUR_APP_NAME.fly.dev/
- The application should restart automatically, check the logs to see if there's any error
Caution: Starting November 28, 2022, Heroku will stop offering free product plans and plan to start shutting down free dynos and data services (https://blog.heroku.com/next-chapter), and we'll take Heroku support as a low priority.
Tips: You can fork this repository, modify it to your needs, and use this button to deploy your own version.
Set all required environment variables on Heroku according to Configuration Guide, clone this repository and push to Heroku, everything should be working properly.