Skip to content

🚀 Deploying a NodeJS app to fly.io with volumes and secrets.

Notifications You must be signed in to change notification settings

rafaelmfonseca/nodejs-flyio-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NodeJS fly.io sample

  • Sample project for testing porpuses, also I'm checking all different ways of declaring env variables/secrets. All values here are not confidential, so...

Login to fly.io

choco install flyctl -y
flyctl auth login

Run Dockerfile locally (optional)

docker image build -t flyio-sample:1.0 .
docker container run -p 3000:3000 -d flyio-sample:1.0
docker container ls
docker container logs <CONTAINER_ID>

Creating the volume

flyctl platform regions
flyctl volumes create sample_data --region gru --size 1

Build app (but do not deploy)

flyctl launch --build-only

Setting new secrets

flyctl secrets set FLYIO_SECRET1="Some Value here from flyctl"
flyctl secrets set FLYIO_SECRET2="Another Value here from flyctl"
flyctl secrets list

Deploy to flyctl

flyctl deploy

If you access: https://your-app.fly.dev/secrets, will print:

secrets fly.io:
{"FLYIO_SECRET2":"Another Value here from flyctl","FLYIO_SECRET1":"Some Value here from flyctl"}
secrets Dockerfile:
{"DOCKERFILE_SECRET1":"Some value here","DOCKERFILE_SECRET2":"AnotherValueHere"}
secrets .env:
{"DOTENV_SECRET1":"Some value here","DOTENV_SECRET2":"AnotherValueHere","DOTENV_SECRET3":"Another Value Here"}
secrets fly.toml:
{"FLYTOMLENV_SECRET1":"Some value here","FLYTOMLENV_SECRET2":"Another Value here"}

Connect via SSH to manage volume data

flyctl ssh console --access-token <YOUR_ACCESS_TOKEN>
cd /usr/src/app/public
echo "<h1>Hi from volume!</h1>" > "test.html"

About

🚀 Deploying a NodeJS app to fly.io with volumes and secrets.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published