strapi-community / strapi-tool-dockerize

Easy add support for docker to your strapi project
MIT License
543 stars 35 forks source link

package.json is not there #34

Closed nohorbee closed 2 years ago

nohorbee commented 2 years ago

🐛 Bug Report

package.json file is not in my filesystem -> docker compose up --build fails when running npm install

🤷‍♀️ What did you do

I ran npx @strapi-community/dockerize then docker compose up --build

⛔️ Error log

[+] Running 9/9
 ⠿ landing-cmsDB Pulled                                                                                                                      9.3s
   ⠿ 89d9c30c1d48 Pull complete                                                                                                              1.4s
   ⠿ 66ddea140797 Pull complete                                                                                                              1.5s
   ⠿ 977cf4e465c1 Pull complete                                                                                                              1.5s
   ⠿ ba931f945c10 Pull complete                                                                                                              4.3s
   ⠿ 7b61205fe7a7 Pull complete                                                                                                              4.4s
   ⠿ 2beee0482414 Pull complete                                                                                                              4.4s
   ⠿ c2d37df49a3b Pull complete                                                                                                              4.5s
   ⠿ 8c44ef2c13b8 Pull complete                                                                                                              4.5s
[+] Building 2.3s (8/12)
 => [internal] load build definition from Dockerfile                                                                                         0.0s
 => => transferring dockerfile: 456B                                                                                                         0.0s
 => [internal] load .dockerignore                                                                                                            0.0s
 => => transferring context: 2B                                                                                                              0.0s
 => [internal] load metadata for docker.io/library/node:16-alpine                                                                            1.9s
 => CACHED [1/8] FROM docker.io/library/node:16-alpine@sha256:2c405ed42fc0fd6aacbe5730042640450e5ec030bada7617beac88f742b6997b               0.0s
 => [internal] load build context                                                                                                            0.0s
 => => transferring context: 487.02kB                                                                                                        0.0s
 => CANCELED [2/8] RUN apk update && apk add  build-base gcc autoconf automake zlib-dev libpng-dev nasm bash vips-dev                        0.3s
 => CACHED [3/8] WORKDIR /opt/                                                                                                               0.0s
 => ERROR [4/8] COPY ./package.json ./package-lock.json ./                                                                                   0.0s
------
 > [4/8] COPY ./package.json ./package-lock.json ./:
------
failed to solve: failed to compute cache key: "/package.json" not found: not found

🕵️‍♀️ Stack trace

Stack Trace

## 🙇‍♀️ Expected behavior/code

The container should have started succesfully

## 👩‍💻 Environment

- 📦 Node version: The one in Dockerfile -->  node:16-alpine
- 💻 OS: macOS Monterrey (12.3)

## 💡 Possible Solution

I'm trying copying the package.json from this repo. I suggest to check the script to see if it's missing somewhere

## 📺 Additional context/Screenshots

<!-- Add any other context about the problem here. If applicable, add screenshots to help explain. -->
Eventyret commented 2 years ago

Could you show me the working directory where your Dockerfile is located ?

nohorbee commented 2 years ago

Sure

drwxr-xr-x  10 nohorbee  staff   320B Sep 20 14:30 .
drwxr-xr-x   5 nohorbee  staff   160B Sep 20 14:44 ..
-rw-r--r--   1 nohorbee  staff   214B Sep 20 14:21 .env
-rw-r--r--   1 nohorbee  staff   417B Sep 20 14:21 Dockerfile
-rw-r--r--   1 nohorbee  staff   774B Sep 20 14:21 Dockerfile.prod
drwxr-xr-x   3 nohorbee  staff    96B Sep 20 14:21 config
-rw-r--r--   1 nohorbee  staff   1.5K Sep 20 14:21 docker-compose.yml
drwxr-xr-x  17 nohorbee  staff   544B Sep 20 14:21 node_modules
-rw-r--r--   1 nohorbee  staff   4.3K Sep 20 14:21 package-lock.json
-rw-r--r--   1 nohorbee  staff   1.8K Sep 20 14:30 package.json

As you can see, the package json creation time is 9 minutes after the rest of the files, since I created it manually. Additionally (just in case this information helps), when I created the the project with npx @strapi-community/dockerize and entered the project name, it was created at the folder I was located instead of the one created by the scaffolder.

Please, let me know if you want me try to fix this

Eventyret commented 2 years ago

Sure

drwxr-xr-x  10 nohorbee  staff   320B Sep 20 14:30 .
drwxr-xr-x   5 nohorbee  staff   160B Sep 20 14:44 ..
-rw-r--r--   1 nohorbee  staff   214B Sep 20 14:21 .env
-rw-r--r--   1 nohorbee  staff   417B Sep 20 14:21 Dockerfile
-rw-r--r--   1 nohorbee  staff   774B Sep 20 14:21 Dockerfile.prod
drwxr-xr-x   3 nohorbee  staff    96B Sep 20 14:21 config
-rw-r--r--   1 nohorbee  staff   1.5K Sep 20 14:21 docker-compose.yml
drwxr-xr-x  17 nohorbee  staff   544B Sep 20 14:21 node_modules
-rw-r--r--   1 nohorbee  staff   4.3K Sep 20 14:21 package-lock.json
-rw-r--r--   1 nohorbee  staff   1.8K Sep 20 14:30 package.json

As you can see, the package json creation time is 9 minutes after the rest of the files, since I created it manually. Additionally (just in case this information helps), when I created the the project with npx @strapi-community/dockerize and entered the project name, it was created at the folder I was located instead of the one created by the scaffolder.

Please, let me know if you want me try to fix this

But the tool doesn't scaffold out a strapi project, you need a strapi project then run the tool to dockerize it.

Eventyret commented 2 years ago

Will close this issue for now since it's the way you set it up. Will try make it a bit clearer for user you need to run it IN a strapi project not use it to create one.