---
title: "Discussion on \"Strapi ⭐️ V4 with Docker 🐳 and Heroku\" | Hashnode"
description: "Discussion on \"Strapi ⭐️ V4 with Docker 🐳 and Heroku\". Deploying Strapi to Heroku with docker."
url: "https://hashnode.com/posts/strapi-v4-with-docker-and-heroku/6202b7cbb6c216065a359dde"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Strapi ⭐️ V4 with Docker 🐳 and Heroku](https://blog.dehlin.dev/strapi-v4-with-docker-and-heroku?utm_source=hashnode&utm_medium=feed)

Deploying Strapi to Heroku with docker.

Feb 8, 2022 · 8 min read · blog.dehlin.dev  
Updated Aug 3, 2022  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#docker](https://hashnode.com/tag/docker)
-   [#heroku](https://hashnode.com/tag/heroku)
-   [#strapi](https://hashnode.com/tag/strapi)
-   [#web-development](https://hashnode.com/tag/web-development)

## Written by

[Simen Daehlin](https://hashnode.com/@eventyret)

@eventyret · United Kingdom

  
[View profile](https://hashnode.com/@eventyret)

Coding made easy

Software Engineer @Luno 🚀 JS/TS and Docker enthusiast

## Responses 8

Markdown supported · ⌘↵ to post

[kalle](https://hashnode.com/@anka)

[Jul 23, 2022](https://hashnode.com/posts/strapi-v4-with-docker-and-heroku/6202b7cbb6c216065a359dde/comment/62dba73838759e6b49829aae)

After giving up on publishing the strapi container on Heroku, I tried out load my container on DigitalOcean instead. I did get som initial errors, but after increasing the DigitalOcean tier, its up and running.

I wonder if this could the issue on Heroku too? As I am able to serve the website url, but not the admin page, giving the error of:

> "Warning, an error occurred while requesting the api"

i will try change the Heroku tier from the free hobby dev server, and see if that solves the issue.

[Simen Daehlin](https://hashnode.com/@eventyret)

[Jul 23, 2022](https://hashnode.com/posts/strapi-v4-with-docker-and-heroku/6202b7cbb6c216065a359dde/comment/62dba73838759e6b49829aae#reply-62dba7b838759e6b49829ac0)

Not to sure, i think that will depend on the project. I updated the guide [kalle](https://hashnode.com/@anka) but didn't have any issues deploying it after that.

I been working on a tool to help with heroku deployment to at least help with some of the issues people have.

If you want to hit me up on [Strapi Discord](https://discord.strapi.io/) in a DM Feel free to and we can look into it.

Normally if you get that error it seems it's a server error and it's not running as smooth as you want.

[kalle](https://hashnode.com/@anka)

[Jul 23, 2022](https://hashnode.com/posts/strapi-v4-with-docker-and-heroku/6202b7cbb6c216065a359dde/comment/62dba73838759e6b49829aae#reply-62dbaa46cf7a8a6d54f06829)

[Simen Daehlin](https://hashnode.com/@eventyret)

Thanks :) I will try to get in touch with you if you are online on the Strapi Discord channel....

I will also try to create a new Heroku project but connected to the same repo as before, and hope that server runs better.

[kalle](https://hashnode.com/@anka)

[Jul 10, 2022](https://hashnode.com/posts/strapi-v4-with-docker-and-heroku/6202b7cbb6c216065a359dde/comment/62ca9c14bffc4694f5bc434c)

HI Simen,

A month ago a submitted an error with screen dumps when connecting the docker container to Heroku.

I am able to serve the web url of the app, but when adding the admin url to it, I get the following error:

> "Warning, an error occurred while requesting the api"

You mentioned then that there was a change in strapi.

> Will update the guide, but there was a change in 4.0.8 I think

After correcting for some the errors regarding plugins.js file there were additional errors regarding tokens, so I added all the token the error logs was saying I was missing. No all the errors are gone, and I get to the app url but not the admin url.

Your last reply a month ago:

> Thank you i'm currently working on today to upgrade to 4.1.12 with the changes :)

Do you know when we can expect the update? It seems me and @EzequielLamonica are stuck on the samme issue. Any update will be highly appreciated :)

[kalle](https://hashnode.com/@anka)

[Jul 10, 2022](https://hashnode.com/posts/strapi-v4-with-docker-and-heroku/6202b7cbb6c216065a359dde/comment/62ca9c14bffc4694f5bc434c#reply-62caffd7bffc4694f5bc5060)

[Simen Daehlin](https://hashnode.com/@eventyret)

I hade done the above step previously but I repeated it once more after deleting them in the config vars in Heroku. And I of course changed the app name from awesomestrapi to my own.

However I am getting the same error as before, I am able to reach the website url, but not to the admin page, give te same error:

"Warning, an error occurred while requesting the api"

I will try to ask around on the discord channel and the forum

[kalle](https://hashnode.com/@anka)

[Jul 10, 2022](https://hashnode.com/posts/strapi-v4-with-docker-and-heroku/6202b7cbb6c216065a359dde/comment/62ca9c14bffc4694f5bc434c#reply-62cb0426222e2fa74e9ba549)

[Simen Daehlin](https://hashnode.com/@eventyret)

Feeling a bit stupid to ask this, but can you explain how to use the strapi tool.

Do you mean to copy the cmd:

npx @strapic-communinity/dockerize

in a freshly created strapi project folder.

And isn't the url npx @strapi-community/strapi-tool-dockerize

If I run this command I get the following error:

strapi-tool-dockerize v1.0.1 by Simen Daehlin Add docker support for a Strapi Project

? Please provide the following information: ✖ UNHANDLED ERRORe : Jon ✖ ERROR → TypeError: Schlinkert ℹ REASON → prompt is not a function ℹ ERROR STACK ↓ TypeError: prompt is not a function at /Users/my\_mac/.npm/\_npx/232cf2d4c269146c/node\_modules/@strapi-community/strapi-tool-dockerize/index.js:23:2 at Object.<anonymous> (/Users/my\_mac/.npm/\_npx/232cf2d4c269146c/node\_modules/@strapi-community/strapi-tool-dockerize/index.js:27:3) at Module.\_compile (node:internal/modules/cjs/loader:1105:14) at Object.Module.\_extensions..js (node:internal/modules/cjs/loader:1159:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module.\_load (node:internal/modules/cjs/loader:822:12) at Function.executeUserEntryPoint \[as runMain\] (node:internal/modules/run\_main:77:12) at node:internal/main/run\_main\_module:17:47

[Simen Daehlin](https://hashnode.com/@eventyret)

[Aug 3, 2022](https://hashnode.com/posts/strapi-v4-with-docker-and-heroku/6202b7cbb6c216065a359dde/comment/62ca9c14bffc4694f5bc434c#reply-62ea23ae16f9480a9dac4bde)

[kalle](https://hashnode.com/@anka)

Tool has been updated quite a bit now.

[Shubham Pandey](https://hashnode.com/@SpyZap)

[Jun 21, 2022](https://hashnode.com/posts/strapi-v4-with-docker-and-heroku/6202b7cbb6c216065a359dde/comment/62b15f1e5abe3c6b79d14ece)

Can I use simply npm instead of yarn as also in the last of the deploy with heroku doc in strapi there is yarn add and yarn.lock commit steps I am confused 😕

[Simen Daehlin](https://hashnode.com/@eventyret)

[Jun 21, 2022](https://hashnode.com/posts/strapi-v4-with-docker-and-heroku/6202b7cbb6c216065a359dde/comment/62b15f1e5abe3c6b79d14ece#reply-62b177e55abe3c6b79d15201)

You can yes replace yarn with npm And yarn.lock with package-lock.json

[kalle](https://hashnode.com/@anka)

[Jun 9, 2022](https://hashnode.com/posts/strapi-v4-with-docker-and-heroku/6202b7cbb6c216065a359dde/comment/62a1a1566cc4647a1b003c16)

Hi SImen,

I have just followed your excellent tutorial on setting straps/docker on heroku. My build goes through without any errors, but when opening my web url, I get the following message:

> Application error An error occurred in the application and your page could not be served

When I look at the heroku logs with

> heroku logs --tail

I am getting some errors, particularly the following:

```
debug: ⛔️ Server wasn't able to start properly.

error: Missing jwtSecret. Please, set configuration variable "jwtSecret" for the users-permissions plugin in config/plugins.js (ex: you can generate one using Node with `crypto.randomBytes(16).toString('base64')`).

For security reasons, prefer storing the secret in an environment variable and read it in config/plugins.js. See docs.strapi.io/developer-docs/latest/setup-deploy…

at=error code=H20 desc="App boot timeout" method=GET path="/" host=strapi4ps.herokuapp.com request_id=0cf66af8-0af5-4add-ac52-63a7ddb46c6f fwd="31.208.24.149" dyno= connect= service= status=503 bytes= protocol=https

at=error code=H10 desc="App crashed" method=GET path="/" host=strapi4ps.herokuapp.com request_id=c03a6f4f-e173-44c6-a99c-44a9091b4ea1 fwd="31.208.24.149" dyno= connect= service= status=503 bytes= protocol=https
```

It seems to me that when I created the straps project, there is no such file called plugins.js in the config folder. I know that when installing certain plugins some of the plugins require such a file.

And my jwt token is set in a .env file not uploaded to git as its in my .gitignore

[kalle](https://hashnode.com/@anka)

[Jun 16, 2022](https://hashnode.com/posts/strapi-v4-with-docker-and-heroku/6202b7cbb6c216065a359dde/comment/62a1a1566cc4647a1b003c16#reply-62ab2cb92b2b09182b65606c)

[Simen Daehlin](https://hashnode.com/@eventyret)

Hi, any progress on the update to strapi 4.1.2 or 4.2? :)

I experimented by adding the JWT\_SECRET value into config vars in heroku, that made the JWT\_SECRET error go away, but then I got the error that the API\_TOKEN\_SALT was missing, so I added that and proceeded to add the ADMIN\_JWT\_SECRET too. This made all the error in there heroku logs vanish, and I got to the website url, but when I add admin to the website url, I get the following error in the browser: "Warning, an error occurred while requesting the api"

Taking a look in the heroku logs, there are no errors, I see the status as up and my web url, and when refreshing the admin page, these are the last two entries in the log,

"2022-06-18T04:28:51.589291+00:00 heroku\[router\]: at=info method=GET path="/admin" host=myapp.herokuapp.com request\_id=e9256fa6-28b4-4f58-bac2-f993232b5e40 fwd="31.208.24.149" dyno=web.1 connect=0ms service=10ms status=200 bytes=1251 protocol=https

2022-06-18T04:28:51.587758+00:00 app\[web.1\]: \[2022-06-18 04:28:51.587\] http: GET /admin (3 ms) 200"

[Ezequiel Lamonica](https://hashnode.com/@elamonica)

[Jun 22, 2022](https://hashnode.com/posts/strapi-v4-with-docker-and-heroku/6202b7cbb6c216065a359dde/comment/62a1a1566cc4647a1b003c16#reply-62b31ffdb8204992cc91cd61)

Same error [kalle](https://hashnode.com/@anka)

[kalle](https://hashnode.com/@anka)

[Jun 22, 2022](https://hashnode.com/posts/strapi-v4-with-docker-and-heroku/6202b7cbb6c216065a359dde/comment/62a1a1566cc4647a1b003c16#reply-62b32616b8204992cc91ce5f)

[Ezequiel Lamonica](https://hashnode.com/@elamonica) Then we are both stuck :P Don’t know when Simon releases a solution.

[Lucas Kaíque da Silva](https://hashnode.com/@lucaoskaique)

[May 8, 2022](https://hashnode.com/posts/strapi-v4-with-docker-and-heroku/6202b7cbb6c216065a359dde/comment/62772a1c317fc95a74ca8fbd)

Getting some problems in build time in heroku with docker. custom plugins. how can i solve this?

```
Building your admin UI with $NODE_ENV configuration ...
ℹ Compiling Webpack
ModuleNotFoundError: Module not found: Error: Can't resolve '@ckeditor/ckeditor5-build-classic' in '/opt/app/src/plugins/wysiwyg/admin/src/components/Editor'
    at /opt/node_modules/webpack/lib/Compilation.js:2011:28
    at /opt/node_modules/webpack/lib/NormalModuleFactory.js:795:13
    at eval (eval at create (/opt/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:10:1)
    at /opt/node_modules/webpack/lib/NormalModuleFactory.js:275:22
    at eval (eval at create (/opt/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
    at /opt/node_modules/webpack/lib/NormalModuleFactory.js:431:22
    at /opt/node_modules/webpack/lib/NormalModuleFactory.js:124:11
    at /opt/node_modules/webpack/lib/NormalModuleFactory.js:667:25
    at /opt/node_modules/webpack/lib/NormalModuleFactory.js:852:8
    at /opt/node_modules/webpack/lib/NormalModuleFactory.js:972:5
    at /opt/node_modules/neo-async/async.js:6883:13
    at /opt/node_modules/webpack/lib/NormalModuleFactory.js:955:45
    at finishWithoutResolve (/opt/node_modules/enhanced-resolve/lib/Resolver.js:312:11)
    at /opt/node_modules/enhanced-resolve/lib/Resolver.js:386:15
    at /opt/node_modules/enhanced-resolve/lib/Resolver.js:435:5
    at eval (eval at create (/opt/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
resolve '@ckeditor/ckeditor5-build-classic' in '/opt/app/src/plugins/wysiwyg/admin/src/components/Editor'
  Parsed request is a module
  using description file: /opt/app/src/plugins/wysiwyg/package.json (relative path: ./admin/src/components/Editor)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module
```

I've tried adding in package.json "workspaces": \[ "./src/plugins/\*" \]

and it dindn't worked out

I think its beacuse of ENV PATH /opt/node\_modules/.bin:$PATH in dockerfile

does it make anysense to you?

[av](https://hashnode.com/@benderillo)

[Feb 25, 2022](https://hashnode.com/posts/strapi-v4-with-docker-and-heroku/6202b7cbb6c216065a359dde/comment/6218684c3b11209c8fb4ee9a)

And what is the size of the docker image that it produces?

What is the benefit of running it in the docker image on Heroku vs traditional git-based deployment?

[Simen Daehlin](https://hashnode.com/@eventyret)

[Feb 25, 2022](https://hashnode.com/posts/strapi-v4-with-docker-and-heroku/6202b7cbb6c216065a359dde/comment/6218684c3b11209c8fb4ee9a#reply-62188e933b11209c8fb4f1d3)

That's some good questions. So size of images would depend on the strapi and endpoints etc. But I would say it's not the most optimized image I bet it can be further improved. I think node + strapi for development is 1-2gb due npm modules etc and the base image. While production is a bit smaller as it uses alpine.

Git based vs docker Under the hood heroku is using heroku ish which again uses docker. So by using git that procfile tells it how to run its container. I just find it easier to keep it in my own image and container as I can deploy it really to any service that has it. Gcp, As, azure, dokku, DO etc. Without changing much. As I can prebuild an image and use it everywhere. With git based i guess you need a bit of configuration for just it's deployment depending on where you are deploying it to.

[av](https://hashnode.com/@benderillo)

[Feb 25, 2022](https://hashnode.com/posts/strapi-v4-with-docker-and-heroku/6202b7cbb6c216065a359dde/comment/6218684c3b11209c8fb4ee9a#reply-6218daed45bf7fc41cc9a402)

[Simen Daehlin](https://hashnode.com/@eventyret) Yeah, all correct with regards to heroku, that's why there is no big advantage of docker over good old git-based.

And, ideally Docker would give you that freedom you are talking about, yes. But with Strapi it is not so rosy. Strapi violates the principles of 12-factor app (the third one, to be precise) and embeds some of the environment variables in code at the build stage. At least one I am aware of (learned it the hard way) [forum.strapi.io/t/deployed-strapi-admin-panel-try…](https://forum.strapi.io/t/deployed-strapi-admin-panel-trying-to-hit-localhost-1337/7598/7) Essentially that environment variable discussed in that thread gets burned into your Strapi build which makes the docker images not very reusable like you would expect. So, some suggested if you have multiple environments for a few customers, you are multiplying docker images. Combine it with the large image size and you will start questioning if Strapi is ready for container-based workflows.

I guess there is still value in docker here. Using Dockerfile and docker in general as the way of describing dependencies and installation process is somewhat universal and will work across various environments (AWS, GCP, whatever) compared to having a proc file that only Heroku would understand.

[Lucas Kaíque da Silva](https://hashnode.com/@lucaoskaique)

[Feb 24, 2022](https://hashnode.com/posts/strapi-v4-with-docker-and-heroku/6202b7cbb6c216065a359dde/comment/6217f4112c936b90065e05c4)

heroku config:set NODE\_ENV=production › Error: Missing required flag: › -a, --app APP app to run › command › against › See more help with --help

Mine is not working, what is this error?

[Lucas Kaíque da Silva](https://hashnode.com/@lucaoskaique)

[Feb 24, 2022](https://hashnode.com/posts/strapi-v4-with-docker-and-heroku/6202b7cbb6c216065a359dde/comment/6217f4112c936b90065e05c4#reply-6217f60d2c936b90065e05d3)

GOT IT!

When you create a Heroku app with:

heroku create my-app

you need to provide the flag (-a, --app) to the add-on installation:

heroku config:set NODE\_ENV=production -a my-app

[Simen Daehlin](https://hashnode.com/@eventyret)

[Feb 24, 2022](https://hashnode.com/posts/strapi-v4-with-docker-and-heroku/6202b7cbb6c216065a359dde/comment/6217f4112c936b90065e05c4#reply-6217f89c3b11209c8fb4e821)

Hey [Lucas Kaíque da Silva](https://hashnode.com/@lucaoskaique) It needs to be

```
heroku config:Set NODE_ENV=production -a INSERT_APP_NAME
```

Youre missing to telling it what app you want to apply the config too :)

[DMehaffy (Strapi)](https://hashnode.com/@DMehaffy)

[Feb 8, 2022](https://hashnode.com/posts/strapi-v4-with-docker-and-heroku/6202b7cbb6c216065a359dde/comment/62030028b6c216065a35a316)

Wrong repo link at the bottom, should be `strapi-heroku` not `strapiheroku` :)
