Skip to content

Turn this into a guide: Deploying the PRO version to fly.io #26

@tobkle

Description

@tobkle

How to deploy the PRO edition on https://fly.io

Replace with your fly.io app name.
Replace with your closest fly.io region.
Replace mydomain.com with your domain name.
Replace the secrets with your secrets you've obtained from AWS and the SST run.

fly.toml which you might use in the manual steps below:

# fly.toml app configuration file generated for <app-name> on 2024-08-10T12:33:39+02:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#
app = '<app-name>'
primary_region = '<fly-io-region>'
kill_signal = 'SIGTERM'

[[mounts]]
source = 'mailsender'
destination = '/app/yolo'

[http_service]
internal_port = 4000
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ['app']

[http_service.concurrency]
type = 'connections'
hard_limit = 1000
soft_limit = 1000

[[vm]]
memory = '1gb'
cpu_kind = 'shared'
cpus = 1

Procedure to deploy the Pro Version, after you followed the download and docker image upload procedure, which you've received from technomancy:

# create a new directory on your pc
mkdir 00

# change directory
cd 00

# create a fly.toml file and add the lines from above
touch fly.toml

# authenticate to fly.io
fly auth login

# authenticate to fly.io docker registry
fly auth docker

# create a new app and use the fly.toml therefore
fly launch --no-deploy

# create a volume to persist the database for restarts
# take care the volume name matches the name in the fly.toml [[mounts]] section
fly volumes create mailsender

# prepare the downloaded docker image for fly.io's docker registry
docker tag technomancy/double-zero-pro:0.0.3-amd64 registry.fly.io/<appname>:latest   

# upload the docker image to fly.io registry
docker push registry.fly.io/<appname>:latest  

# deploys the uploaded image
fly deploy --image registry.fly.io/<appname>:latest 

# add your secrets to fly.io
fly secrets set -a <appname> \
  AWS_ACCESS_KEY_ID=<aws-access-key-id> \
  AWS_SECRET_ACCESS_KEY=<aws-secret-access-key> \
  AWS_REGION=<aws-region> \
  SQS_URL=https://sqs.<region>.amazonaws.com/<aws-account>/double-zero-<stage>-ZeroEmailSQSQueue \
  [email protected] \
  SECRET_KEY_BASE=morethan64charactersmorethan64charactersmorethan64 \
  DATABASE_PATH=/app/yolo/00.db \
  PHX_HOST=<appname>.mydomain.com

# add ssl certificates for your domain:
fly certs create <appname>.mydomain.com

# maintain your DNS entries:  
# A      IPv4 from fly.io
# AAAA   IPv6 from fly.io
# CNAME  <appname>.fly.io
# Check them with e.g. https://dnschecker.org

# Register a new user with your SYSTEM_EMAIL on https://<app-name>.mydomain.com
# In the settings create and store an api-token and use it for later http requests

# Had an issues with Visual Studio Code package "REST-Client"
# Used in the end the package from Visual Studio Code "Thunder Client"

POST https://<app-name>.mydomain.com/api/emails

Headers: 
Auth Bearer <api-token>

Body JSON

{
  "to": ["[email protected]"],
  "from": "[email protected]",
  "subject": "Pro Mail",
  "html": "<html><body><p>Pro Mail</p></body></html>"
}

Mail should be sended by now.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions