docker-compose up command throwing error when deploying a parse server - docker

I am trying to run my parse server app in docker, but when running the command 'docker-compose up' it runs fine for some seconds and then throws this error:
Error parsing command line: unrecognised option '--break-mongo'.
and after this it also throws an npm related error --
my-parse-app |
my-parse-app | > app#1.0.0 start /parse-server
my-parse-app | > parse-server "/parse-server/config/config.json"
my-parse-app |
my-parse-app |
/parse-server/node_modules/parse/lib/node/ParseObject.js:1301
my-parse-app | async exists(options
my-parse-app | ^^^^^^
my-parse-app |
my-parse-app | SyntaxError: Unexpected identifier
my-parse-app | at createScript (vm.js:56:10)
my-parse-app | at Object.runInThisContext (vm.js:97:10)
my-parse-app | at Module._compile (module.js:549:28)
my-parse-app | at Object.Module._extensions..js (module.js:586:10)
my-parse-app | at Module.load (module.js:494:32)
my-parse-app | at tryModuleLoad (module.js:453:12)
my-parse-app | at Function.Module._load (module.js:445:3)
my-parse-app | at Module.require (module.js:504:17)
my-parse-app | at require (internal/module.js:20:19)
my-parse-app | at Object.
(/parse-server/node_modules/parse/lib/node/ParseRole.js:12:43)
my-parse-app |
my-parse-app | npm ERR! Linux 4.19.128-microsoft-standard
my-parse-app | npm ERR! argv "/usr/local/bin/node"
"/usr/local/bin/npm" "start" "--" "/parse-server/config/config.json"
my-parse-app | npm ERR! node v6.17.1
my-parse-app | npm ERR! npm v3.10.10
my-parse-app | npm ERR! code ELIFECYCLE
my-parse-app | npm ERR! app#1.0.0 start: parse-server "/parse-server/config/config.json"
my-parse-app | npm ERR! Exit status 1
my-parse-app | npm ERR!
my-parse-app | npm ERR! Failed at the app#1.0.0 start script
'parse-server "/parse-server/config/config.json"'.
my-parse-app | npm ERR! Make sure you have the latest version of
node.js and npm installed.
my-parse-app | npm ERR! If you do, this is most likely a problem with
the app package,
my-parse-app | npm ERR! not with npm itself.
my-parse-app | npm ERR! Tell the author that this fails on your
system:
my-parse-app | npm ERR! parse-server
"/parse-server/config/config.json"
my-parse-app | npm ERR! You can get information on how to open an
issue for this project with:
my-parse-app | npm ERR! npm bugs app
my-parse-app | npm ERR! Or if that isn't available, you can get their
info via:
my-parse-app | npm ERR! npm owner ls app
my-parse-app | npm ERR! There is likely additional logging output
above.
my-parse-app |
my-parse-app | npm ERR! Please include the following file with any
support request:
my-parse-app | npm ERR! /parse-server/npm-debug.log
my-parse-app exited with code 1
My docker-compose:
version: "2"
services:
# Node.js parse-server application image
app:
build: ./app
command: npm start -- /parse-server/config/config.json
container_name: my-parse-app
volumes:
- ./app:/parse-server/
- /parse-server/node_modules
ports:
- "1337:1337"
links:
- mongo
# MongoDB image
mongo:
image: mongo:latest
container_name: mongo-database
ports:
- "27017:27017"
volumes_from:
- mongodata
# MongoDB image volume for persistence
mongodata:
image: mongo
volumes:
- ./data/db:/data/db
command:
- --break-mongo
My Dockerfile
FROM node:boron
RUN mkdir -p /parse-server
WORKDIR /parse-server
COPY . /parse-server
RUN npm install
EXPOSE 1337
CMD ["npm","start"]
The break-mongo error
The npm error

It looks you are using an old version of node and it is probably the problem. Switch the first line of your docker file to:
FROM node:erbium

Related

Getting an npm permissions error in CI/CD after upgrading to Node v16 - working fine locally running container from same image

After upgrading from Node 14.15 => 16.18.1, I have started getting a Error: EACCES: permission denied, scandir '/root/.npm/_logs' error when trying to run ESLint in the GitHub Actions CI/CD workflow.
Note: I am running this inside a Docker container. I am able to run the ESLint script locally in a container built from the same image, but when running in Github Actions, the workflow fails with the following error:
Creating csps-lint ... done
Attaching to csps-lint
csps-lint |
csps-lint | > lint
csps-lint | > bash ./scripts/lint.sh
csps-lint |
csps-lint | Running Prettier to identify code formatting issues...
csps-lint |
csps-lint | Checking formatting...
csps-lint | All matched files use Prettier code style!
csps-lint |
csps-lint | Running ESLint to identify code quality issues...
csps-lint | npm WARN logfile Error: EACCES: permission denied, scandir '/root/.npm/_logs'
csps-lint | npm WARN logfile error cleaning log files [Error: EACCES: permission denied, scandir '/root/.npm/_logs'] {
csps-lint | npm WARN logfile errno: -13,
csps-lint | npm WARN logfile code: 'EACCES',
csps-lint | npm WARN logfile syscall: 'scandir',
csps-lint | npm WARN logfile path: '/root/.npm/_logs'
csps-lint | npm WARN logfile }
csps-lint | npm ERR! code EACCES
csps-lint | npm ERR! syscall mkdir
csps-lint | npm ERR! path /root/.npm/_cacache/tmp
csps-lint | npm ERR! errno -13
csps-lint | npm ERR!
csps-lint | npm ERR! Your cache folder contains root-owned files, due to a bug in
csps-lint | npm ERR! previous versions of npm which has since been addressed.
csps-lint | npm ERR!
csps-lint | npm ERR! To permanently fix this problem, please run:
csps-lint | npm ERR! sudo chown -R 1001:123 "/root/.npm"
csps-lint |
csps-lint | npm ERR! Log files were not written due to an error writing to the directory: /root/.npm/_logs
csps-lint | npm ERR! You can rerun the command with `--loglevel=verbose` to see the logs in your terminal
csps-lint | ESLint found code quality issues. Please address any errors above and try again.
csps-lint |
csps-lint exited with code 1
1
Aborting on container exit...
Error: Process completed with exit code 1.
My GH Actions workflow is this:
name: test-eslint-fix
on:
push:
branches:
- eslint-fix
jobs:
login:
runs-on: ubuntu-latest
steps:
- uses: docker/login-action#v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
linting:
needs: login
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v3
- run: LINT_COMMAND=lint docker-compose -f docker-comp-lint.yml up --abort-on-container-
Here is the Dockerfile that the image is created from:
# start FROM a base layer of node v16.18.1
FROM node:16.18.1
# confirm installation
RUN node -v
RUN npm -v
# Globally install webpack in the container for webpack dev server
RUN npm install webpack -g
# Install db-migrate
RUN npm install db-migrate#0.11.11 -g
# Set up a WORKDIR for application in the container
WORKDIR /usr/src/app
# A wildcard is used to ensure both package.json AND package-lock.json are copied
COPY package*.json /usr/src/app/
# npm install to create node_modules in the container
RUN npm install
# EXPOSE your server port
EXPOSE 3000
This is my docker-compose file:
version: '3'
services:
csps-lint:
image: <<my image>>
container_name: csps-lint
ports:
- '3002:3002'
volumes:
- ./:/usr/src/app
- node_modules:/usr/src/app/node_modules
environment:
- NODE_ENV=test
- LINT_COMMAND=${LINT_COMMAND}
command: npm run ${LINT_COMMAND}
volumes:
node_modules:
And this is the bash script that is running the ESLint command:
# Run Prettier in check mode and store status
echo -e "\033[1;33mRunning Prettier to identify code formatting issues...\033[0m\n"
prettier --check .
PRETTIER_STATUS=$?
# Run ESLint in check mode and store status
echo -e "\n\033[1;33mRunning ESLint to identify code quality issues...\033[0m"
npx eslint .
ESLINT_STATUS=$?
I have tried adding the recommended fix from the error message in multiple places, but nothing seems to resolve the issue. I've put this command in the lint.sh script, I've added it to the Dockerfile, I've tried adding in the docker-compose file as well, but I'm unable to resolve the issue no matter where I place the command.
sudo chown -R 1001:123 "/root/.npm"
In a few of the instances, there was no access to sudo, so I'm wondering if I somehow need to install that first? Do I even need to be setting these permissions? Is there something that has changed from Node v14 to Node v16 that I'm just overlooking?
I've tried to use the solutions provided in other posts with similar error messages for other packages, but none of the solutions seem to fix this issue.
I feel like there must just be some very small thing I've missed, but the part that I'm really lost on is that I haven't changed this workflow other than upgrading the Node.js version in the Dockerfile. Also, I am able to run this workflow locally without issue in a container created from the same image, but inside GH Actions I can't seem to get past this flow.
When running the following command locally docker exec csps-lint ls -la /root/.npm/_logs, this is my output:
total 1080
drwxr-xr-x 1 root root 4096 Dec 2 23:02 .
drwxr-xr-x 1 root root 4096 Dec 2 20:15 ..
-rw-r--r-- 1 root root 1589 Nov 15 06:46 2022-11-15T06_46_44_197Z-debug-0.log
-rw-r--r-- 1 root root 1589 Dec 2 20:15 2022-12-02T20_15_05_450Z-debug-0.log
-rw-r--r-- 1 root root 65102 Dec 2 20:15 2022-12-02T20_15_05_684Z-debug-0.log
-rw-r--r-- 1 root root 59037 Dec 2 20:15 2022-12-02T20_15_09_141Z-debug-0.log
-rw-r--r-- 1 root root 943351 Dec 2 20:15 2022-12-02T20_15_14_433Z-debug-0.log
-rw-r--r-- 1 root root 1706 Dec 2 20:23 2022-12-02T20_23_05_075Z-debug-0.log
-rw-r--r-- 1 root root 1756 Dec 2 20:23 2022-12-02T20_23_16_787Z-debug-0.log
-rw-r--r-- 1 root root 1599 Dec 2 23:02 2022-12-02T23_02_23_793Z-debug-0.log
UPDATE: So I have discovered that when I run the script in the csps-lint folder locally, the user is root, but when it is run in the CI/CD, it runs as an unnamed user with ID 1001. I'm really unclear why the user would be different when the container is built from the same image no matter where it's being run.
I believe this issue was caused by npm updates no longer running in root. After much back and forth and trying 101 different things, I was able to resolve the issue by:
Adding the following command to the end of my dockerfile
RUN chown -R node:node /usr/src/app
Adding a user key to my docker-compose.yml file
version: '3'
services:
csps-lint:
image: <<my image>>
user: node
container_name: csps-lint
ports:
- '3002:3002'
volumes:
- ./:/usr/src/app
- node_modules:/usr/src/app/node_modules
environment:
- NODE_ENV=test
- LINT_COMMAND=${LINT_COMMAND}
command: npm run ${LINT_COMMAND}
volumes:
node_modules:

Docker "Unexpected identifier" error for library express

I study containers. For it, I implement it in a particular project, available on this link. When I type the command docker-compose up, an error log below pops out. I can run the command npm start without problems.
Attaching to nodejs
nodejs | [nodemon] 2.0.15
nodejs | [nodemon] to restart at any time, enter `rs`
nodejs | [nodemon] watching path(s): *.*
nodejs | [nodemon] watching extensions: js,mjs,json
nodejs | [nodemon] starting `node app.js ./src/index.js`
nodejs | /home/node/app/src/index.js:2
nodejs | import express from 'express';
nodejs | ^^^^^^^
nodejs |
nodejs | SyntaxError: Unexpected identifier
nodejs | at Module._compile (internal/modules/cjs/loader.js:723:23)
nodejs | at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
nodejs | at Module.load (internal/modules/cjs/loader.js:653:32)
nodejs | at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
nodejs | at Function.Module._load (internal/modules/cjs/loader.js:585:3)
nodejs | at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
nodejs | at startup (internal/bootstrap/node.js:283:19)
nodejs | at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
nodejs | [nodemon] app crashed - waiting for file changes before starting...

Building prestashop using docker-compose Error: EACCES: permission denied, access '/var/www/html/admin-dev/themes/default'

I am trying to up prestashop in a docker container on an AWS EC2 instance. I use the latest docker-compose.yml file from here
.....
- "80:80"
user: root
volumes:
- ./:/var/www/html:delegated
enter code here
.....
but when starting the container I get this error:
prestashop-git_1 | ~/html/admin-dev/themes/default ~/html
prestashop-git_1 | 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!
prestashop-git_1 | npm WARN checkPermissions Missing write access to /var/www/html/admin-dev/themes/default
prestashop-git_1 | npm WARN default#1.7.5 No description
prestashop-git_1 | npm WARN default#1.7.5 No repository field.
prestashop-git_1 |
prestashop-git_1 | npm ERR! code EACCES
prestashop-git_1 | npm ERR! syscall access
prestashop-git_1 | npm ERR! path /var/www/html/admin-dev/themes/default
prestashop-git_1 | npm ERR! errno -13
prestashop-git_1 | npm ERR! Error: EACCES: permission denied, access '/var/www/html/admin-dev/themes/default'
prestashop-git_1 | npm ERR! [Error: EACCES: permission denied, access '/var/www/html/admin-dev/themes/default'] {
prestashop-git_1 | npm ERR! errno: -13,
prestashop-git_1 | npm ERR! code: 'EACCES',
prestashop-git_1 | npm ERR! syscall: 'access',
prestashop-git_1 | npm ERR! path: '/var/www/html/admin-dev/themes/default'
prestashop-git_1 | npm ERR! }
prestashop-git_1 | npm ERR!
prestashop-git_1 | npm ERR! The operation was rejected by your operating system.
prestashop-git_1 | npm ERR! It is likely you do not have the permissions to access this file as the current user
prestashop-git_1 | npm ERR!
prestashop-git_1 | npm ERR! If you believe this might be a permissions issue, please double-check the
prestashop-git_1 | npm ERR! permissions of the file and its containing directories, or try running
prestashop-git_1 | npm ERR! the command again as root/Administrator.
prestashop-git_1 |
prestashop-git_1 | npm ERR! A complete log of this run can be found in:
prestashop-git_1 | npm ERR! /var/www/.npm/_logs/2022-01-15T21_02_42_638Z-debug.log
prestashop-git_1 | make: *** [Makefile:7: assets] Error 243
prestashop-git_1 |
prestashop-git_1 | * Checking if mysql is available...
I tried to add user: root to docker-compose.yml to make sure there is no permissions issue, but it still fails.
I cloned the whole Prestashop repo:
[ec2-user#ip-172-31-28-236 PrestaShop]$ ls
CODE_OF_CONDUCT.md admin-dev composer.lock images.inc.php mails tests vendor
CONTRIBUTING.md app config img modules tests-legacy webservice
CONTRIBUTORS.md autoload.php controllers index.php override themes
INSTALL.txt bin docker-compose.yml init.php pdf tools
LICENSE.md cache docs install-dev phpstan.neon.dist translations
Makefile classes download js src upload
README.md composer.json error500.html localization templates var
[ec2-user#ip-172-31-28-236 PrestaShop]$ ls admin-dev/
ajax_products_list.php bootstrap.php export functions.php import robots.txt
autoupgrade cron_currency_rates.php favicon.ico get-file-admin.php index.php searchcron.php
backup.php displayImage.php filemanager grider.php init.php themes
backups drawer.php footer.inc.php header.inc.php pdf.php
[ec2-user#ip-172-31-28-236 PrestaShop]$

docker-compose build Cannot find module './src'

I recently ran npm install and npm update.
Then I tried to build my docker container. I keep getting the same stacktrace:
Step 7/8 : RUN npm run build
---> Running in 9d7f766e2cf7
> docs.rpg.riotgames.io#1.0.0 build /riot/rpg-docs-hub
> next build
(node:18) ExperimentalWarning: The fs.promises API is experimental
Loaded env from /riot/rpg-docs-hub/.env
> Build error occurred
{ Error: Cannot find module './src'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/riot/rpg-docs-hub/node_modules/dotenv-webpack/index.js:9:14)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/riot/rpg-docs-hub/next.config.js:4:16)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32) code: 'MODULE_NOT_FOUND' }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! docs.rpg.riotgames.io#1.0.0 build: `next build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the docs.rpg.riotgames.io#1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-02-03T19_16_10_771Z-debug.log
ERROR: Service 'rpg-docs-hub' failed to build : The command '/bin/sh -c npm run build' returned a non-zero code: 1
I tried...
repeating npm install and npm update
Running docker-compose up --build
running npm install --save-dev dotenv-webpack, since this seems to be associated with webpack
The result is the same.
My level of technical understanding is limited, though I'm trying to ramp up quickly.
Any help is appreciated. thanks!

Docker container stuck in a build loop

i'm facing a problem with docker. I'm working on a multi-container Docker application using a node server, a postgreSQL database and adminer. When i run the command docker-compose up everything looks to work fine until i encounter a loop situation :
serveur_1 | yarn install v1.22.4
serveur_1 | [1/4] Resolving packages...
serveur_1 | success Already up-to-date.
serveur_1 | Done in 0.86s.
serveur_1 | yarn run v1.22.4
serveur_1 | $ ts-node-dev --inspect=0.0.0.0:5858 --respawn --transpileOnly --
detectOpenHandles ./app/index.ts
serveur_1 | Usage: ts-node-dev [options] script [arguments]
serveur_1 |
serveur_1 | error Command failed with exit code 1.
serveur_1 | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this
command.
devops_serveur_1 exited with code 1
serveur_1 | yarn install v1.22.4
serveur_1 | [1/4] Resolving packages...
serveur_1 | success Already up-to-date.
serveur_1 | Done in 0.83s.
serveur_1 | yarn run v1.22.4
serveur_1 | $ ts-node-dev --inspect=0.0.0.0:5858 --respawn --transpileOnly --
detectOpenHandles ./app/index.ts
serveur_1 | Usage: ts-node-dev [options] script [arguments]
serveur_1 |
serveur_1 | error Command failed with exit code 1.
serveur_1 | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this
command.
devops_serveur_1 exited with code 1
serveur_1 | yarn install v1.22.4
serveur_1 | [1/4] Resolving packages...
serveur_1 | success Already up-to-date.
serveur_1 | Done in 0.84s.
serveur_1 | yarn run v1.22.4
serveur_1 | $ ts-node-dev --inspect=0.0.0.0:5858 --respawn --transpileOnly --
detectOpenHandles ./app/index.ts
serveur_1 | Usage: ts-node-dev [options] script [arguments]
serveur_1 |
serveur_1 | error Command failed with exit code 1.
serveur_1 | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this
command.
And this is my docker-compose.yml file :
version: "3.7"
services:
db:
env_file:
- .env
image: postgres
restart: always
ports:
- "${DB_PORT}:5432"
environment:
POSTGRES_PASSWORD: $DB_PASSWORD
POSTGRES_USER: $DB_USERNAME
POSTGRES_DB: $DB_NAME
networks:
- database
volumes:
- ./db:/var/lib/postgresql/data
serveur:
env_file:
- .env
image: "node:12.16.3"
working_dir: /app
command: bash -c "yarn && yarn dev"
restart: always
depends_on:
- db
ports:
- "${API_PORT:-5000}:${API_PORT:-5000}"
volumes:
- ./serveur:/app
environment:
PORT: $API_PORT
DB_PORT: $DB_PORT
DB_NAME: $DB_NAME
DB_USERNAME: $DB_USERNAME
DB_PASSWORD: $DB_PASSWORD
JWTSECRET: $JWTSECRET
networks:
- database
- front
admin:
env_file:
- .env
image: adminer
restart: always
depends_on:
- db
networks:
- database
ports:
- "${ADMINER_PORT:-5050}:8080"
# client:
# image: "node:12.16.3"
# working_dir: /app
# command: bash -c "yarn && yarn start"
# restart: always
# stdin_open: true
# ports:
# - "${FRONT_PORT:-3000}:3000"
# environment:
# REACT_APP_API_URL: http://localhost:${API_PORT:-5000}
# depends_on:
# - serveur
# volumes:
# - ./client:/app
# networks:
# - front
networks:
database:
front:
It seem to be a problem with the volumes but i'm not sure about that, what would be the best approch for solving this issue ?
Any help would be much appreciated !
Thanks in advance
If you are here because you think your docker settings were faulty or something wrong with your code and you are using ts-node-dev package. The problem might be in how you are setting options on ts-node-dev. They change --transpileOnly option to --transpile-only. took me 3 hours to figure this out. The error message didn't help.
➜ npm run dev
> ts-node-dev --inspect=0.0.0.0 --respawn --transpileOnly startup.ts <-- ERROR HERE. SHOULD BE --transpile-only
ts-node-dev: no script to run provided
Usage: ts-node-dev [options] script [arguments]
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ggpo-server#1.0.0 dev: `ts-node-dev --inspect=0.0.0.0 --respawn --transpileOnly startup.ts`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ggpo-server#1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/user/.npm/_logs/2021-07-03T23_59_58_287Z-debug.log
For reference: https://github.com/wclr/ts-node-dev/issues/223

Resources