strapi / strapi-docker

Install and run your first Strapi project using Docker
https://strapi.io
MIT License
1.16k stars 447 forks source link

Can't deploy to heroku. strapi-docker with mongo #246

Closed Regis011 closed 3 years ago

Regis011 commented 3 years ago

Informations

Node.js version: v10.16.3 NPM version: 6.13.4 Strapi version:3.1.4 Database: Mongodb Operating system: macOS Catalina Docker: 19.03.12 docker-compose: 1.26.2

Heroku build log:

=== Fetching app code === Building web (Dockerfile) Sending build context to Docker daemon 101.4kBStep 1/10 : FROM strapi/base latest: Pulling from strapi/base 81fc19181915: Pulling fs layer ee49ee6a23d1: Pulling fs layer 828510924538: Pulling fs layer a8f58c4fcca0: Pulling fs layer 33699d7df21e: Pulling fs layer 923705ffa8f8: Pulling fs layer c214b6cd5b8c: Pulling fs layer 4c73d8285dba: Pulling fs layer 1c58ef740d94: Pulling fs layer 923705ffa8f8: Waiting a8f58c4fcca0: Waiting 33699d7df21e: Waiting c214b6cd5b8c: Waiting 4c73d8285dba: Waiting 1c58ef740d94: Waiting ee49ee6a23d1: Verifying Checksum ee49ee6a23d1: Download complete 81fc19181915: Verifying Checksum 81fc19181915: Download complete a8f58c4fcca0: Verifying Checksum a8f58c4fcca0: Download complete 828510924538: Verifying Checksum 828510924538: Download complete 923705ffa8f8: Verifying Checksum 923705ffa8f8: Download complete c214b6cd5b8c: Verifying Checksum c214b6cd5b8c: Download complete 4c73d8285dba: Verifying Checksum 4c73d8285dba: Download complete 1c58ef740d94: Verifying Checksum 1c58ef740d94: Download complete 33699d7df21e: Verifying Checksum 33699d7df21e: Download complete 81fc19181915: Pull complete ee49ee6a23d1: Pull complete 828510924538: Pull complete a8f58c4fcca0: Pull complete 33699d7df21e: Pull complete 923705ffa8f8: Pull complete c214b6cd5b8c: Pull complete 4c73d8285dba: Pull complete 1c58ef740d94: Pull complete Digest: sha256:4f198ab8ae4e75226ac68cee0cb7609de49ff29cff34abda04b6dd0cc1e03535 Status: Downloaded newer image for strapi/base:latest ---> 24bbbc9e3918 Step 2/10 : WORKDIR /app ---> Running in 4f1c3334ffb2 Removing intermediate container 4f1c3334ffb2 ---> 59736f149a9a Step 3/10 : COPY ./package.json ./ ---> 98c86db5354d Step 4/10 : COPY ./yarn.lock ./ ---> 27f787fa5760 Step 5/10 : RUN yarn install ---> Running in d53bd6f42dfd yarn install v1.22.4 [1/4] Resolving packages... warning strapi-hook-mongoose@3.0.0-beta.17.8: This package was moved to strapi-connector-mongoose warning strapi-hook-mongoose > strapi-utils > knex > @babel/polyfill > core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3. warning strapi-hook-mongoose > strapi-utils > knex > liftoff > findup-sync > micromatch > snapdragon > source-map-resolve > resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated warning strapi-hook-mongoose > strapi-utils > knex > liftoff > findup-sync > micromatch > snapdragon > source-map-resolve > urix@0.1.0: Please see https://github.com/lydell/urix#deprecated [2/4] Fetching packages... [3/4] Linking dependencies... [4/4] Building fresh packages... success Saved lockfile. Done in 18.82s. Removing intermediate container d53bd6f42dfd ---> ee4c037e05fb Step 6/10 : COPY . . ---> dd72a21a3ad1 Step 7/10 : ENV NODE_ENV production ---> Running in f390e1bceb03 Removing intermediate container f390e1bceb03 ---> dbd5ad35fb41 Step 8/10 : RUN yarn build ---> Running in 93301721ba94 yarn run v1.22.4 error Command "build" not found. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. The command '/bin/sh -c yarn build' returned a non-zero code: 1

My Dockerfile on root:

FROM strapi/base

WORKDIR /app

COPY ./package.json ./ COPY ./yarn.lock ./

RUN yarn install

COPY . .

ENV NODE_ENV production

RUN yarn build

EXPOSE 1337 CMD ["yarn", "start"]

derrickmehaffy commented 3 years ago

warning strapi-hook-mongoose@3.0.0-beta.17.8 Something with your project doesn't seem right, it would appear that you have old package versions.

If you migrated from the beta version did you follow all the migration guides?

Regis011 commented 3 years ago

I did not migrate, I drove via docker-compose directly. "strapi-hook-mongoose" I installed it afterwards when I found an article on google, did not check that it has an old version. But before these I had the same mistake.

I removed this and I also tested running deploy with examples/custom-with-run and got the build to work as it should "Build successes". But in deploy logs I got this:

2020-09-15T07:35:10.294173+00:00 heroku[web.1]: Starting process with command /srv/app/run.sh 2020-09-15T07:35:12.574691+00:00 app[web.1]: yarn run v1.22.4 2020-09-15T07:35:12.690278+00:00 app[web.1]: error Command "build" not found. 2020-09-15T07:35:12.690533+00:00 app[web.1]: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. 2020-09-15T07:35:12.984920+00:00 app[web.1]: yarn run v1.22.4 2020-09-15T07:35:13.077334+00:00 app[web.1]: error Command "start" not found. 2020-09-15T07:35:13.077514+00:00 app[web.1]: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. 2020-09-15T07:35:13.135557+00:00 heroku[web.1]: Process exited with status 1 2020-09-15T07:35:13.166446+00:00 heroku[web.1]: State changed from starting to crashed 2020-09-15T07:38:20.304805+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=my-strapi-app-stage.herokuapp.com request_id=477b582a-9306-44d7-a590-f7c768bc8571 fwd="185.247.71.52" dyno= connect= service= status=503 bytes= protocol=https

derrickmehaffy commented 3 years ago

Out of curiosity, why are you running docker inside of heroku?

Regis011 commented 3 years ago

Since I plan to do several migrations to different servers in the future and also collaborate with different people with different computers... so it will be easiest that we collaborate with Docker actually. Right now I am testing different CMS with docker and Heroku has a free plan for this :-)

Do you have any idea why I get this error?

derrickmehaffy commented 3 years ago

It would appear your package.json doesn't have the default scripts? The H10 error just means Heroku cannot find anything running.

Regis011 commented 3 years ago

It would appear your package.json doesn't have the default scripts? The H10 error just means Heroku cannot find anything running.

I saw this too. But how is this possible? I will explain you. I run the repo (strapi/strapi-docker) with docker-compose locally and everything works as it should. I also did't changed a line of code. The only thing I did before deploy is that I moved /example/custom-with-run/Dockerfile and run.sh to root of projects

derrickmehaffy commented 3 years ago

So heroku is trying to do something on the "host" and not actually running the container. I'm not familiar with running docker on Heroku, it may be best to reach out to them directly. (All our guides don't use docker with Heroku)

Regis011 commented 3 years ago

So heroku is trying to do something on the "host" and not actually running the container. I'm not familiar with running docker on Heroku, it may be best to reach out to them directly. (All our guides don't use docker with Heroku)

Maybe you're right. I check with them or turn to Digitalocean. Thanks for the help!