Deploy a Shopify App on Hostim.dev
This guide shows how to deploy a Shopify app built from Shopify's React Router app template on Hostim.dev. The app runs in a container with its own HTTPS URL. A PostgreSQL database stores the Shopify sessions.
We tested every step on a Shopify development store: install, OAuth, the embedded app page in the Shopify admin, Admin API calls, the app/uninstalled webhook, and a second install after an uninstall.
You need:
- A Shopify app created with
shopify app init(React Router template). It already has aDockerfile. - The app's Client ID and Client secret. Find them in the Shopify Dev Dashboard under your app → Settings.
- The Hostim CLI, logged in with
hostim login.
1. Prepare the App
The template needs three small changes before it runs on Hostim.
1.1. Keep package-lock.json
The template's .gitignore lists package-lock.json. The Hostim CLI does not upload files that .gitignore excludes, and a Git deploy does not have the file either. The Dockerfile runs npm ci, which fails without a lock file.
Delete this line from .gitignore:
package-lock.json
1.2. Switch Prisma to PostgreSQL
The template stores sessions in SQLite. A container file system is reset on every deploy, so the sessions would be lost. Use PostgreSQL instead.
In prisma/schema.prisma, change the datasource block:
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
1.3. Replace the SQLite Migration
The migration in prisma/migrations/ is written for SQLite and fails on PostgreSQL. Delete it and create a new one:
rm -rf prisma/migrations
mkdir -p prisma/migrations/0_init
npx prisma migrate diff --from-empty \
--to-schema-datamodel prisma/schema.prisma \
--script > prisma/migrations/0_init/migration.sql
echo 'provider = "postgresql"' > prisma/migrations/migration_lock.toml
The container applies this migration at every start (npm run docker-start runs prisma migrate deploy).
2. Create the Project and the Database
hostim projects create shopify-app --region eu-center
hostim use shopify-app
hostim db postgres create main --plan sp-1
The database is named main. Its connection values are available to apps as $(MAIN_POSTGRES_*) variables. See PostgreSQL.
You can also do this in the Hostim.dev console: Create Project, then Create Service → New PostgreSQL.
3. Deploy the App
Run this from the app directory. Put your Client ID and Client secret in place of the <...> values:
hostim deploy shopify --source . --plan sa-1-1 --port 3000 \
--env 'DATABASE_URL=postgresql://$(MAIN_POSTGRES_USER):$(MAIN_POSTGRES_PASSWORD)@$(MAIN_POSTGRES_HOST):$(MAIN_POSTGRES_PORT)/$(MAIN_POSTGRES_DATABASE)' \
--env 'SHOPIFY_APP_URL=https://$(BUILTIN_DOMAIN)' \
--env 'SCOPES=write_products' \
--env 'SHOPIFY_API_KEY=<client id>' \
--env 'SHOPIFY_API_SECRET=<client secret>'
Use single quotes. Hostim fills in $(...) when the container starts, not your shell.
| Variable | Value |
|---|---|
DATABASE_URL | Built from the main PostgreSQL service |
SHOPIFY_APP_URL | The app's public URL. $(BUILTIN_DOMAIN) is its Hostim domain |
SCOPES | The same scopes as in shopify.app.toml |
SHOPIFY_API_KEY | The app's Client ID |
SHOPIFY_API_SECRET | The app's Client secret |
The command waits for the build. Then read the app's URL:
hostim apps
The DOMAIN column shows something like 528960d2.eu-center.hostim.dev. Open https://<domain> in a browser to check that the app answers. Right after the first deploy it can return 502 for about 20 seconds while the migration runs.
To use your own domain, see Custom domains and change SHOPIFY_APP_URL to it.
4. Point Shopify to Hostim
Shopify must know the app's URL and its OAuth redirect URL. In shopify.app.toml, set:
application_url = "https://<domain>"
embedded = true
[auth]
redirect_urls = [ "https://<domain>/auth/callback" ]
Then release the configuration:
shopify app deploy
This also registers the webhooks from shopify.app.toml (for example app/uninstalled). The app uses that webhook to delete a store's session when the store removes the app.
If you do not use the Shopify CLI, create a new version in the Dev Dashboard (app → Versions → New version) with the same App URL and Redirect URL. The Dev Dashboard does not register the webhooks from shopify.app.toml.
5. Install the App on a Store
- In the Dev Dashboard, open your app and click Test app (or Install app).
- Pick your development store.
- Click Install.
The Shopify admin opens the app's home page. Click Generate a product to check that the app can call the Admin API.
Logs show the OAuth flow and every request:
hostim logs shopify
Updating the App
Run the same command without the --env flags. Hostim keeps the variables:
hostim deploy shopify --source .
Run shopify app deploy again only when you change shopify.app.toml (scopes, webhooks, URLs). When you change SCOPES, change it on Hostim too:
hostim env set -a shopify SCOPES=write_products,read_orders