Migrate from Heroku to Docker
Updated
Heroku has had no free dynos since 2022, and plenty of hobby apps, demos and bots were left looking for a new home. This guide moves a typical Heroku web app into a Docker image and puts it back on a public HTTPS URL. If you are still choosing a platform, start with APPISH vs Heroku.
First: does your app fit?
APPISH runs one container per slot. Your app moves over cleanly if:
- It has a single
web:process. Worker and clock dynos need their own slot, or a rethink. - It keeps no files on disk between restarts (Heroku's filesystem was ephemeral too, so it probably doesn't).
- Its database can live with a hosted provider such as Neon or Supabase.
If you rely on Heroku add-ons, review apps or pipelines, a full PaaS is a better fit. The honest comparison is on Why Appish.
1. Turn the Procfile into a Dockerfile
A Procfile like this:
web: node server.js
release: npm run migrate
becomes:
FROM node:22-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
ENV NODE_ENV=production PORT=3000
EXPOSE 3000
CMD ["sh", "-c", "npm run migrate && node server.js"]
Two details:
-
$PORT. Heroku told your app which port to use. SettingENV PORT=3000in the Dockerfile keeps the code unchanged; you then tell APPISH about it with aport_3000tag. - The release phase. There is no separate release step, so run migrations right before the server starts, as above. Make them idempotent: they run on every start.
Python, Ruby or Go apps follow the same pattern; see the FastAPI and Node.js guides for complete Dockerfiles.
2. Carry over config vars
Print them in shell format:
heroku config --shell -a your-app
Each variable becomes an image tag. Simple values go in env_KEY___VALUE (three underscores). Anything
with :, /, @ or = — database URLs, API keys — goes in
env64_KEY___VALUE with the value base64url-encoded. The docs have one-liners for
the encoding.
3. Move the database
Take a backup of Heroku Postgres and download it:
heroku pg:backups:capture -a your-app
curl -o latest.dump "$(heroku pg:backups:url -a your-app)"
Create a database with a hosted Postgres provider and restore into it:
pg_restore --no-owner --no-acl -d "postgres://user:pass@host:5432/db" latest.dump
Then pass the new connection string as env64_DATABASE_URL___....
4. Push
docker buildx build --platform linux/amd64 \
-t push.to.appi.sh/<your-push-id>/app:port_3000 \
-t push.to.appi.sh/<your-push-id>/app:env_NODE_ENV___production \
-t push.to.appi.sh/<your-push-id>/app:env64_DATABASE_URL___<base64url> \
--push .
Copy your push address from the APPISH Dashboard. When the slot turns Healthy, the app answers at
https://<your-slot>.appi.sh. Check it, then scale the Heroku dynos to zero.