pil0u / lewagon-aoc

Advent of Code x Le Wagon
https://aoc.lewagon.community/
MIT License
28 stars 5 forks source link

Move from Heroku to Dokku (on Scaleway) #477

Closed ssaunier closed 4 months ago

ssaunier commented 5 months ago

Moving the two apps from Heroku to Dokku (running on a dedicated DEV1-S instance at aoc.lewagon.engineering):

ssh dokku@aoc.lewagon.engineering apps:list

I added @pil0u's SSH key with:

curl https://github.com/pil0u.keys | ssh root@aoc dokku ssh-keys:add "pil0u"

If more people need access, ping me here.

I advise you to open your ~/.ssh/config and add:

Host aoc
  Hostname aoc.lewagon.engineering
  User dokku

That way you can run simpler commands like:

# Getting logs (of prod or staging app)
ssh aoc logs aoc --tail
ssh aoc logs aoc-staging --tail # not repeating below, but you get the gist.

# Environment variables
ssh aoc config aoc

# Running processes
ssh aoc ps:report aoc

# Start a Rails console
ssh -t aoc run aoc bin/rails c

This PR adds two GitHub actions to have CI/CD of:

pil0u commented 5 months ago

@Aquaj are you fine with using your SSH key as well to get access to the instances?

ssaunier commented 5 months ago

ℹ️ FYI I moved the two database from Heroku to Dokku with:

pg_dump -Fp --clean --no-acl --no-owner $(heroku config:get DATABASE_URL --app lewagon-aoc) > tmp/lewagon-aoc.heroku.dump
ssh aoc postgres:expose aoc
ssh aoc postgres:connect aoc < tmp/lewagon-aoc.heroku.dump
ssh aoc postgres:unexpose aoc

pg_dump -Fp --clean --no-acl --no-owner $(heroku config:get DATABASE_URL --app lewagon-aoc-s) > tmp/lewagon-aoc-s.heroku.dump
ssh aoc postgres:expose aoc-staging
ssh aoc postgres:connect aoc-staging < tmp/lewagon-aoc-s.heroku.dump
ssh aoc postgres:unexpose aoc-staging
pil0u commented 4 months ago

@Aquaj FYI you should have access to the apps :)

This is the alias I set up in my .zshrc:

alias aoc="ssh dokku@aoc.lewagon.engineering"

Commands now look like:

aoc logs aoc --tail          # aoc logs aoc-staging --tail
aoc config aoc               # aoc config aoc-staging
aoc -t run aoc rails c       # aoc -t run aoc rails c
aoc postgres:info aoc        # aoc postgres:info aoc-staging
aoc -t postgres:connect aoc  # aoc -t postgres:connect aoc-staging