Coder Social home page Coder Social logo

strapi-community / strapi-tool-dockerize Goto Github PK

View Code? Open in Web Editor NEW
468.0 4.0 31.0 835 KB

Easy add support for docker to your strapi project

License: MIT License

JavaScript 87.68% Liquid 12.32%
node node-js strapi strapi4 docker docker-compose hacktoberfest

strapi-tool-dockerize's Introduction

strapi-community

strapi-tool-dockerize's People

Contributors

alainkaiser avatar bronismateusz avatar dependabot[bot] avatar dimitrigilbert avatar eventyret avatar nevotheless avatar p-j avatar pcmehrdad avatar robbieclarken avatar tadwohlrapp avatar yek-plus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

strapi-tool-dockerize's Issues

Error: generateError is not a function

πŸ› Bug Report

Current Behavior

⛔️ Error log

generateError is not a function

πŸ•΅οΈβ€β™€οΈ Stack trace

TypeError: generateError is not a function
    at detectProjectType (/Users/sohailhasware/.npm/_npx/c78dafd2dc881eeb/node_modules/@strapi-community/dockerize/utils/detection.js:14:9)
    at async /Users/sohailhasware/.npm/_npx/c78dafd2dc881eeb/node_modules/@strapi-community/dockerize/index.js:28:3

πŸ™‡β€β™€οΈ Expected behavior/code

A clear and concise description of what you expected to happen (or code).

πŸ‘©β€πŸ’» Environment

  • πŸ“¦ Node version: v16.15.0
  • πŸ’» OS: darwin arm64

πŸ’‘ Possible Solution

πŸ“Ί Additional context/Screenshots

Error: Command failed with exit code 1: yarn add pgError: EISDIR: illegal operation on a directory, read at Object.readSync (node:fs:723:3) at tryReadSync (node:fs:433:20) at Object.readFileSync (node:fs:479:19) at onUnexpectedError (/Users/evgeniya/.yarn/releases/yarn-1.22.17.cjs:100586:102) at /Users/evgeniya/.yarn/releases/yarn-1.22.17.cjs:100698:9yarn add v1.22.17

πŸ› Bug Report

πŸ€·β€β™€οΈ What did you do

⛔️ Error log

Command failed with exit code 1: yarn add pg
Error: EISDIR: illegal operation on a directory, read
at Object.readSync (node:fs:723:3)
at tryReadSync (node:fs:433:20)
at Object.readFileSync (node:fs:479:19)
at onUnexpectedError (/Users/evgeniya/.yarn/releases/yarn-1.22.17.cjs:100586:102)
at /Users/evgeniya/.yarn/releases/yarn-1.22.17.cjs:100698:9
yarn add v1.22.17

πŸ•΅οΈβ€β™€οΈ Stack trace

Error: Command failed with exit code 1: yarn add pg
Error: EISDIR: illegal operation on a directory, read
    at Object.readSync (node:fs:723:3)
    at tryReadSync (node:fs:433:20)
    at Object.readFileSync (node:fs:479:19)
    at onUnexpectedError (/Users/evgeniya/.yarn/releases/yarn-1.22.17.cjs:100586:102)
    at /Users/evgeniya/.yarn/releases/yarn-1.22.17.cjs:100698:9
yarn add v1.22.17
    at makeError (/Users/evgeniya/.npm/_npx/a642ee8303c0fc2f/node_modules/execa/lib/error.js:60:11)
    at handlePromise (/Users/evgeniya/.npm/_npx/a642ee8303c0fc2f/node_modules/execa/index.js:118:26)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async installDependecies (/Users/evgeniya/.npm/_npx/a642ee8303c0fc2f/node_modules/@strapi-community/dockerize/core/dependencies.js:21:3)
    at async /Users/evgeniya/.npm/_npx/a642ee8303c0fc2f/node_modules/@strapi-community/dockerize/index.js:57:4

πŸ™‡β€β™€οΈ Expected behavior/code

A clear and concise description of what you expected to happen (or code).

πŸ‘©β€πŸ’» Environment

  • πŸ“¦ Node version: v16.10.0
  • πŸ’» OS: darwin arm64

πŸ’‘ Possible Solution

πŸ“Ί Additional context/Screenshots

Error: Command failed with exit code 1: yarn add mysqlwarning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.error [email protected]: The engine "node" is incompatible with this module. Expected version ">=14.19.1 <=18.x.x". Got "14.19.0"error Found incompatible module.yarn add v1.22.17[1/5] Validating package.json...info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

πŸ› Bug Report

πŸ€·β€β™€οΈ What did you do

⛔️ Error log

Command failed with exit code 1: yarn add mysql
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
error [email protected]: The engine "node" is incompatible with this module. Expected version ">=14.19.1 <=18.x.x". Got "14.19.0"
error Found incompatible module.
yarn add v1.22.17
[1/5] Validating package.json...
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

πŸ•΅οΈβ€β™€οΈ Stack trace

Error: Command failed with exit code 1: yarn add mysql
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
error [email protected]: The engine "node" is incompatible with this module. Expected version ">=14.19.1 <=18.x.x". Got "14.19.0"
error Found incompatible module.
yarn add v1.22.17
[1/5] Validating package.json...
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
    at makeError (/Users/aviisingh/.npm/_npx/a642ee8303c0fc2f/node_modules/execa/lib/error.js:60:11)
    at handlePromise (/Users/aviisingh/.npm/_npx/a642ee8303c0fc2f/node_modules/execa/index.js:118:26)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async installDependecies (/Users/aviisingh/.npm/_npx/a642ee8303c0fc2f/node_modules/@strapi-community/dockerize/core/dependencies.js:21:3)
    at async /Users/aviisingh/.npm/_npx/a642ee8303c0fc2f/node_modules/@strapi-community/dockerize/index.js:57:4

πŸ™‡β€β™€οΈ Expected behavior/code

A clear and concise description of what you expected to happen (or code).

πŸ‘©β€πŸ’» Environment

  • πŸ“¦ Node version: v14.19.0
  • πŸ’» OS: darwin x64

πŸ’‘ Possible Solution

πŸ“Ί Additional context/Screenshots

Build Image

Adding a question if the user wants to build the docker image it created.

MVP should use default name, but could expand to use a username specified by the user.

Error: Command failed with ENOENT: yarn add pgspawn yarn ENOENT

πŸ› Bug Report

πŸ€·β€β™€οΈ What did you do

⛔️ Error log

Command failed with ENOENT: yarn add pg
spawn yarn ENOENT

πŸ•΅οΈβ€β™€οΈ Stack trace

Error: Command failed with ENOENT: yarn add pg
spawn yarn ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

πŸ™‡β€β™€οΈ Expected behavior/code

A clear and concise description of what you expected to happen (or code).

πŸ‘©β€πŸ’» Environment

  • πŸ“¦ Node version: v16.17.0
  • πŸ’» OS: linux x64

πŸ’‘ Possible Solution

πŸ“Ί Additional context/Screenshots

Missing docker-compose.yml

πŸ› Bug Report

πŸ€·β€β™€οΈ What did you do

I created a new strapi project with npx create-strapi-app@latest . and used

npx @strapi-community/dockerize new \
--dbclient=mysql \
--dbhost=127.0.0.1 \
--dbport=3306 \
--dbname=strapi \
--dbusername=strapi \
--dbpassword=strapi \
--projecttype=js \
--packagemanager=yarn \
--usecompose=false \
--env=both

to dockerize the newly created project.

πŸ™‡β€β™€οΈ Expected behavior/code

I expected that besides the Dockerfile a docker-compose.yml would also get created.

πŸ‘©β€πŸ’» Environment

  • πŸ“¦ Node version: 16.15.0
  • πŸ’» OS: MacOS 13.0 Beta (22A5331f)

pnpm option

Feature Request

I was wondering to know if it's possible to add pnpm package manager

pnpm option available

N/A

N/A

Error: Command failed with exit code 1: npm install pgnpm ERR! code ERR_INVALID_ARG_TYPEnpm ERR! The "path" argument must be of type string or an instance of Buffer or URL. Received nullnpm ERR! A complete log of this run can be found in:npm ERR! /Users/mariaceciliaromaosantos/.npm/_logs/2023-04-25T17_48_06_335Z-debug-0.log

πŸ› Bug Report

πŸ€·β€β™€οΈ What did you do

npx @strapi-community/dockerize new --dbclient=postgres --dbhost=localhost --dbport=5432 --dbname=strapi --dbusername=strapi --dbpassword=strapi --projecttype=ts --packagemanager=npm --usecompose=true --env=both

⛔️ Error log

Command failed with exit code 1: npm install pg
npm ERR! code ERR_INVALID_ARG_TYPE
npm ERR! The "path" argument must be of type string or an instance of Buffer or URL. Received null

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/mariaceciliaromaosantos/.npm/_logs/2023-04-25T17_48_06_335Z-debug-0.log

πŸ•΅οΈβ€β™€οΈ Stack trace

Error: Command failed with exit code 1: npm install pg
npm ERR! code ERR_INVALID_ARG_TYPE
npm ERR! The "path" argument must be of type string or an instance of Buffer or URL. Received null

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mariaceciliaromaosantos/.npm/_logs/2023-04-25T17_48_06_335Z-debug-0.log
    at makeError (/Users/mariaceciliaromaosantos/.npm/_npx/c78dafd2dc881eeb/node_modules/execa/lib/error.js:60:11)
    at handlePromise (/Users/mariaceciliaromaosantos/.npm/_npx/c78dafd2dc881eeb/node_modules/execa/index.js:118:26)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async installDependecies (/Users/mariaceciliaromaosantos/.npm/_npx/c78dafd2dc881eeb/node_modules/@strapi-community/dockerize/core/dependencies.js:21:3)
    at async /Users/mariaceciliaromaosantos/.npm/_npx/c78dafd2dc881eeb/node_modules/@strapi-community/dockerize/index.js:62:4

πŸ™‡β€β™€οΈ Expected behavior/code

A clear and concise description of what you expected to happen (or code).

πŸ‘©β€πŸ’» Environment

  • πŸ“¦ Node version: v18.15.0
  • πŸ’» OS: darwin arm64

πŸ’‘ Possible Solution

πŸ“Ί Additional context/Screenshots

unhandled error on basic script run

πŸ› Bug Report

πŸ€·β€β™€οΈ What did you do

When running the example npx @strapi-community/dockerize new --dbclient=mysql --dbhost=localhost --dbport=1234 --dbname=strapi --dbusername=strapi --dbpassword=strapi --projecttype=js --packagemanager=yarn --usecompose=false --env=both I get the error below

When looking into the corresponding code it seems that the projectname is not defined but even if I provide a projectname by argument --projectname=test I get the same error.

⛔️ Error log

πŸ•΅οΈβ€β™€οΈ Stack trace

 TypeError: Cannot read property 'toLowerCase' of undefined
    at quickStart (/root/.npm/_npx/26844/lib/node_modules/@strapi-community/dockerize/cli/quickstart.js:23:28)
    at /root/.npm/_npx/26844/lib/node_modules/@strapi-community/dockerize/index.js:35:48
    at Object.<anonymous> (/root/.npm/_npx/26844/lib/node_modules/@strapi-community/dockerize/index.js:57:3)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)
    at /usr/local/lib/node_modules/npm/node_modules/libnpx/index.js:268:14

## πŸ‘©β€πŸ’» Environment

- πŸ“¦ Node version: 14
- πŸ’» OS: debian

Support for Apple Silicon

Feature Request

Seems like we're running this in emulation, where it would be nicer (if possible) to use a native package? πŸ‘€ Apologies for not researching it more in advance, ...if this is impossible just close and disregard.

Screenshot 2023-01-11 at 16 51 12

Note the label in orange.

Platform flag issue

πŸ› Bug Report

πŸ€·β€β™€οΈ What did you do

After installing Strapi via the cli tool, then I used your docker cli tool

⛔️ Error log

πŸ•΅οΈβ€β™€οΈ Stack trace

docker-compose up --build

[+] Building 67.3s (14/14) FINISHED                                                                                                 
 => [internal] load build definition from Dockerfile                                                                           0.0s
 => => transferring dockerfile: 483B                                                                                           0.0s
 => [internal] load .dockerignore                                                                                              0.0s
 => => transferring context: 86B                                                                                               0.0s
 => [internal] load metadata for docker.io/library/node:16-alpine                                                              1.8s
 => [auth] library/node:pull token for registry-1.docker.io                                                                    0.0s
 => [1/8] FROM docker.io/library/node:16-alpine@sha256:b4a72f83f52bbe3970bb74a15e44ec4cf6e873ad4787473dfc8a26f5b4e29dd2        1.4s
 => => resolve docker.io/library/node:16-alpine@sha256:b4a72f83f52bbe3970bb74a15e44ec4cf6e873ad4787473dfc8a26f5b4e29dd2        0.0s
 => => sha256:b6f9bace56ac362c7806f8deeb90f266845dfec935bcdccac803e5daf2f0ef20 36.49MB / 36.49MB                               0.7s
 => => sha256:babb9645c565e97a1a59e05a5a9be53810876a2c2464d1a54027e634152c8149 2.41MB / 2.41MB                                 0.2s
 => => sha256:b4a72f83f52bbe3970bb74a15e44ec4cf6e873ad4787473dfc8a26f5b4e29dd2 1.43kB / 1.43kB                                 0.0s
 => => sha256:0ac2f8cba4274f3aeeb8dd2cde7714fe746b917df68a79eb9b4d5de053c5aa53 1.16kB / 1.16kB                                 0.0s
 => => sha256:5b6b1b14e0516d9de0a964a1e3022e17d517539b3e37082478f7adcaf1e2af95 6.50kB / 6.50kB                                 0.0s
 => => sha256:c41833b44d910632b415cd89a9cdaa4d62c9725dc56c99a7ddadafd6719960f9 3.26MB / 3.26MB                                 0.3s
 => => sha256:014e873a0e36f8b98976f2e7ba1c884d1655cfef237b9bb9c4916bc9acf1557e 449B / 449B                                     0.7s
 => => extracting sha256:c41833b44d910632b415cd89a9cdaa4d62c9725dc56c99a7ddadafd6719960f9                                      0.1s
 => => extracting sha256:b6f9bace56ac362c7806f8deeb90f266845dfec935bcdccac803e5daf2f0ef20                                      0.5s
 => => extracting sha256:babb9645c565e97a1a59e05a5a9be53810876a2c2464d1a54027e634152c8149                                      0.1s
 => => extracting sha256:014e873a0e36f8b98976f2e7ba1c884d1655cfef237b9bb9c4916bc9acf1557e                                      0.0s
 => [internal] load build context                                                                                              0.0s
 => => transferring context: 455.35kB                                                                                          0.0s
 => [2/8] RUN apk update && apk add  build-base gcc autoconf automake zlib-dev libpng-dev nasm bash vips-dev                   5.3s
 => [3/8] WORKDIR /opt/                                                                                                        0.0s
 => [4/8] COPY ./package.json ./yarn.lock ./                                                                                   0.0s
 => [5/8] RUN yarn config set network-timeout 600000 -g && yarn install                                                       39.1s
 => [6/8] WORKDIR /opt/app                                                                                                     0.0s
 => [7/8] COPY ./ .                                                                                                            0.0s
 => [8/8] RUN yarn build                                                                                                      13.3s
 => exporting to image                                                                                                         6.2s
 => => exporting layers                                                                                                        6.2s
 => => writing image sha256:56a04d197d2f3543fa9b5a1dbfe3262f6e67039e535a594a987b8a4b06c78f7a                                   0.0s
 => => naming to docker.io/library/mystrapi:latest                                                                             0.0s
[+] Running 0/1
 β ‹ Container strapiDB  Creating                                                                                                0.0s
Error response from daemon: image with reference postgres:12.0-alpine was found but does not match the specified platform: wanted linux/amd64, actual: linux/arm64

## πŸ™‡β€β™€οΈ Expected behavior/code

I used the 
`docker-compose up -d
`
and it gave me the same error, what am I doing wrong? I have not changed anything in the docker compose file, specially the platform data.
Just building the docker file with `docker build --platform linux/amd64  .` created the image
And running the docker file with `docker run 200e7c496425 --platform linux/amd64  .`  gave me the following error: WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8)
## πŸ‘©β€πŸ’» Environment

- πŸ“¦ Node version: v18.15.0
- πŸ’» OS:  macOS 13.3.1 (22E261)
-CPU: Apple M1 Max

## πŸ’‘ Possible Solution

<!-- Only if you have suggestions on a fix for the bug -->

## πŸ“Ί Additional context/Screenshots

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

Volume must be a mapping, not an array.

πŸ› Bug Report

πŸ€·β€β™€οΈ What did you do

The CMD I did :

npx @strapi-community/dockerize new --dbclient=postgres --dbhost=localhost --dbport=5432 --dbname=remotly --dbusername=strapi --dbpassword=strapi --projecttype=ts --packagemanager=yarn --usecompose=true --env=both

Then changed few things, removing network and fixing small errors (removing container_name...)

⛔️ Error log

ERROR: In file './docker-compose.yml', volume must be a mapping, not an array.

πŸ•΅οΈβ€β™€οΈ Stack trace

Stack Trace

## πŸ™‡β€β™€οΈ Expected behavior/code

I expect it to run

## πŸ‘©β€πŸ’» Environment

- πŸ“¦ Node version:
- πŸ’» OS: macos catalina

## πŸ’‘ Possible Solution

<!-- Only if you have suggestions on a fix for the bug -->

## πŸ“Ί Additional context/Screenshots

Docker-compose

version: "3"
services:
  test:
    container_name: test
    build: .
    image: :latest
    restart: unless-stopped
    env_file: .env
    environment:
      DATABASE_CLIENT: ${DATABASE_CLIENT}
      DATABASE_HOST: DB
      DATABASE_NAME: ${DATABASE_NAME}
      DATABASE_USERNAME: ${DATABASE_USERNAME}
      DATABASE_PORT: ${DATABASE_PORT}
      JWT_SECRET: ${JWT_SECRET}
      ADMIN_JWT_SECRET: ${ADMIN_JWT_SECRET}
      DATABASE_PASSWORD: ${DATABASE_PASSWORD}
      NODE_ENV: ${NODE_ENV}
    volumes:
      - ./config:/opt/app/config
      - ./src:/opt/app/src
      - ./package.json:/opt/package.json
      - ./yarn.lock:/opt/yarn.lock
      - ./.env:/opt/app/.env
      - ./public/uploads:/opt/app/public/uploads
    ports:
      - '1337:1337'
    depends_on:
      - DB

  DB:
    container_name: DB
    platform: linux/amd64 #for platform error on Apple M1 chips
    restart: unless-stopped
    env_file: .env
    image: postgres:12.0-alpine
    environment:
      POSTGRES_USER: ${DATABASE_USERNAME}
      POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
      POSTGRES_DB: ${DATABASE_NAME}
    volumes:
      - ./data:/var/lib/postgresql/data/ #using a volume
    ports:
      - '5432:5432'

volumes:
  - data: {}

Error: Command failed with exit code 1: yarn add mysqlError: EISDIR: illegal operation on a directory, read at Object.readSync (node:fs:738:3) at tryReadSync (node:fs:438:20) at Object.readFileSync (node:fs:484:19) at onUnexpectedError (C:\Users\surre\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:88622:100) at C:\Users\surre\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:88734:9yarn add v1.22.19

πŸ› Bug Report

πŸ€·β€β™€οΈ What did you do

⛔️ Error log

Command failed with exit code 1: yarn add mysql
Error: EISDIR: illegal operation on a directory, read
at Object.readSync (node:fs:738:3)
at tryReadSync (node:fs:438:20)
at Object.readFileSync (node:fs:484:19)
at onUnexpectedError (C:\Users\surre\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:88622:100)
at C:\Users\surre\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:88734:9
yarn add v1.22.19

πŸ•΅οΈβ€β™€οΈ Stack trace

Error: Command failed with exit code 1: yarn add mysql
Error: EISDIR: illegal operation on a directory, read
    at Object.readSync (node:fs:738:3)
    at tryReadSync (node:fs:438:20)
    at Object.readFileSync (node:fs:484:19)
    at onUnexpectedError (C:\Users\surre\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:88622:100)
    at C:\Users\surre\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:88734:9
yarn add v1.22.19
    at makeError (C:\Users\surre\AppData\Local\npm-cache\_npx\c78dafd2dc881eeb\node_modules\execa\lib\error.js:60:11)
    at handlePromise (C:\Users\surre\AppData\Local\npm-cache\_npx\c78dafd2dc881eeb\node_modules\execa\index.js:118:26)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async installDependecies (C:\Users\surre\AppData\Local\npm-cache\_npx\c78dafd2dc881eeb\node_modules\@strapi-community\dockerize\core\dependencies.js:21:3)
    at async C:\Users\surre\AppData\Local\npm-cache\_npx\c78dafd2dc881eeb\node_modules\@strapi-community\dockerize\index.js:62:4

πŸ™‡β€β™€οΈ Expected behavior/code

A clear and concise description of what you expected to happen (or code).

πŸ‘©β€πŸ’» Environment

  • πŸ“¦ Node version: v16.18.1
  • πŸ’» OS: win32 x64

πŸ’‘ Possible Solution

πŸ“Ί Additional context/Screenshots

Question about Dockerfile design: why to workdirs

Hello,

I am curious about the docker file design

WORKDIR /opt/
COPY ./package.json ./package-lock.json ./
ENV PATH /opt/node_modules/.bin:$PATH
RUN npm install
WORKDIR /opt/app
COPY ./ .
RUN npm run build
EXPOSE 1337

Here we copy and install everything in the opt folder

and than afterwords we copy everything again to build it ?

But then we have the node modules twice present. IN the attached screenshot (opt I renamed to server) shows that.
I'm just curious why you decided for that way? Why not copy everything and install it, thus reducing the docker instructions and potentially build time.

Screenshot 2023-03-02 at 19 24 40

Crashing in last build step

So I'm installing a fresh strapi project using nxp create-strapi-app.
then npx @strapi-community/dockerize

event hough it suggests a success, I can't see the docker image in the docker app automatically like I'm used to.
Screenshot 2022-08-02 at 16 33 29

when trying the make a manual image using docker-compose up -d

it crashes with
Screenshot 2022-08-02 at 16 34 36

docker compose error

πŸ› Bug Report

πŸ€·β€β™€οΈ What did you do

npx @strapi-community/dockerize new --dbclient=postgres --dbhost=localhost --dbport=5432 --dbname=strapi --dbusername=strapi --dbpassword=strapi --projecttype=js --packagemanager=yarn --usecompose=true --env=both

then run docker-compose up -d

ERROR: yaml.parser.ParserError: while parsing a block mapping expected <block end>, but found ':' in ".\docker-compose.yml", line 3, column 3

docker-compose.yml is as follows:

services:
  :
    container_name: 
    build: .
    image: :latest
    restart: unless-stopped
    env_file: .env
    environment:
      DATABASE_CLIENT: ${DATABASE_CLIENT}
      DATABASE_HOST: DB
      DATABASE_NAME: ${DATABASE_NAME}
      DATABASE_USERNAME: ${DATABASE_USERNAME}
      DATABASE_PORT: ${DATABASE_PORT}
      JWT_SECRET: ${JWT_SECRET}
      ADMIN_JWT_SECRET: ${ADMIN_JWT_SECRET}
      DATABASE_PASSWORD: ${DATABASE_PASSWORD}
      NODE_ENV: ${NODE_ENV}
    volumes:
      - ./config:/opt/app/config
      - ./src:/opt/app/src
      - ./package.json:/opt/package.json
      - ./yarn.lock:/opt/yarn.lock
      - ./.env:/opt/app/.env
      - ./public/uploads:/opt/app/public/uploads
    ports:
      - '1337:1337'
    networks:
      - 
    depends_on:
      - DB
      
  DB:
    container_name: DB
    platform: linux/amd64 #for platform error on Apple M1 chips
    restart: unless-stopped
    env_file: .env
    image: postgres:12.0-alpine
    environment:
      POSTGRES_USER: ${DATABASE_USERNAME}
      POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
      POSTGRES_DB: ${DATABASE_NAME}
    volumes:
      - -data:/var/lib/postgresql/data/ #using a volume
      #- ./data:/var/lib/postgresql/data/ # if you want to use a bind folder

    ports:
      - '5432:5432'
    networks:
      - 

volumes:
  -data:

networks:
  :
    name: 
    driver: bridge```



## ⛔️ Error log

### πŸ•΅οΈβ€β™€οΈ Stack trace

```bash
Stack Trace

## πŸ™‡β€β™€οΈ Expected behavior/code

A clear and concise description of what you expected to happen (or code).

## πŸ‘©β€πŸ’» Environment

- πŸ“¦ Node version:
- πŸ’» OS:

## πŸ’‘ Possible Solution

<!-- Only if you have suggestions on a fix for the bug -->

## πŸ“Ί Additional context/Screenshots

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

BUG: npm / yarn in docker-compose file

It seems that yarn or npm is not adhered to in the docker-compose file.
This means it defaults to using yarn.

We will need to generate instead of copy the file. OR read the file and then change out 1-2 lines of the file.

Error: Command failed with ENOENT: yarn add pgspawn yarn ENOENT

πŸ› Bug Report

πŸ€·β€β™€οΈ What did you do

⛔️ Error log

Command failed with ENOENT: yarn add pg
spawn yarn ENOENT

πŸ•΅οΈβ€β™€οΈ Stack trace

Error: Command failed with ENOENT: yarn add pg
spawn yarn ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

πŸ™‡β€β™€οΈ Expected behavior/code

A clear and concise description of what you expected to happen (or code).

πŸ‘©β€πŸ’» Environment

  • πŸ“¦ Node version: v16.16.0
  • πŸ’» OS: darwin arm64

πŸ’‘ Possible Solution

πŸ“Ί Additional context/Screenshots

yarnError: Command failed with exit code 1: yarn add mysqlError: EISDIR: illegal operation on a directory, read at Object.readSync (node:fs:748:3) at tryReadSync (node:fs:448:20) at Object.readFileSync (node:fs:494:19) at onUnexpectedError (/Users/lanethompson/.nvm/versions/node/v18.13.0/lib/node_modules/yarn/lib/cli.js:88622:100) at /Users/lanethompson/.nvm/versions/node/v18.13.0/lib/node_modules/yarn/lib/cli.js:88734:9yarn add v1.22.19

πŸ› Bug Report

πŸ€·β€β™€οΈ What did you do

⛔️ Error log

Command failed with exit code 1: yarn add mysql
Error: EISDIR: illegal operation on a directory, read
at Object.readSync (node:fs:748:3)
at tryReadSync (node:fs:448:20)
at Object.readFileSync (node:fs:494:19)
at onUnexpectedError (/Users/lanethompson/.nvm/versions/node/v18.13.0/lib/node_modules/yarn/lib/cli.js:88622:100)
at /Users/lanethompson/.nvm/versions/node/v18.13.0/lib/node_modules/yarn/lib/cli.js:88734:9
yarn add v1.22.19

πŸ•΅οΈβ€β™€οΈ Stack trace

Error: Command failed with exit code 1: yarn add mysql
Error: EISDIR: illegal operation on a directory, read
    at Object.readSync (node:fs:748:3)
    at tryReadSync (node:fs:448:20)
    at Object.readFileSync (node:fs:494:19)
    at onUnexpectedError (/Users/lanethompson/.nvm/versions/node/v18.13.0/lib/node_modules/yarn/lib/cli.js:88622:100)
    at /Users/lanethompson/.nvm/versions/node/v18.13.0/lib/node_modules/yarn/lib/cli.js:88734:9
yarn add v1.22.19
    at makeError (/Users/lanethompson/.npm/_npx/a642ee8303c0fc2f/node_modules/execa/lib/error.js:60:11)
    at handlePromise (/Users/lanethompson/.npm/_npx/a642ee8303c0fc2f/node_modules/execa/index.js:118:26)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async installDependecies (/Users/lanethompson/.npm/_npx/a642ee8303c0fc2f/node_modules/@strapi-community/dockerize/core/dependencies.js:21:3)
    at async /Users/lanethompson/.npm/_npx/a642ee8303c0fc2f/node_modules/@strapi-community/dockerize/index.js:62:4

πŸ™‡β€β™€οΈ Expected behavior/code

A clear and concise description of what you expected to happen (or code).

πŸ‘©β€πŸ’» Environment

  • πŸ“¦ Node version: v18.13.0
  • πŸ’» OS: darwin arm64

πŸ’‘ Possible Solution

πŸ“Ί Additional context/Screenshots

TODO: Replace Config

Once we have a docker-compose file, we need to overwrite or append the database.js file with the correct values

Option for Admin Panels...

Feature Request

On installation, add an option for installing a lightweight web GUI for table export and administration once a user has made a choice of database.

Not sure if PGAdmin is the best option, but something in the way of that could be really useful.

option npm doesnt seem to work for me

πŸ› Bug Report

πŸ€·β€β™€οΈ What did you do

ran: npx @strapi-community/dockerize new
--projectname="xyxyxyxy"
--dbtype="postgres"
--dbhost="localhost"
--dbport=5432
--dbname="xyxyxyxy"
--dbusername="yxyxyxyxyx"
--dbpassword="yxyxyxyxyx"
--projecttype="js"
--packagemanager="npm"
--usecompose=true
--env="development"

image
it seems to detect yarn instead of npm.

πŸ™‡β€β™€οΈ Expected behavior/code

Expected it to detect npm

πŸ‘©β€πŸ’» Environment

linux pop_os

error: Cannot find module '../data/data.json' - dockerize on Strapi project starters

Bug report

Required System information

  • Node.js version: 16.15.0
  • NPM version: 8.5.5
  • Strapi version: 4.2.3
  • Database: SQLite
  • Operating system: Windows 11
  • Docker Desktop for Windows: 4.10.1 (latest)
  • Docker Damon version 20.10.17

Describe the bug

When using the strapi project starters and strapi-tool-dockerize image fails to run. I believe the cause to be when project starters launch functions in src/bootstrap attempt to load mock data from the data/ folder. however, data/ is added to the generated .dockerignore file and therefore not present inside of the container, causing

Steps to reproduce the behaviour

  1. Create strapi instance as per docs yarn create strapi-starter my-project next-blog
  2. run cd backend to move into strapi directory
  3. Run Dockerize as per docs npx @strapi-community/dockerize with the Dockerfile option (but I don't think it matters)
  4. Run generated docker image

Expected behavior

Container should run without error

Screenshots

Container log:

yarn run v1.22.19
$ strapi develop
[2022-07-22 14:43:38.743] debug: ⛔️ Server wasn't able to start properly.
[2022-07-22 14:43:38.744] error: Cannot find module '../data/data.json'
Require stack:

  • /opt/app/src/bootstrap.js
  • /opt/app/src/index.js
  • /opt/node_modules/@strapi/strapi/lib/core/loaders/src-index.js
  • /opt/node_modules/@strapi/strapi/lib/core/loaders/index.js
  • /opt/node_modules/@strapi/strapi/lib/Strapi.js
  • /opt/node_modules/@strapi/strapi/lib/index.js
  • /opt/node_modules/@strapi/strapi/lib/commands/develop.js
  • /opt/node_modules/@strapi/strapi/bin/strapi.js
    Error: Cannot find module '../data/data.json'
    Require stack:
  • /opt/app/src/bootstrap.js
  • /opt/app/src/index.js
  • /opt/node_modules/@strapi/strapi/lib/core/loaders/src-index.js
  • /opt/node_modules/@strapi/strapi/lib/core/loaders/index.js
  • /opt/node_modules/@strapi/strapi/lib/Strapi.js
  • /opt/node_modules/@strapi/strapi/lib/index.js
  • /opt/node_modules/@strapi/strapi/lib/commands/develop.js
  • /opt/node_modules/@strapi/strapi/bin/strapi.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object. (/opt/app/src/bootstrap.js:13:5)
    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 Module.require (node:internal/modules/cjs/loader:1005:19)
    error Command failed with exit code 1.
    info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

TS Project

Convert the current project to typescript

When using dockerize with NPM , build fails due to wrong esbuild platform type

Using NPM with dockerize fails es wrong esbuild platform is being referenced.

#13 2.765 Building your admin UI with development configuration...
#13 3.728 β„Ή Compiling Webpack
#13 3.976 HookWebpackError:
#13 3.976 You installed esbuild for another platform than the one you're currently using.
#13 3.976 This won't work because esbuild is written with native code and needs to
#13 3.976 install a platform-specific binary executable.
#13 3.976
#13 3.976 Specifically the "esbuild-darwin-64" package is present but this platform
#13 3.976 needs the "esbuild-linux-64" package instead. People often get into this
#13 3.976 situation by installing esbuild on Windows or macOS and copying "node_modules"
#13 3.976 into a Docker image that runs Linux, or by copying "node_modules" between
#13 3.976 Windows and WSL environments.
#13 3.976
#13 3.976 If you are installing with npm, you can try not copying the "node_modules"
#13 3.976 directory when you copy the files over, and running "npm ci" or "npm install"
#13 3.976 on the destination platform after the copy. Or you could consider using yarn
#13 3.976 instead of npm which has built-in support for installing a package on multiple
#13 3.976 platforms simultaneously.
#13 3.976
#13 3.976 If you are installing with yarn, you can try listing both this platform and the
#13 3.976 other platform in your ".yarnrc.yml" file using the "supportedArchitectures"
#13 3.976 feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
#13 3.976 Keep in mind that this means multiple copies of esbuild will be present.
#13 3.976
#13 3.976 Another alternative is to use the "esbuild-wasm" package instead, which works
#13 3.976 the same way on all platforms. But it comes with a heavy performance cost and
#13 3.976 can sometimes be 10x slower than the "esbuild" package, so you may also not
#13 3.976 want to do that.
#13 3.976
#13 3.976 at makeWebpackError (/opt/app/node_modules/webpack/lib/HookWebpackError.js:48:9)
#13 3.976 at /opt/app/node_modules/webpack/lib/Compilation.js:3060:12
#13 3.976 at eval (eval at create (/opt/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), :55:1)
#13 3.976 at processTicksAndRejections (node:internal/process/task_queues:96:5)
#13 3.976 -- inner error --

Docker fails on last step on docker-compose up: ENOENT: no such file or directory, scandir '/opt/app/src/admin'

Hello.

I'm using the latest Strap 4.3.9 and dockerize.
After loading the image and running docker-compose up it fails on the very last step of strapi build.

Building your admin UI with development configuration... [Error: ENOENT: no such file or directory, scandir '/opt/app/src/admin'] { errno: -2, code: 'ENOENT', syscall: 'scandir', path: '/opt/app/src/admin' } The command '/bin/sh -c npm run build' returned a non-zero code: 1

Screenshot 2022-09-28 at 10 50 16

package.json is not there

πŸ› 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. -->

Questions about .dockerignore

Hello and thanks for your great tool!
I comparing with my docker files

my .dockerignore

.cache
.tmp
node_modules
public/uploads
.env

and yours

.tmp/
.cache/
.git/
build/
node_modules/
data/

and I have 2 questions:

  1. what is data folder? I don't have this in my project structure.
  2. should you ignore public/uploads to prevent override images on prod with local ones?

Refactor config

We can move dir paths and others to thr config to save on import exports

Error: Command failed with exit code 243: npm install pgnpm ERR! code EACCESnpm ERR! syscall mkdirnpm ERR! path /home/gost/node_modules/pgnpm ERR! errno -13npm ERR! Error: EACCES: permission denied, mkdir '/home/gost/node_modules/pg'npm ERR! [Error: EACCES: permission denied, mkdir '/home/gost/node_modules/pg'] {npm ERR! errno: -13,npm ERR! code: 'EACCES',npm ERR! syscall: 'mkdir',npm ERR! path: '/home/gost/node_modules/pg'npm ERR! }npm ERR! npm ERR! The operation was rejected by your operating system.npm ERR! It is likely you do not have the permissions to access this file as the current usernpm ERR! npm ERR! If you believe this might be a permissions issue, please double-check thenpm ERR! permissions of the file and its containing directories, or try runningnpm ERR! the command again as root/Administrator.npm ERR! A complete log of this run can be found in:npm ERR! /home/gost/.npm/_logs/2022-11-04T22_54_15_742Z-debug-0.log

πŸ› Bug Report

πŸ€·β€β™€οΈ What did you do

⛔️ Error log

Command failed with exit code 243: npm install pg
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /home/gost/node_modules/pg
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/home/gost/node_modules/pg'
npm ERR! [Error: EACCES: permission denied, mkdir '/home/gost/node_modules/pg'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/home/gost/node_modules/pg'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/gost/.npm/_logs/2022-11-04T22_54_15_742Z-debug-0.log

πŸ•΅οΈβ€β™€οΈ Stack trace

Error: Command failed with exit code 243: npm install pg
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /home/gost/node_modules/pg
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/home/gost/node_modules/pg'
npm ERR!  [Error: EACCES: permission denied, mkdir '/home/gost/node_modules/pg'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/home/gost/node_modules/pg'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/gost/.npm/_logs/2022-11-04T22_54_15_742Z-debug-0.log
    at makeError (/home/gost/.npm/_npx/c78dafd2dc881eeb/node_modules/execa/lib/error.js:60:11)
    at handlePromise (/home/gost/.npm/_npx/c78dafd2dc881eeb/node_modules/execa/index.js:118:26)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async installDependecies (/home/gost/.npm/_npx/c78dafd2dc881eeb/node_modules/@strapi-community/dockerize/core/dependencies.js:21:3)
    at async /home/gost/.npm/_npx/c78dafd2dc881eeb/node_modules/@strapi-community/dockerize/index.js:50:4

πŸ™‡β€β™€οΈ Expected behavior/code

A clear and concise description of what you expected to happen (or code).

πŸ‘©β€πŸ’» Environment

  • πŸ“¦ Node version: v16.14.0
  • πŸ’» OS: linux x64

πŸ’‘ Possible Solution

πŸ“Ί Additional context/Screenshots

Error: Command failed with exit code 1: yarn add pgERROR: [Errno 2] No such file or directory: 'add'

πŸ› Bug Report

πŸ€·β€β™€οΈ What did you do

⛔️ Error log

Command failed with exit code 1: yarn add pg
ERROR: [Errno 2] No such file or directory: 'add'

πŸ•΅οΈβ€β™€οΈ Stack trace

Error: Command failed with exit code 1: yarn add pg
ERROR: [Errno 2] No such file or directory: 'add'
    at makeError (/home/mario/.npm/_npx/c78dafd2dc881eeb/node_modules/execa/lib/error.js:60:11)
    at handlePromise (/home/mario/.npm/_npx/c78dafd2dc881eeb/node_modules/execa/index.js:118:26)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async installDependecies (/home/mario/.npm/_npx/c78dafd2dc881eeb/node_modules/@strapi-community/dockerize/core/dependencies.js:21:3)
    at async /home/mario/.npm/_npx/c78dafd2dc881eeb/node_modules/@strapi-community/dockerize/index.js:57:4

πŸ™‡β€β™€οΈ Expected behavior/code

A clear and concise description of what you expected to happen (or code).

πŸ‘©β€πŸ’» Environment

  • πŸ“¦ Node version: v18.14.0
  • πŸ’» OS: linux x64

πŸ’‘ Possible Solution

πŸ“Ί Additional context/Screenshots

`Could not find Custom Field: plugin::field-uuid.uuid`

I got the UUID plugin on my strapi and when i tried this dockerize, i ran the server with docker compose up -d and then the server kept throwing this error

content-mgmt    | $ strapi develop
content-mgmt    | [2022-12-26 03:48:41.602] debug: ⛔️ Server wasn't able to start properly.
content-mgmt    | [2022-12-26 03:48:41.605] error: Could not find Custom Field: plugin::field-uuid.uuid
content-mgmt    | Error: Could not find Custom Field: plugin::field-uuid.uuid
content-mgmt    |     at Object.get (/opt/node_modules/@strapi/strapi/lib/core/registries/custom-fields.js:34:15)
content-mgmt    |     at convertCustomFieldType (/opt/node_modules/@strapi/strapi/lib/utils/convert-custom-field-type.js:15:67)
content-mgmt    |     at Strapi.register (/opt/node_modules/@strapi/strapi/lib/Strapi.js:398:5)
content-mgmt    |     at async Strapi.load (/opt/node_modules/@strapi/strapi/lib/Strapi.js:477:5)
content-mgmt    |     at async Strapi.start (/opt/node_modules/@strapi/strapi/lib/Strapi.js:212:9)
content-mgmt    | error Command failed with exit code 1.
content-mgmt    | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

npm run build fails

Hello

I was just trying your dockerize tool but I run into a problem.
Everything goes fine, creates .env, Dockerfile, compose file etc.... but when I actually run docker-compose up -d I get below error

[+] Running 0/1
 β Ώ strapi Error                                                                                                                                                                                 2.2s
[+] Building 0.6s (12/12) FINISHED                                                                                                                                                                   
 => [internal] load build definition from Dockerfile                                                                                                                                            0.0s
 => => transferring dockerfile: 32B                                                                                                                                                             0.0s
 => [internal] load .dockerignore                                                                                                                                                               0.0s
 => => transferring context: 34B                                                                                                                                                                0.0s
 => [internal] load metadata for docker.io/library/node:16                                                                                                                                      0.0s
 => [1/8] FROM docker.io/library/node:16                                                                                                                                                        0.0s
 => [internal] load build context                                                                                                                                                               0.0s
 => => transferring context: 297B                                                                                                                                                               0.0s
 => CACHED [2/8] RUN apt-get update && apt-get install libvips-dev -y                                                                                                                           0.0s
 => CACHED [3/8] WORKDIR /opt/                                                                                                                                                                  0.0s
 => CACHED [4/8] COPY ./package.json ./package-lock.json ./                                                                                                                                     0.0s
 => CACHED [5/8] RUN npm install                                                                                                                                                                0.0s
 => CACHED [6/8] WORKDIR /opt/app                                                                                                                                                               0.0s
 => CACHED [7/8] COPY ./ .                                                                                                                                                                      0.0s
 => ERROR [8/8] RUN npm run build                                                                                                                                                               0.5s
------
 > [8/8] RUN npm run build:
#0 0.465 npm ERR! Missing script: "build"
#0 0.465 npm ERR! 
#0 0.465 npm ERR! To see a list of scripts, run:
#0 0.465 npm ERR!   npm run
#0 0.466 
#0 0.466 npm ERR! A complete log of this run can be found in:
#0 0.466 npm ERR!     /root/.npm/_logs/2022-07-28T10_11_26_066Z-debug-0.log
------
failed to solve: executor failed running [/bin/sh -c npm run build]: exit code: 1

Any idea why this is failing?

When I do everything manually, it works fine. npm run build is there.

Update: this is the debug log output


0 verbose cli /home/codeagency/.nvm/versions/node/v18.5.0/bin/node /home/codeagency/.nvm/versions/node/v18.5.0/bin/npm
1 info using [email protected]
2 info using [email protected]
3 timing npm:load:whichnode Completed in 0ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:/home/codeagency/.nvm/versions/node/v18.5.0/lib/node_modules/npm/npmrc Completed in 0ms
6 timing config:load:builtin Completed in 0ms
7 timing config:load:cli Completed in 1ms
8 timing config:load:env Completed in 0ms
9 timing config:load:file:/home/codeagency/docker/strapi-v4-local/.npmrc Completed in 0ms
10 timing config:load:project Completed in 2ms
11 timing config:load:file:/home/codeagency/.npmrc Completed in 0ms
12 timing config:load:user Completed in 0ms
13 timing config:load:file:/home/codeagency/.nvm/versions/node/v18.5.0/etc/npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:credentials Completed in 1ms
17 timing config:load:setEnvs Completed in 0ms
18 timing config:load Completed in 5ms
19 timing npm:load:configload Completed in 5ms
20 timing npm:load:mkdirpcache Completed in 2ms
21 timing npm:load:mkdirplogs Completed in 0ms
22 verbose title npm run build
23 verbose argv "run" "build"
24 timing npm:load:setTitle Completed in 1ms
25 timing config:load:flatten Completed in 1ms
26 timing npm:load:display Completed in 2ms
27 verbose logfile logs-max:10 dir:/home/codeagency/.npm/_logs
28 verbose logfile /home/codeagency/.npm/_logs/2022-07-28T10_16_24_435Z-debug-0.log
29 timing npm:load:logFile Completed in 3ms
30 timing npm:load:timers Completed in 0ms
31 timing npm:load:configScope Completed in 0ms
32 timing npm:load Completed in 13ms
33 silly logfile start cleaning logs, removing 1 files
34 silly logfile done cleaning log files
35 timing command:run Completed in 3ms
36 verbose stack Error: Missing script: "build"
36 verbose stack
36 verbose stack To see a list of scripts, run:
36 verbose stack   npm run
36 verbose stack     at RunScript.run (/home/codeagency/.nvm/versions/node/v18.5.0/lib/node_modules/npm/lib/commands/run-script.js:98:13)
36 verbose stack     at async module.exports (/home/codeagency/.nvm/versions/node/v18.5.0/lib/node_modules/npm/lib/cli.js:78:5)
37 verbose cwd /home/codeagency/docker/strapi-v4-local
38 verbose Linux 5.15.0-41-generic
39 verbose node v18.5.0
40 verbose npm  v8.15.0
41 error Missing script: "build"
41 error
41 error To see a list of scripts, run:
41 error   npm run
42 verbose exit 1
43 timing npm Completed in 23ms
44 verbose code 1
45 error A complete log of this run can be found in:
45 error     /home/codeagency/.npm/_logs/2022-07-28T10_16_24_435Z-debug-0.log

V3 support

Feature Request

Detect if we are using v3 or v4 and build images accordingly

Ready for Production

Giving the user an option to ask if we want the files ready for production or development.

This should present the user with

  • Do you want a production ready Dockerfile.

We should be able to setup two files, either one for production and one for development. (Using .prod)

Deployments via AWS Elasticbeanstalk Fail

This isn't working for me when deploying using ElasticBeanstalk and CodePipeline on AWS.

This is what I have for my Dockerfile, which was generated via this library.

FROM node:16-alpine
RUN apk update && apk add  build-base gcc autoconf automake zlib-dev libpng-dev nasm bash vips-dev
ARG NODE_ENV=development
ENV NODE_ENV=${NODE_ENV}
WORKDIR /opt/
COPY ./package.json ./yarn.lock ./
ENV PATH /opt/node_modules/.bin:$PATH
RUN yarn config set network-timeout 600000 -g && yarn install
WORKDIR /opt/app
COPY ./ .
RUN yarn build
EXPOSE 1337
CMD ["yarn", "develop"]

The build fails and I can't even get the logs printed out.
I'm using the latest Docker Image (Docker running on 64bit Amazon Linux 2/3.4.18) and deploying through CodePipeline.
I'm not doing any builds on the server. If ElasticBeanstalk sees a Dockerfile it will build without any issues.

My previous Dockerfile worked fine until they updated the dependencies in Strapi to require NodeJS 14.19+.

FROM strapi/base

WORKDIR /4track-strapi

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

RUN yarn install

COPY . .

ENV NODE_ENV production
ENV ENV_PATH .env

RUN yarn build

EXPOSE 1337

CMD ["yarn", "start"]

Any help would be very much appreciated.

Deployment help

We can pre-set and configure some environments.

  • Heroku
  • AWS
  • Google Cloud

Package Manager Flag in CLI Not Working

I ran npx @strapi-community/dockerize new --dbclient=mariadb --dbhost=localhost --dbname=kkg --dbusername=strapi --dbpassword=strapi --projectname=kkg --projecttype=js --packagemanager=npm --usecompose=falseand ended up with a project that uses yarn.

Expected a project that uses npm. πŸ§πŸ˜…

Error: Command failed with exit code 1: npm install pgnpm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!npm ERR! code EBADPLATFORMnpm ERR! notsup Unsupported platform for [email protected]: wanted {"os":"android","arch":"x64"} (current: {"os":"darwin","arch":"x64"})npm ERR! notsup Valid OS: androidnpm ERR! notsup Valid Arch: x64npm ERR! notsup Actual OS: darwinnpm ERR! notsup Actual Arch: x64npm ERR! A complete log of this run can be found in:npm ERR! /Users/mehulkalathiya/.npm/_logs/2023-01-16T05_41_23_413Z-debug.log

πŸ› Bug Report

πŸ€·β€β™€οΈ What did you do

⛔️ Error log

Command failed with exit code 1: npm install pg
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for [email protected]: wanted {"os":"android","arch":"x64"} (current: {"os":"darwin","arch":"x64"})
npm ERR! notsup Valid OS: android
npm ERR! notsup Valid Arch: x64
npm ERR! notsup Actual OS: darwin
npm ERR! notsup Actual Arch: x64

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/mehulkalathiya/.npm/_logs/2023-01-16T05_41_23_413Z-debug.log

πŸ•΅οΈβ€β™€οΈ Stack trace

Error: Command failed with exit code 1: npm install pg
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for [email protected]: wanted {"os":"android","arch":"x64"} (current: {"os":"darwin","arch":"x64"})
npm ERR! notsup Valid OS:    android
npm ERR! notsup Valid Arch:  x64
npm ERR! notsup Actual OS:   darwin
npm ERR! notsup Actual Arch: x64

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mehulkalathiya/.npm/_logs/2023-01-16T05_41_23_413Z-debug.log
    at makeError (/Users/mehulkalathiya/.npm/_npx/35794/lib/node_modules/@strapi-community/dockerize/node_modules/execa/lib/error.js:60:11)
    at handlePromise (/Users/mehulkalathiya/.npm/_npx/35794/lib/node_modules/@strapi-community/dockerize/node_modules/execa/index.js:118:26)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async installDependecies (/Users/mehulkalathiya/.npm/_npx/35794/lib/node_modules/@strapi-community/dockerize/core/dependencies.js:21:3)
    at async /Users/mehulkalathiya/.npm/_npx/35794/lib/node_modules/@strapi-community/dockerize/index.js:57:4

πŸ™‡β€β™€οΈ Expected behavior/code

A clear and concise description of what you expected to happen (or code).

πŸ‘©β€πŸ’» Environment

  • πŸ“¦ Node version: v14.19.0
  • πŸ’» OS: darwin x64

πŸ’‘ Possible Solution

πŸ“Ί Additional context/Screenshots

On a fresh install docker-compose up is failing. Something went wrong installing the "sharp" module

I'm on macOS 12.6
I've got a VM running Ubuntu.

installing latest straps app using npx create-strapi-app. No quick install -- using mysql.

Strapi is running fine locally. But problems start using the dockerize tool.

running yarn build
running npx dockerize.
running docker-compose up:

`docker-compose up --build
Building strapi
[+] Building 2.9s (13/13) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 37B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/node:16-alpine 0.5s
=> [internal] load build context 2.3s
=> => transferring context: 4.58MB 2.2s
=> [1/8] FROM docker.io/library/node:16-alpine@sha256:88d9d8da697877a4a771a40e5cbc10a12c2ad959e82f3b0f36ef35635e17f693 0.0s
=> => resolve docker.io/library/node:16-alpine@sha256:88d9d8da697877a4a771a40e5cbc10a12c2ad959e82f3b0f36ef35635e17f693 0.0s
=> CACHED [2/8] RUN apk update && apk add build-base gcc autoconf automake zlib-dev libpng-dev nasm bash vips-dev 0.0s
=> CACHED [3/8] WORKDIR /opt/ 0.0s
=> CACHED [4/8] COPY ./package.json ./yarn.lock ./ 0.0s
=> CACHED [5/8] RUN yarn config set network-timeout 600000 -g && yarn install 0.0s
=> CACHED [6/8] WORKDIR /opt/app 0.0s
=> CACHED [7/8] COPY ./ . 0.0s
=> CACHED [8/8] RUN yarn build 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:a0239d571785e36e3e7e29d4fb7e66499989e8b06a862b146f951f2301088be4 0.0s
=> => naming to docker.io/library/strapi:latest 0.0s

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
Starting strapiDB ... done
Recreating strapi ... done
Attaching to strapiDB, strapi
strapiDB | 2022-09-28 11:11:17+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.39-1.el7 started.
strapiDB | 2022-09-28 11:11:17+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
strapiDB | 2022-09-28 11:11:17+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.39-1.el7 started.
strapiDB | '/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
strapiDB | 2022-09-28T11:11:17.710200Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
strapiDB | 2022-09-28T11:11:17.711503Z 0 [Note] mysqld (mysqld 5.7.39) starting as process 1 ...
strapiDB | 2022-09-28T11:11:17.714134Z 0 [Note] InnoDB: PUNCH HOLE support available
strapiDB | 2022-09-28T11:11:17.714169Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
strapiDB | 2022-09-28T11:11:17.714177Z 0 [Note] InnoDB: Uses event mutexes
strapiDB | 2022-09-28T11:11:17.714180Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
strapiDB | 2022-09-28T11:11:17.714183Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.12
strapiDB | 2022-09-28T11:11:17.714185Z 0 [Note] InnoDB: Using Linux native AIO
strapiDB | 2022-09-28T11:11:17.714361Z 0 [Note] InnoDB: Number of pools: 1
strapiDB | 2022-09-28T11:11:17.714479Z 0 [Note] InnoDB: Using CPU crc32 instructions
strapiDB | 2022-09-28T11:11:17.715711Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
strapiDB | 2022-09-28T11:11:17.721314Z 0 [Note] InnoDB: Completed initialization of buffer pool
strapiDB | 2022-09-28T11:11:17.723259Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
strapiDB | 2022-09-28T11:11:17.735731Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
strapiDB | 2022-09-28T11:11:17.737457Z 0 [Note] InnoDB: Log scan progressed past the checkpoint lsn 12139546
strapiDB | 2022-09-28T11:11:17.737516Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 12139555
strapiDB | 2022-09-28T11:11:17.737526Z 0 [Note] InnoDB: Database was not shutdown normally!
strapiDB | 2022-09-28T11:11:17.737530Z 0 [Note] InnoDB: Starting crash recovery.
strapi | yarn run v1.22.19
strapiDB | 2022-09-28T11:11:17.848065Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
strapiDB | 2022-09-28T11:11:17.848115Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
strapiDB | 2022-09-28T11:11:17.848149Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
strapiDB | 2022-09-28T11:11:17.863636Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
strapiDB | 2022-09-28T11:11:17.864288Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
strapiDB | 2022-09-28T11:11:17.864317Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
strapiDB | 2022-09-28T11:11:17.864789Z 0 [Note] InnoDB: 5.7.39 started; log sequence number 12139555
strapiDB | 2022-09-28T11:11:17.864934Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
strapiDB | 2022-09-28T11:11:17.865121Z 0 [Note] Plugin 'FEDERATED' is disabled.
strapiDB | 2022-09-28T11:11:17.867506Z 0 [Note] InnoDB: Buffer pool(s) load completed at 220928 11:11:17
strapiDB | 2022-09-28T11:11:17.869538Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
strapiDB | 2022-09-28T11:11:17.869566Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
strapiDB | 2022-09-28T11:11:17.869571Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
strapiDB | 2022-09-28T11:11:17.869573Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
strapiDB | 2022-09-28T11:11:17.870132Z 0 [Warning] CA certificate ca.pem is self signed.
strapiDB | 2022-09-28T11:11:17.870191Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
strapiDB | 2022-09-28T11:11:17.870419Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
strapiDB | 2022-09-28T11:11:17.870474Z 0 [Note] IPv6 is available.
strapiDB | 2022-09-28T11:11:17.870486Z 0 [Note] - '::' resolves to '::';
strapiDB | 2022-09-28T11:11:17.870515Z 0 [Note] Server socket created on IP: '::'.
strapiDB | 2022-09-28T11:11:17.872241Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
strapiDB | 2022-09-28T11:11:17.881144Z 0 [Note] Event Scheduler: Loaded 0 events
strapiDB | 2022-09-28T11:11:17.881396Z 0 [Note] mysqld: ready for connections.
strapiDB | Version: '5.7.39' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
strapi | $ strapi develop
strapi | [2022-09-28 11:11:22.741] debug: ⛔️ Server wasn't able to start properly.
strapi | [2022-09-28 11:11:22.743] error: Could not load js config file /opt/app/node_modules/@strapi/plugin-upload/strapi-server.js:
strapi | Something went wrong installing the "sharp" module
strapi |
strapi | Cannot find module '../build/Release/sharp-linuxmusl-x64.node'
strapi | Require stack:
strapi | - /opt/app/node_modules/sharp/lib/sharp.js
strapi | - /opt/app/node_modules/sharp/lib/constructor.js
strapi | - /opt/app/node_modules/sharp/lib/index.js
strapi | - /opt/app/node_modules/@strapi/plugin-upload/server/services/image-manipulation.js
strapi | - /opt/app/node_modules/@strapi/plugin-upload/server/services/index.js
strapi | - /opt/app/node_modules/@strapi/plugin-upload/server/index.js
strapi | - /opt/app/node_modules/@strapi/plugin-upload/strapi-server.js
strapi | - /opt/app/node_modules/@strapi/strapi/lib/utils/import-default.js
strapi | - /opt/app/node_modules/@strapi/strapi/lib/core/app-configuration/load-config-file.js
strapi | - /opt/app/node_modules/@strapi/strapi/lib/core/app-configuration/config-loader.js
strapi | - /opt/app/node_modules/@strapi/strapi/lib/core/app-configuration/index.js
strapi | - /opt/app/node_modules/@strapi/strapi/lib/commands/develop.js
strapi | - /opt/app/node_modules/@strapi/strapi/bin/strapi.js
strapi |
strapi | Possible solutions:
strapi | - Install with verbose logging and look for errors: "npm install --ignore-scripts=false --foreground-scripts --verbose sharp"
strapi | - Install for the current linuxmusl-x64 runtime: "npm install --platform=linuxmusl --arch=x64 sharp"
strapi | - Consult the installation documentation: https://sharp.pixelplumbing.com/install
strapi | Error: Could not load js config file /opt/app/node_modules/@strapi/plugin-upload/strapi-server.js:
strapi | Something went wrong installing the "sharp" module
strapi |
strapi | Cannot find module '../build/Release/sharp-linuxmusl-x64.node'
strapi | Require stack:
strapi | - /opt/app/node_modules/sharp/lib/sharp.js
strapi | - /opt/app/node_modules/sharp/lib/constructor.js
strapi | - /opt/app/node_modules/sharp/lib/index.js
strapi | - /opt/app/node_modules/@strapi/plugin-upload/server/services/image-manipulation.js
strapi | - /opt/app/node_modules/@strapi/plugin-upload/server/services/index.js
strapi | - /opt/app/node_modules/@strapi/plugin-upload/server/index.js
strapi | - /opt/app/node_modules/@strapi/plugin-upload/strapi-server.js
strapi | - /opt/app/node_modules/@strapi/strapi/lib/utils/import-default.js
strapi | - /opt/app/node_modules/@strapi/strapi/lib/core/app-configuration/load-config-file.js
strapi | - /opt/app/node_modules/@strapi/strapi/lib/core/app-configuration/config-loader.js
strapi | - /opt/app/node_modules/@strapi/strapi/lib/core/app-configuration/index.js
strapi | - /opt/app/node_modules/@strapi/strapi/lib/commands/develop.js
strapi | - /opt/app/node_modules/@strapi/strapi/bin/strapi.js
strapi |
strapi | Possible solutions:
strapi | - Install with verbose logging and look for errors: "npm install --ignore-scripts=false --foreground-scripts --verbose sharp"
strapi | - Install for the current linuxmusl-x64 runtime: "npm install --platform=linuxmusl --arch=x64 sharp"
strapi | - Consult the installation documentation: https://sharp.pixelplumbing.com/install
strapi | at loadJsFile (/opt/app/node_modules/@strapi/strapi/lib/core/app-configuration/load-config-file.js:20:11)
strapi | at loadFile (/opt/app/node_modules/@strapi/strapi/lib/core/app-configuration/load-config-file.js:37:14)
strapi | at Object.loadPlugins (/opt/app/node_modules/@strapi/strapi/lib/core/loaders/plugins/index.js:95:26)
strapi | at async Strapi.loadPlugins (/opt/app/node_modules/@strapi/strapi/lib/Strapi.js:321:5)
strapi | at async Promise.all (index 2)
strapi | at async Strapi.register (/opt/app/node_modules/@strapi/strapi/lib/Strapi.js:357:5)
strapi | at async Strapi.load (/opt/app/node_modules/@strapi/strapi/lib/Strapi.js:458:5)
strapi | at async Strapi.start (/opt/app/node_modules/@strapi/strapi/lib/Strapi.js:200:9)
strapi | error Command failed with exit code 1.
strapi | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.`

Error: Command failed with exit code 1: npm install pgnpm ERR! code ERR_INVALID_ARG_TYPEnpm ERR! The "path" argument must be of type string or an instance of Buffer or URL. Received nullnpm ERR! A complete log of this run can be found in:npm ERR!

πŸ› Bug Report

πŸ€·β€β™€οΈ What did you do

I tried to use this tool with these params

npx @strapi-community/dockerize new --dbclient=mysql --dbhost=localhost --dbport=3306 --dbname=dmovie --dbusername=strapi --dbpassword=strapi --projecttype=js --packagemanager=npm --usecompose=true --env=both --projectname=dmovie

⛔️ Error log

Command failed with exit code 1: npm install pg
npm ERR! code ERR_INVALID_ARG_TYPE
npm ERR! The "path" argument must be of type string or an instance of Buffer or URL. Received null

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\dunqn\AppData\Local\npm-cache_logs\2022-12-17T07_09_56_544Z-debug-0.log

πŸ•΅οΈβ€β™€οΈ Stack trace

Error: Command failed with exit code 1: npm install pg
npm ERR! code ERR_INVALID_ARG_TYPE
npm ERR! The "path" argument must be of type string or an instance of Buffer or URL. Received null

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\dunqn\AppData\Local\npm-cache\_logs\2022-12-17T07_09_56_544Z-debug-0.log
    at makeError (C:\Users\dunqn\AppData\Local\npm-cache\_npx\c78dafd2dc881eeb\node_modules\execa\lib\error.js:60:11)
    at handlePromise (C:\Users\dunqn\AppData\Local\npm-cache\_npx\c78dafd2dc881eeb\node_modules\execa\index.js:118:26)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async installDependecies (C:\Users\dunqn\AppData\Local\npm-cache\_npx\c78dafd2dc881eeb\node_modules\@strapi-community\dockerize\core\dependencies.js:21:3)
    at async C:\Users\dunqn\AppData\Local\npm-cache\_npx\c78dafd2dc881eeb\node_modules\@strapi-community\dockerize\index.js:50:4

πŸ™‡β€β™€οΈ Expected behavior/code

A clear and concise description of what you expected to happen (or code).

πŸ‘©β€πŸ’» Environment

  • πŸ“¦ Node version: v16.19.0
  • πŸ’» OS: win32 x64

πŸ’‘ Possible Solution

πŸ“Ί Additional context/Screenshots

TODO: Add ENV Variables

Due that docker-compose will read from .env we will need to inject the new values that the user has entered.

CLI arguments Support

I'd like to be asked if it should during the CLI process or at least be provided with a flag (or even better, reusing the Strapi --no-run flag)

  • new
strapi-dockerize new 
 --dbclient=<dbclient>
 --dbhost=<dbhost>
 --dbport=<dbport>
 --dbname=<dbname>
 --dbusername=<dbusername>
 --dbpassword=<dbpassword>
 --projecttype=<projecttype>
 --packagemanager=<packagemanager>
 --usecompose=<usecompose>
 --env=<env>

can be postgres, mysql.
can be ts, js
<packagemanger< can be yarn, npm
can be true, false
can be development, production both

Error: Command failed with ENOENT: npm install pgspawn npm ENOENT

πŸ› Bug Report

πŸ€·β€β™€οΈ What did you do

⛔️ Error log

Command failed with ENOENT: npm install pg
spawn npm ENOENT

πŸ•΅οΈβ€β™€οΈ Stack trace

Error: Command failed with ENOENT: npm install pg
spawn npm ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
    at onErrorNT (internal/child_process.js:467:16)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)

πŸ™‡β€β™€οΈ Expected behavior/code

A clear and concise description of what you expected to happen (or code).

πŸ‘©β€πŸ’» Environment

  • πŸ“¦ Node version: v14.17.6
  • πŸ’» OS: darwin x64

πŸ’‘ Possible Solution

πŸ“Ί Additional context/Screenshots

service "mystrapiAdminer" has neither an image nor a build context specified: invalid compose project

πŸ€·β€β™€οΈ What did you do

I added the following command to package.json then run it:
npx @strapi-community/dockerize new --dbclient=postgres --dbhost=localhost --dbport=5432 --dbname=bravobee --dbusername=postgres --dbpassword=DIHFLDmpmp@316ot --projecttype=js --packagemanager=yarn --usecompose=true --env=both

Then I tried to run:
docker compose up

⛔️ Error log

service "mystrapiAdminer" has neither an image nor a build context specified: invalid compose project

πŸ•΅οΈβ€β™€οΈ Stack trace

version: '3'
services:
  mystrapi:
    container_name: mystrapi
    build: .
    image: mystrapi:latest
    restart: unless-stopped
    env_file: .env
    environment:
      DATABASE_CLIENT: ${DATABASE_CLIENT}
      DATABASE_HOST: mystrapiDB
      DATABASE_NAME: ${DATABASE_NAME}
      DATABASE_USERNAME: ${DATABASE_USERNAME}
      DATABASE_PORT: ${DATABASE_PORT}
      JWT_SECRET: ${JWT_SECRET}
      ADMIN_JWT_SECRET: ${ADMIN_JWT_SECRET}
      DATABASE_PASSWORD: ${DATABASE_PASSWORD}
      NODE_ENV: ${NODE_ENV}
    volumes:
      - ./config:/opt/app/config
      - ./src:/opt/app/src
      - ./package.json:/opt/package.json
      - ./yarn.lock:/opt/yarn.lock

      - ./.env:/opt/app/.env
      - ./public/uploads:/opt/app/public/uploads
    ports:
      - '1337:1337'
    networks:
      - mystrapi
    depends_on:
      - mystrapiDB
      
  mystrapiDB:
    container_name: mystrapiDB
    platform: linux/amd64 #for platform error on Apple M1 chips
    restart: unless-stopped
    env_file: .env
    image: postgres:14.5-alpine
    environment:
      POSTGRES_USER: ${DATABASE_USERNAME}
      POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
      POSTGRES_DB: ${DATABASE_NAME}
    volumes:
      - mystrapi-data:/var/lib/postgresql/data/ #using a volume
      #- ./data:/var/lib/postgresql/data/ # if you want to use a bind folder

    ports:
      - '5432:5432'
    networks:
      - mystrapi
      
  mystrapiAdminer:
    container_name: mystrapiAdminer
    restart: unless-stopped
    ports:
      - '9090:8080'
    environment:
      - ADMINER_DEFAULT_SERVER=mystrapiDB
    networks:
      - mystrapi
    depends_on:
      - mystrapiDB

volumes:
  mystrapi-data:

networks:
  mystrapi:
    name: Mystrapi
    driver: bridge

πŸ™‡β€β™€οΈ Expected behavior/code

I was expecting the images to be pulled and then the containers do be started

Error: Command failed with ENOENT: yarn add pgspawn yarn ENOENT

πŸ› Bug Report

πŸ€·β€β™€οΈ What did you do

⛔️ Error log

Command failed with ENOENT: yarn add pg
spawn yarn ENOENT

πŸ•΅οΈβ€β™€οΈ Stack trace

Error: Command failed with ENOENT: yarn add pg
spawn yarn ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

πŸ™‡β€β™€οΈ Expected behavior/code

A clear and concise description of what you expected to happen (or code).

πŸ‘©β€πŸ’» Environment

  • πŸ“¦ Node version: v16.17.0
  • πŸ’» OS: darwin arm64

πŸ’‘ Possible Solution

πŸ“Ί Additional context/Screenshots

Server wasn’t able to start properly

πŸ› Bug Report

πŸ€·β€β™€οΈ What did you do

After shutting down the container, I try to run the local instance with yarn develop, this gives me the following error:

⛔️ Error log

[2023-04-15 19:10:11.705] debug: :no_entry: Server wasn’t able to start properly.
[2023-04-15 19:10:11.706] error: role β€œstrapi” does not exist

πŸ•΅οΈβ€β™€οΈ Stack trace

Stack Trace

## πŸ™‡β€β™€οΈ Expected behavior/code

If I need to update the local strapi instance and rebuild the for example the package.json file and the do strapi build to rebuild the admin panel, to use a newer version of Strapi, I can't do it as I get the above error.

## πŸ‘©β€πŸ’» Environment

- πŸ“¦ Node version: v18.15.0
- πŸ’» OS: macOS Ventura 13.3.1 (22E261)
Apple M1 Max, 64 GB

## πŸ’‘ Possible Solution

<!-- Only if you have suggestions on a fix for the bug -->

## πŸ“Ί Additional context/Screenshots

For the docker tool itself, I went through the interactive setup, using the following setup:
:popcorn: JavaScript project detected

:package: YARN detected

:heavy_check_mark: Do you want to create a docker-compose file? :whale: Β· No / Yes
:heavy_check_mark: What enviroments do you want to configure? Β· Both
:heavy_check_mark: What database do you want to use? Β· PostgreSQL
:heavy_check_mark: Database Host Β· localhost
:heavy_check_mark: Database Name Β· strapi
:heavy_check_mark: Database Username Β· strapi
:heavy_check_mark: Database Password Β· ******
:heavy_check_mark: Database Port Β· 5432
:whale: Added docker-compose file with POSTGRESQL configuration

:whale: Dockerfile for PRODUCTION added

:male_detective: Added Dockerize variables in .env file

:floppy_disk: Added POSTGRESQL configuration to database.js

:package: No old dependencies to clean up

:package: PostgreSQL dependencies installed with YARN

:point_up: Strapi is now dockerized :whale: - have a look at the logs above for more info. :rocket:

:star: Star the project on GitHub if you liked this tool :pray:.

Error: Command failed with exit code 1: yarn add pgerror [email protected]: The engine "node" is incompatible with this module. Expected version ">=14.19.1 <=18.x.x". Got "19.6.0"error Found incompatible module.yarn add v1.22.19[1/5] Validating package.json...info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

πŸ› Bug Report

πŸ€·β€β™€οΈ What did you do

⛔️ Error log

Command failed with exit code 1: yarn add pg
error [email protected]: The engine "node" is incompatible with this module. Expected version ">=14.19.1 <=18.x.x". Got "19.6.0"
error Found incompatible module.
yarn add v1.22.19
[1/5] Validating package.json...
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

πŸ•΅οΈβ€β™€οΈ Stack trace

Error: Command failed with exit code 1: yarn add pg
error [email protected]: The engine "node" is incompatible with this module. Expected version ">=14.19.1 <=18.x.x". Got "19.6.0"
error Found incompatible module.
yarn add v1.22.19
[1/5] Validating package.json...
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
    at makeError (/home/asavienko/.npm/_npx/c78dafd2dc881eeb/node_modules/execa/lib/error.js:60:11)
    at handlePromise (/home/asavienko/.npm/_npx/c78dafd2dc881eeb/node_modules/execa/index.js:118:26)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async installDependecies (/home/asavienko/.npm/_npx/c78dafd2dc881eeb/node_modules/@strapi-community/dockerize/core/dependencies.js:21:3)
    at async /home/asavienko/.npm/_npx/c78dafd2dc881eeb/node_modules/@strapi-community/dockerize/index.js:57:4

πŸ™‡β€β™€οΈ Expected behavior/code

A clear and concise description of what you expected to happen (or code).

πŸ‘©β€πŸ’» Environment

  • πŸ“¦ Node version: v19.6.0
  • πŸ’» OS: linux x64

πŸ’‘ Possible Solution

πŸ“Ί Additional context/Screenshots

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.