Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to install on Windows 10 #53

Closed
MikePugs opened this issue Aug 16, 2017 · 12 comments
Closed

Unable to install on Windows 10 #53

MikePugs opened this issue Aug 16, 2017 · 12 comments

Comments

@MikePugs
Copy link

I've tried to get this running using the default development configuration on 3 different windows 10 machines without success.

Here are the steps I am taking:

  1. Update Docker to latest version (currently version 17.06.0-ce, build 02c1d87)
  2. Clone and run docker-compose up as instructed

git clone https://github.com/kriasoft/nodejs-api-starter.git example-api
cd example-api # Change current directory to the newly created one
docker-compose up # Launch Docker containers with the Node.js API app running inside

  1. Try to seed databases in spite of error from above step.

    winpty docker-compose exec api yarn db-seed

  2. Notice more errors. Try the process again by executing docker-compose down followed by docker-compose up

Below is the output from steps 2-4.

$ docker-compose up
Creating network "exampleapi_default" with the default driver
Creating volume "exampleapi_redis" with default driver
Creating volume "exampleapi_db" with default driver
Creating volume "exampleapi_yarn" with default driver
Pulling redis (redis:4.0.1-alpine)...
4.0.1-alpine: Pulling from library/redis
Digest: sha256:e633cded055a94202e4ccccb8125b7f383cd6ee56527ab890db643383a2647dd
Status: Downloaded newer image for redis:4.0.1-alpine
Pulling db (postgres:9.6.4-alpine)...
9.6.4-alpine: Pulling from library/postgres
Digest: sha256:5fd73de311d304caeb4f907d4f559d322805abc622e4baf5788c6a079ee5224e
Status: Downloaded newer image for postgres:9.6.4-alpine
Pulling api (node:8.3.0-alpine)...
8.3.0-alpine: Pulling from library/node
Digest: sha256:811180c902c56e594832bc553bfc5ba8315959a55d453e045bfe77af9b2341cb
Status: Downloaded newer image for node:8.3.0-alpine
Pulling nginx (nginx:1.13.3-alpine)...
1.13.3-alpine: Pulling from library/nginx
Digest: sha256:24a27241f0450b465f9e9deb30628c524aa81a1aa6936daa41ef7c4345515272
Status: Downloaded newer image for nginx:1.13.3-alpine
Creating exampleapi_redis_1 ...
Creating exampleapi_db_1 ...
Creating exampleapi_db_1
Creating exampleapi_db_1 ... done
Creating exampleapi_api_1 ...
Creating exampleapi_api_1 ... done
Creating exampleapi_nginx_1 ...
Creating exampleapi_nginx_1 ... done
Attaching to exampleapi_redis_1, exampleapi_db_1, exampleapi_api_1, exampleapi_n ginx_1
redis_1 | 1:C 16 Aug 15:41:22.078 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0 Oo
redis_1 | 1:C 16 Aug 15:41:22.079 # Redis version=4.0.1, bits=64, commit=000000 00, modified=0, pid=1, just started
db_1 | The files belonging to this database system will be owned by user "po stgres".
redis_1 | 1:C 16 Aug 15:41:22.079 # Warning: no config file specified, using th e default config. In order to specify a config file use redis-server /path/to/re dis.conf
db_1 | This user must also own the server process.
api_1 | yarn install v0.27.5
db_1 |
redis_1 | 1:M 16 Aug 15:41:22.080 * Running mode=standalone, port=6379.
db_1 | The database cluster will be initialized with locale "en_US.utf8".
api_1 | [1/4] Resolving packages...
redis_1 | 1:M 16 Aug 15:41:22.080 # WARNING: The TCP backlog setting of 511 can not be enforced because /proc/sys/net/core/somaxconn is set to the lower value o f 128.
db_1 | The default database encoding has accordingly been set to "UTF8".
redis_1 | 1:M 16 Aug 15:41:22.080 # Server initialized
api_1 | [2/4] Fetching packages...
db_1 | The default text search configuration will be set to "english".
redis_1 | 1:M 16 Aug 15:41:22.080 # WARNING you have Transparent Huge Pages (TH P) support enabled in your kernel. This will create latency and memory usage iss ues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/t ransparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disab led.
db_1 |
redis_1 | 1:M 16 Aug 15:41:22.080 * Ready to accept connections
db_1 | Data page checksums are disabled.
db_1 |
db_1 | fixing permissions on existing directory /var/lib/postgresql/data ... ok
db_1 | creating subdirectories ... ok
db_1 | selecting default max_connections ... 100
db_1 | selecting default shared_buffers ... 128MB
db_1 | selecting dynamic shared memory implementation ... posix
db_1 | creating configuration files ... ok
db_1 | running bootstrap script ... ok
db_1 | performing post-bootstrap initialization ... No usable system locales were found.
db_1 | Use the option "--debug" to see details.
db_1 | sh: locale: not found
db_1 | ok
db_1 | syncing data to disk ...
db_1 | WARNING: enabling "trust" authentication for local connections
db_1 | You can change this by editing pg_hba.conf or using the option -A, or
db_1 | --auth-local and --auth-host, the next time you run initdb.
db_1 | ok
db_1 |
db_1 | Success. You can now start the database server using:
db_1 |
db_1 | pg_ctl -D /var/lib/postgresql/data -l logfile start
db_1 |
db_1 | ****************************************************
db_1 | WARNING: No password has been set for the database.
db_1 | This will allow anyone with access to the
db_1 | Postgres port to access your database. In
db_1 | Docker's default configuration, this is
db_1 | effectively any other container on the same
db_1 | system.
db_1 |
db_1 | Use "-e POSTGRES_PASSWORD=password" to set
db_1 | it in "docker run".
db_1 | ****************************************************
db_1 | waiting for server to start....LOG: could not bind IPv6 socket: Addr ess not available
db_1 | HINT: Is another postmaster already running on port 5432? If not, wa it a few seconds and retry.
db_1 | LOG: database system was shut down at 2017-08-16 15:42:02 UTC
db_1 | LOG: MultiXact member wraparound protections are now enabled
db_1 | LOG: database system is ready to accept connections
db_1 | LOG: autovacuum launcher started
db_1 | done
db_1 | server started
db_1 | ALTER ROLE
db_1 |
db_1 |
db_1 | /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initd b.d/initdb.sh
db_1 | /docker-entrypoint-initdb.d/initdb.sh: line 2: $'\r': command not fou nd
exampleapi_db_1 exited with code 127
api_1 | warning fsevents@1.1.2: The platform "linux" is incompatible with thi s module.
api_1 | info "fsevents@1.1.2" is an optional dependency and failed compatibil ity check. Excluding it from installation.
api_1 | [3/4] Linking dependencies...
api_1 | [4/4] Building fresh packages...
api_1 | Done in 55.49s.
api_1 | Starting 'run'...
api_1 | Starting 'db-migrate'...
api_1 | Error: getaddrinfo EAI_AGAIN db:5432
api_1 | at Object._errnoException (util.js:1022:11)
api_1 | at errnoException (dns.js:58:15)
api_1 | at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:95:26)
api_1 | Starting 'build'...
api_1 | src/DataLoaders.js -> build/DataLoaders.js
api_1 | src/app.js -> build/app.js
api_1 | src/db.js -> build/db.js
api_1 | src/email.js -> build/email.js
api_1 | src/passport.js -> build/passport.js
api_1 | src/redis.js -> build/redis.js
api_1 | src/server.js -> build/server.js
api_1 | src/routes/account.js -> build/routes/account.js
api_1 | src/schema/Comment.js -> build/schema/Comment.js
api_1 | src/schema/CommentType.js -> build/schema/CommentType.js
api_1 | src/schema/EmailType.js -> build/schema/EmailType.js
api_1 | src/schema/Node.js -> build/schema/Node.js
api_1 | src/schema/README.md -> build/schema/README.md
api_1 | src/schema/Story.js -> build/schema/Story.js
api_1 | src/schema/StoryType.js -> build/schema/StoryType.js
api_1 | src/schema/User.js -> build/schema/User.js
api_1 | src/schema/UserType.js -> build/schema/UserType.js
api_1 | src/schema/ValidationError.js -> build/schema/ValidationError.js
api_1 | src/schema/index.js -> build/schema/index.js
api_1 | src/emails/welcome/html.hbs -> build/emails/welcome/html.js
api_1 | src/emails/welcome/subject.hbs -> build/emails/welcome/subject.js
api_1 | Finished 'build' after 1010ms
api_1 | Node.js API server is listening on http://api:8080/


$ winpty docker-compose exec api yarn db-seed
yarn db-seed v0.27.5
$ node tools/db.js seed
Starting 'db-seed'...
Error: getaddrinfo EAI_AGAIN db:5432
at Object._errnoException (util.js:1022:11)
at errnoException (dns.js:58:15)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:95:26)
Done in 26.30s.


$ docker-compose down
Stopping exampleapi_nginx_1 ...
Stopping exampleapi_nginx_1 ... done
Stopping exampleapi_api_1 ... done
exampleapi_nginx_1 exited with code 0
exampleapi_api_1 exited with code 0
redis_1 | 1:signal-handler (1502898486) Received SIGTERM scheduling shutdown...
redis_1 | 1:M 16 Aug 15:48:07.046 # User requested shutdown...
redis_1 | 1:M 16 Aug 15:48:07.046 * Saving the final RDB snapshot before exiting.
redis_1 | 1:M 16 Aug 15:48:07.074 * DB saved on disk
Stopping exampleapi_redis_1 ... done
exampleapi_redis_1 exited with code 0
Removing exampleapi_nginx_1 ... done
Removing exampleapi_api_1 ... done
Removing exampleapi_db_1 ... done
Removing exampleapi_redis_1 ... done
Removing network exampleapi_default


$ docker-compose up
Creating network "exampleapi_default" with the default driver
Creating exampleapi_redis_1 ...
Creating exampleapi_db_1 ...
Creating exampleapi_db_1
Creating exampleapi_redis_1 ... done
Creating exampleapi_api_1 ...
Creating exampleapi_api_1 ... done
Creating exampleapi_nginx_1 ...
Creating exampleapi_nginx_1 ... done
Attaching to exampleapi_db_1, exampleapi_redis_1, exampleapi_api_1, exampleapi_nginx_1
db_1 | LOG: database system was interrupted; last known up at 2017-08-16 15:42:07 UTC
db_1 | LOG: database system was not properly shut down; automatic recovery in progress
db_1 | LOG: redo starts at 0/14EDC10
redis_1 | 1:C 16 Aug 15:48:31.164 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
db_1 | LOG: invalid record length at 0/14EDDF0: wanted 24, got 0
redis_1 | 1:C 16 Aug 15:48:31.164 # Redis version=4.0.1, bits=64, commit=00000000, modified=0, pid=1, just started
db_1 | LOG: redo done at 0/14EDDC8
redis_1 | 1:C 16 Aug 15:48:31.164 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
db_1 | LOG: last completed transaction was at log time 2017-08-16 15:42:07.984983+00
redis_1 | 1:M 16 Aug 15:48:31.166 * Running mode=standalone, port=6379.
db_1 | LOG: MultiXact member wraparound protections are now enabled
redis_1 | 1:M 16 Aug 15:48:31.166 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
db_1 | LOG: database system is ready to accept connections
redis_1 | 1:M 16 Aug 15:48:31.166 # Server initialized
redis_1 | 1:M 16 Aug 15:48:31.166 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
db_1 | LOG: autovacuum launcher started
redis_1 | 1:M 16 Aug 15:48:31.166 * DB loaded from disk: 0.000 seconds
redis_1 | 1:M 16 Aug 15:48:31.166 * Ready to accept connections
api_1 | Starting 'run'...
api_1 | Starting 'db-migrate'...
db_1 | FATAL: database "dev" does not exist
db_1 | FATAL: database "dev" does not exist
db_1 | FATAL: database "dev" does not exist
api_1 | error: database "dev" does not exist
api_1 | at Connection.parseE (/usr/src/app/node_modules/pg/lib/connection.js:546:11)
api_1 | at Connection.parseMessage (/usr/src/app/node_modules/pg/lib/connection.js:371:19)
api_1 | at Socket. (/usr/src/app/node_modules/pg/lib/connection.js:114:22)
api_1 | at emitOne (events.js:115:13)
api_1 | at Socket.emit (events.js:210:7)
api_1 | at addChunk (_stream_readable.js:252:12)
api_1 | at readableAddChunk (_stream_readable.js:239:11)
api_1 | at Socket.Readable.push (_stream_readable.js:197:10)
api_1 | at TCP.onread (net.js:589:20)
api_1 | Starting 'build'...
api_1 | src/DataLoaders.js -> build/DataLoaders.js
api_1 | src/app.js -> build/app.js
api_1 | src/db.js -> build/db.js
api_1 | src/email.js -> build/email.js
api_1 | src/passport.js -> build/passport.js
api_1 | src/redis.js -> build/redis.js
api_1 | src/server.js -> build/server.js
api_1 | src/routes/account.js -> build/routes/account.js
api_1 | src/schema/Comment.js -> build/schema/Comment.js
api_1 | src/schema/CommentType.js -> build/schema/CommentType.js
api_1 | src/schema/EmailType.js -> build/schema/EmailType.js
api_1 | src/schema/Node.js -> build/schema/Node.js
api_1 | src/schema/README.md -> build/schema/README.md
api_1 | src/schema/Story.js -> build/schema/Story.js
api_1 | src/schema/StoryType.js -> build/schema/StoryType.js
api_1 | src/schema/User.js -> build/schema/User.js
api_1 | src/schema/UserType.js -> build/schema/UserType.js
api_1 | src/schema/ValidationError.js -> build/schema/ValidationError.js
api_1 | src/schema/index.js -> build/schema/index.js
api_1 | src/emails/welcome/html.hbs -> build/emails/welcome/html.js
api_1 | src/emails/welcome/subject.hbs -> build/emails/welcome/subject.js
api_1 | Finished 'build' after 1146ms
api_1 | Node.js API server is listening on http://api:8080/
db_1 | FATAL: database "dev" does not exist
db_1 | FATAL: database "dev" does not exist

@koistya
Copy link
Member

koistya commented Aug 16, 2017

@MikePugs try setting CHOKIDAR_USEPOLLING environment variable in your docker-compose.override.yml to true (or 1)

@MikePugs
Copy link
Author

No luck.

My Steps:

  1. Created the following docker-compose.override.yml:
version: '3'

services:
  api:
    environment:
      - CHOKIDAR_USEPOLLING=true 
  1. Removed all existing containers

  2. Ran docker-compose up

$ docker-compose up
Creating exampleapi_redis_1 ...
Creating exampleapi_db_1 ...
Creating exampleapi_redis_1
Creating exampleapi_redis_1 ... done
Creating exampleapi_api_1 ...
Creating exampleapi_api_1 ... done
Creating exampleapi_nginx_1 ...
Creating exampleapi_nginx_1 ... done
Attaching to exampleapi_db_1, exampleapi_redis_1, exampleapi_api_1, exampleapi_nginx_1
db_1 | LOG: database system was interrupted; last known up at 2017-08-16 17:51:18 UTC
db_1 | LOG: database system was not properly shut down; automatic recovery in progress
redis_1 | 1:C 16 Aug 17:54:48.982 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
db_1 | LOG: invalid record length at 0/14EE0A8: wanted 24, got 0
redis_1 | 1:C 16 Aug 17:54:48.982 # Redis version=4.0.1, bits=64, commit=00000000, modified=0, pid=1, just started
db_1 | LOG: redo is not required
redis_1 | 1:C 16 Aug 17:54:48.982 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
db_1 | LOG: MultiXact member wraparound protections are now enabled
redis_1 | 1:M 16 Aug 17:54:48.983 * Running mode=standalone, port=6379.
db_1 | LOG: database system is ready to accept connections
redis_1 | 1:M 16 Aug 17:54:48.983 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
db_1 | LOG: autovacuum launcher started
redis_1 | 1:M 16 Aug 17:54:48.983 # Server initialized
redis_1 | 1:M 16 Aug 17:54:48.983 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
redis_1 | 1:M 16 Aug 17:54:48.983 * DB loaded from disk: 0.000 seconds
redis_1 | 1:M 16 Aug 17:54:48.984 * Ready to accept connections
api_1 | Starting 'run'...
api_1 | Starting 'db-migrate'...
db_1 | FATAL: database "dev" does not exist
db_1 | FATAL: database "dev" does not exist
db_1 | FATAL: database "dev" does not exist
api_1 | error: database "dev" does not exist
api_1 | at Connection.parseE (/usr/src/app/node_modules/pg/lib/connection.js:546:11)
api_1 | at Connection.parseMessage (/usr/src/app/node_modules/pg/lib/connection.js:371:19)
api_1 | at Socket. (/usr/src/app/node_modules/pg/lib/connection.js:114:22)
api_1 | at emitOne (events.js:115:13)
api_1 | at Socket.emit (events.js:210:7)
api_1 | at addChunk (_stream_readable.js:252:12)
api_1 | at readableAddChunk (_stream_readable.js:239:11)
api_1 | at Socket.Readable.push (_stream_readable.js:197:10)
api_1 | at TCP.onread (net.js:589:20)
api_1 | Starting 'build'...
api_1 | src/DataLoaders.js -> build/DataLoaders.js
api_1 | src/app.js -> build/app.js
api_1 | src/db.js -> build/db.js
api_1 | src/email.js -> build/email.js
api_1 | src/passport.js -> build/passport.js
api_1 | src/redis.js -> build/redis.js
api_1 | src/server.js -> build/server.js
api_1 | src/routes/account.js -> build/routes/account.js
api_1 | src/schema/Comment.js -> build/schema/Comment.js
api_1 | src/schema/CommentType.js -> build/schema/CommentType.js
api_1 | src/schema/EmailType.js -> build/schema/EmailType.js
api_1 | src/schema/Node.js -> build/schema/Node.js
api_1 | src/schema/README.md -> build/schema/README.md
api_1 | src/schema/Story.js -> build/schema/Story.js
api_1 | src/schema/StoryType.js -> build/schema/StoryType.js
api_1 | src/schema/User.js -> build/schema/User.js
api_1 | src/schema/UserType.js -> build/schema/UserType.js
api_1 | src/schema/ValidationError.js -> build/schema/ValidationError.js
api_1 | src/schema/index.js -> build/schema/index.js
api_1 | src/emails/welcome/html.hbs -> build/emails/welcome/html.js
api_1 | src/emails/welcome/subject.hbs -> build/emails/welcome/subject.js
api_1 | Finished 'build' after 1012ms
api_1 | Node.js API server is listening on http://api:8080/
db_1 | FATAL: database "dev" does not exist
db_1 | FATAL: database "dev" does not exist

@koistya
Copy link
Member

koistya commented Aug 16, 2017

I see "Node.js API server is listening on ..." it means that the app is running, you should be able to access it via http://localhost:8080/.. Regarding "database dev does not exist", one way is to remove the volumes created during the initial run of docker-compose up and try again, you can use docker volume ls, docker volume rm .. commands to manipulate volumes.. regarding the env variables, you can check what variables are set inside a container by running docker-compose run --rm --no-deps api printenv

@koistya
Copy link
Member

koistya commented Aug 16, 2017

@MikePugs this script is executed during the initial run of docker-compose up when no volumes exist yet => https://github.com/kriasoft/nodejs-api-starter/blob/master/config/postgres-initdb.sh After volumes are created they are staying permanently on your machine and this script is ignored, but you can remove volumes manually if needed (see my comment above).

@MikePugs
Copy link
Author

MikePugs commented Aug 16, 2017

Here are the environment variables returned by the command you provided:

$ docker-compose run --rm --no-deps api printenv
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=api
TWITTER_SECRET=xxxxx
DATABASE_DEBUG=false
GOOGLE_ID=xxxxx.apps.googleusercontent.com
CORS_ORIGIN=http://localhost:3001,http://localhost:3000
FACEBOOK_SECRET=2339bdf25f236a42fc3a18280bf455e8
GOOGLE_SECRET=xxxxx
REDIS_URL=redis://redis:6379/0
DATABASE_URL=postgres://postgres@db:5432/dev
CHOKIDAR_USEPOLLING=true
TWITTER_KEY=xxxxx
FACEBOOK_ID=1821424564802638
SESSION_SECRET=wZjwhFtzQsd7r87W6AZw45Sm
NPM_CONFIG_LOGLEVEL=info
NODE_VERSION=8.3.0
YARN_VERSION=0.27.5
HOME=/home/node

It seems that I am only able to remove a volume after I remove the associated container. Otherwise, I receive the following error:

$ docker volume rm exampleapi_db
Error response from daemon: unable to remove volume: remove exampleapi_db: volume is in use - [83bd33a561f45347e6fb827914ae930e0f6177b5d8b31f37b8e2de4378c04249]

After I remove all of the containers and all of the volumes I still receive docker-compose up errors

No Containers:

$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

No Volumes:

$ docker volume ls
DRIVER              VOLUME NAME

docker-compose up

$ docker-compose up
Creating volume "exampleapi_redis" with default driver
Creating volume "exampleapi_db" with default driver
Creating volume "exampleapi_yarn" with default driver
Creating exampleapi_redis_1 ...
Creating exampleapi_db_1 ...
Creating exampleapi_redis_1
Creating exampleapi_redis_1 ... done
Creating exampleapi_api_1 ...
Creating exampleapi_api_1 ... done
Creating exampleapi_nginx_1 ...
Creating exampleapi_nginx_1 ... done
Attaching to exampleapi_db_1, exampleapi_redis_1, exampleapi_api_1, exampleapi_nginx_1
db_1     | The files belonging to this database system will be owned by user "postgres".
db_1     | This user must also own the server process.
db_1     |
redis_1  | 1:C 16 Aug 19:21:48.294 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
db_1     | The database cluster will be initialized with locale "en_US.utf8".
redis_1  | 1:C 16 Aug 19:21:48.294 # Redis version=4.0.1, bits=64, commit=00000000, modified=0, pid=1, just started
db_1     | The default database encoding has accordingly been set to "UTF8".
redis_1  | 1:C 16 Aug 19:21:48.294 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
db_1     | The default text search configuration will be set to "english".
redis_1  | 1:M 16 Aug 19:21:48.294 * Running mode=standalone, port=6379.
db_1     |
redis_1  | 1:M 16 Aug 19:21:48.294 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
db_1     | Data page checksums are disabled.
redis_1  | 1:M 16 Aug 19:21:48.294 # Server initialized
db_1     |
redis_1  | 1:M 16 Aug 19:21:48.295 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
redis_1  | 1:M 16 Aug 19:21:48.295 * Ready to accept connections
db_1     | fixing permissions on existing directory /var/lib/postgresql/data ... ok
db_1     | creating subdirectories ... ok
db_1     | selecting default max_connections ... 100
db_1     | selecting default shared_buffers ... 128MB
db_1     | selecting dynamic shared memory implementation ... posix
db_1     | creating configuration files ... ok
db_1     | running bootstrap script ... ok
db_1     | performing post-bootstrap initialization ... No usable system locales were found.
db_1     | Use the option "--debug" to see details.
db_1     | sh: locale: not found
db_1     | ok
db_1     | syncing data to disk ... ok
db_1     |
db_1     | Success. You can now start the database server using:
db_1     |
db_1     |     pg_ctl -D /var/lib/postgresql/data -l logfile start
db_1     |
db_1     |
db_1     | WARNING: enabling "trust" authentication for local connections
db_1     | You can change this by editing pg_hba.conf or using the option -A, or
db_1     | --auth-local and --auth-host, the next time you run initdb.
db_1     | ****************************************************
db_1     | WARNING: No password has been set for the database.
db_1     |          This will allow anyone with access to the
db_1     |          Postgres port to access your database. In
db_1     |          Docker's default configuration, this is
db_1     |          effectively any other container on the same
db_1     |          system.
db_1     |
db_1     |          Use "-e POSTGRES_PASSWORD=password" to set
db_1     |          it in "docker run".
db_1     | ****************************************************
db_1     | waiting for server to start....LOG:  could not bind IPv6 socket: Address not available
db_1     | HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
db_1     | LOG:  database system was shut down at 2017-08-16 19:21:49 UTC
db_1     | LOG:  MultiXact member wraparound protections are now enabled
db_1     | LOG:  database system is ready to accept connections
db_1     | LOG:  autovacuum launcher started
db_1     |  done
db_1     | server started
db_1     | ALTER ROLE
db_1     |
db_1     |
db_1     | /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/initdb.sh
db_1     | /docker-entrypoint-initdb.d/initdb.sh: line 2: $'\r': command not found
exampleapi_db_1 exited with code 127
api_1    | Starting 'run'...
api_1    | Starting 'db-migrate'...
api_1    | Error: getaddrinfo EAI_AGAIN db:5432
api_1    |     at Object._errnoException (util.js:1022:11)
api_1    |     at errnoException (dns.js:58:15)
api_1    |     at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:95:26)
api_1    | Starting 'build'...
api_1    | src/DataLoaders.js -> build/DataLoaders.js
api_1    | src/app.js -> build/app.js
api_1    | src/db.js -> build/db.js
api_1    | src/email.js -> build/email.js
api_1    | src/passport.js -> build/passport.js
api_1    | src/redis.js -> build/redis.js
api_1    | src/server.js -> build/server.js
api_1    | src/routes/account.js -> build/routes/account.js
api_1    | src/schema/Comment.js -> build/schema/Comment.js
api_1    | src/schema/CommentType.js -> build/schema/CommentType.js
api_1    | src/schema/EmailType.js -> build/schema/EmailType.js
api_1    | src/schema/Node.js -> build/schema/Node.js
api_1    | src/schema/README.md -> build/schema/README.md
api_1    | src/schema/Story.js -> build/schema/Story.js
api_1    | src/schema/StoryType.js -> build/schema/StoryType.js
api_1    | src/schema/User.js -> build/schema/User.js
api_1    | src/schema/UserType.js -> build/schema/UserType.js
api_1    | src/schema/ValidationError.js -> build/schema/ValidationError.js
api_1    | src/schema/index.js -> build/schema/index.js
api_1    | src/emails/welcome/html.hbs -> build/emails/welcome/html.js
api_1    | src/emails/welcome/subject.hbs -> build/emails/welcome/subject.js
api_1    | Finished 'build' after 1689ms
api_1    | Node.js API server is listening on http://api:8080/

@koistya
Copy link
Member

koistya commented Aug 16, 2017

I see, it complains about the \r symbol in the config/postgres-initdb.sh file. I just added .sh extension to .gitattributes in a8f4663. Try merging this update into your project, removing db volume and running docker-compose up again.

git remote add nodejs-api-starter https://github.com/kriasoft/nodejs-api-starter.git
git checkout master
git fetch nodejs-api-starter
git merge nodejs-api-starter/master

@MikePugs
Copy link
Author

MikePugs commented Aug 16, 2017

I'm not sure I did the git update correctly, or if I continued to experience issues because it wasn't just the last \r that caused the error.

I solved that particular \r error by running the following:

sed -i 's/\r//' config/postgres-initdb.sh

which I believe replaces all of the \r characters in the file*.

After I ran that command, removed all containers and volumes the \r error went away. Note the line that says LOG: received fast shutdown request though...

$ docker-compose up
Creating volume "exampleapi_redis" with default driver
Creating volume "exampleapi_db" with default driver
Creating volume "exampleapi_yarn" with default driver
Creating exampleapi_redis_1 ...
Creating exampleapi_db_1 ...
Creating exampleapi_redis_1
Creating exampleapi_db_1 ... done
Creating exampleapi_api_1 ...
Creating exampleapi_api_1 ... done
Creating exampleapi_nginx_1 ...
Creating exampleapi_nginx_1 ... done
Attaching to exampleapi_redis_1, exampleapi_db_1, exampleapi_api_1, exampleapi_nginx_1
redis_1  | 1:C 16 Aug 20:28:51.372 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis_1  | 1:C 16 Aug 20:28:51.372 # Redis version=4.0.1, bits=64, commit=00000000, modified=0, pid=1, just started
redis_1  | 1:C 16 Aug 20:28:51.372 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
db_1     | The files belonging to this database system will be owned by user "postgres".
redis_1  | 1:M 16 Aug 20:28:51.373 * Running mode=standalone, port=6379.
db_1     | This user must also own the server process.
redis_1  | 1:M 16 Aug 20:28:51.373 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
db_1     |
redis_1  | 1:M 16 Aug 20:28:51.373 # Server initialized
db_1     | The database cluster will be initialized with locale "en_US.utf8".
redis_1  | 1:M 16 Aug 20:28:51.373 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
db_1     | The default database encoding has accordingly been set to "UTF8".
redis_1  | 1:M 16 Aug 20:28:51.373 * Ready to accept connections
db_1     | The default text search configuration will be set to "english".
db_1     |
db_1     | Data page checksums are disabled.
db_1     |
db_1     | fixing permissions on existing directory /var/lib/postgresql/data ... ok
db_1     | creating subdirectories ... ok
db_1     | selecting default max_connections ... 100
db_1     | selecting default shared_buffers ... 128MB
db_1     | selecting dynamic shared memory implementation ... posix
db_1     | creating configuration files ... ok
db_1     | running bootstrap script ... ok
db_1     | performing post-bootstrap initialization ... sh: locale: not found
db_1     | No usable system locales were found.
db_1     | Use the option "--debug" to see details.
db_1     | ok
db_1     | syncing data to disk ...
db_1     | WARNING: enabling "trust" authentication for local connections
db_1     | You can change this by editing pg_hba.conf or using the option -A, or
db_1     | --auth-local and --auth-host, the next time you run initdb.
db_1     | ok
db_1     |
db_1     | Success. You can now start the database server using:
db_1     |
db_1     |     pg_ctl -D /var/lib/postgresql/data -l logfile start
db_1     |
db_1     | ****************************************************
db_1     | WARNING: No password has been set for the database.
db_1     |          This will allow anyone with access to the
db_1     |          Postgres port to access your database. In
db_1     |          Docker's default configuration, this is
db_1     |          effectively any other container on the same
db_1     |          system.
db_1     |
db_1     |          Use "-e POSTGRES_PASSWORD=password" to set
db_1     |          it in "docker run".
db_1     | ****************************************************
db_1     | waiting for server to start....LOG:  could not bind IPv6 socket: Address not available
db_1     | HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
db_1     | LOG:  database system was shut down at 2017-08-16 20:28:52 UTC
db_1     | LOG:  MultiXact member wraparound protections are now enabled
db_1     | LOG:  database system is ready to accept connections
db_1     | LOG:  autovacuum launcher started
db_1     |  done
db_1     | server started
db_1     | ALTER ROLE
db_1     |
db_1     |
db_1     | /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/initdb.sh
api_1    | Starting 'run'...
db_1     | CREATE DATABASE
db_1     | CREATE EXTENSION
db_1     | CREATE EXTENSION
db_1     |
db_1     | LOG:  received fast shutdown request
db_1     | LOG:  aborting any active transactions
db_1     | LOG:  autovacuum launcher shutting down
db_1     | waiting for server to shut down....LOG:  shutting down
db_1     | LOG:  database system is shut down
api_1    | Starting 'db-migrate'...
api_1    | Error: connect ECONNREFUSED 172.18.0.3:5432
api_1    |     at Object._errnoException (util.js:1022:11)
api_1    |     at _exceptionWithHostPort (util.js:1045:20)
api_1    |     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1161:14)
api_1    | Starting 'build'...
db_1     |  done
db_1     | server stopped
db_1     |
db_1     | PostgreSQL init process complete; ready for start up.
db_1     |
api_1    | src/DataLoaders.js -> build/DataLoaders.js
api_1    | src/db.js -> build/db.js
api_1    | src/app.js -> build/app.js
api_1    | src/email.js -> build/email.js
db_1     | LOG:  database system was shut down at 2017-08-16 20:28:57 UTC
db_1     | LOG:  MultiXact member wraparound protections are now enabled
db_1     | LOG:  database system is ready to accept connections
db_1     | LOG:  autovacuum launcher started
api_1    | src/passport.js -> build/passport.js
api_1    | src/redis.js -> build/redis.js
api_1    | src/server.js -> build/server.js
api_1    | src/routes/account.js -> build/routes/account.js
api_1    | src/schema/Comment.js -> build/schema/Comment.js
api_1    | src/schema/CommentType.js -> build/schema/CommentType.js
api_1    | src/schema/EmailType.js -> build/schema/EmailType.js
api_1    | src/schema/Node.js -> build/schema/Node.js
api_1    | src/schema/README.md -> build/schema/README.md
api_1    | src/schema/Story.js -> build/schema/Story.js
api_1    | src/schema/StoryType.js -> build/schema/StoryType.js
api_1    | src/schema/User.js -> build/schema/User.js
api_1    | src/schema/UserType.js -> build/schema/UserType.js
api_1    | src/schema/ValidationError.js -> build/schema/ValidationError.js
api_1    | src/schema/index.js -> build/schema/index.js
api_1    | src/emails/welcome/html.hbs -> build/emails/welcome/html.js
api_1    | src/emails/welcome/subject.hbs -> build/emails/welcome/subject.js
api_1    | Finished 'build' after 1172ms
api_1    | Node.js API server is listening on http://api:8080/

The next step of seeding the database understandably throws errors as a result:

winpty docker-compose exec api yarn db-seed

yarn db-seed v0.27.5
$ node tools/db.js seed
Starting 'db-seed'...
db_1     | ERROR:  relation "users" does not exist at character 13
db_1     | STATEMENT:  insert into "users" ("display_name", "emails", "image_url") values ($1, $2, $3) returning "id"
db_1     | ERROR:  relation "users" does not exist at character 13
db_1     | STATEMENT:  insert into "users" ("display_name", "emails", "image_url") values ($1, $2, $3) returning "id"
db_1     | ERROR:  relation "users" does not exist at character 13
db_1     | STATEMENT:  insert into "users" ("display_name", "emails", "image_url") values ($1, $2, $3) returning "id"
db_1     | ERROR:  relation "users" does not exist at character 13
db_1     | STATEMENT:  insert into "users" ("display_name", "emails", "image_url") values ($1, $2, $3) returning "id"
db_1     | ERROR:  relation "users" does not exist at character 13
db_1     | STATEMENT:  insert into "users" ("display_name", "emails", "image_url") values ($1, $2, $3) returning "id"
db_1     | ERROR:  relation "users" does not exist at character 13
db_1     | STATEMENT:  insert into "users" ("display_name", "emails", "image_url") values ($1, $2, $3) returning "id"
db_1     | ERROR:  relation "users" does not exist at character 13
db_1     | STATEMENT:  insert into "users" ("display_name", "emails", "image_url") values ($1, $2, $3) returning "id"
db_1     | ERROR:  relation "users" does not exist at character 13
db_1     | STATEMENT:  insert into "users" ("display_name", "emails", "image_url") values ($1, $2, $3) returning "id"
db_1     | ERROR:  relation "users" does not exist at character 13
db_1     | STATEMENT:  insert into "users" ("display_name", "emails", "image_url") values ($1, $2, $3) returning "id"
db_1     | ERROR:  relation "users" does not exist at character 13
db_1     | STATEMENT:  insert into "users" ("display_name", "emails", "image_url") values ($1, $2, $3) returning "id"
error: relation "users" does not exist
    at Connection.parseE (/usr/src/app/node_modules/pg/lib/connection.js:546:11)
    at Connection.parseMessage (/usr/src/app/node_modules/pg/lib/connection.js:371:19)
    at Socket.<anonymous> (/usr/src/app/node_modules/pg/lib/connection.js:114:22)
    at emitOne (events.js:115:13)
    at Socket.emit (events.js:210:7)
    at addChunk (_stream_readable.js:252:12)
    at readableAddChunk (_stream_readable.js:239:11)
    at Socket.Readable.push (_stream_readable.js:197:10)
    at TCP.onread (net.js:589:20)
Done in 4.07s.

Related*:

https://stackoverflow.com/questions/11616835/r-command-not-found-bashrc-bash-profile

@MikePugs
Copy link
Author

I went to my home computer, deleted the repository, containers, volumes and started over.

It seems to have worked now. Further research suggests that the "fast shutdown" described above is normal behavior.

Here is the output which resulted in what seems to be a successful install on my windows 10 machine


$ docker-compose up
Creating volume "exampleapi_redis" with default driver
Creating volume "exampleapi_db" with default driver
Creating volume "exampleapi_yarn" with default driver
Creating exampleapi_redis_1 ...
Creating exampleapi_db_1 ...
Creating exampleapi_redis_1
Creating exampleapi_db_1 ... done
Creating exampleapi_api_1 ...
Creating exampleapi_api_1 ... done
Creating exampleapi_nginx_1 ...
Creating exampleapi_nginx_1 ... done
Attaching to exampleapi_redis_1, exampleapi_db_1, exampleapi_api_1, exampleapi_nginx_1
redis_1 | 1:C 17 Aug 00:36:53.169 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis_1 | 1:C 17 Aug 00:36:53.169 # Redis version=4.0.1, bits=64, commit=00000000, modified=0, pid=1, just started
redis_1 | 1:C 17 Aug 00:36:53.169 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
db_1 | The files belonging to this database system will be owned by user "postgres".
redis_1 | 1:M 17 Aug 00:36:53.170 * Running mode=standalone, port=6379.
db_1 | This user must also own the server process.
redis_1 | 1:M 17 Aug 00:36:53.170 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
db_1 |
redis_1 | 1:M 17 Aug 00:36:53.170 # Server initialized
redis_1 | 1:M 17 Aug 00:36:53.170 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
db_1 | The database cluster will be initialized with locale "en_US.utf8".
redis_1 | 1:M 17 Aug 00:36:53.170 * Ready to accept connections
db_1 | The default database encoding has accordingly been set to "UTF8".
db_1 | The default text search configuration will be set to "english".
db_1 |
db_1 | Data page checksums are disabled.
db_1 |
db_1 | fixing permissions on existing directory /var/lib/postgresql/data ... ok
db_1 | creating subdirectories ... ok
db_1 | selecting default max_connections ... 100
db_1 | selecting default shared_buffers ... 128MB
db_1 | selecting dynamic shared memory implementation ... posix
db_1 | creating configuration files ... ok
db_1 | running bootstrap script ... ok
db_1 | performing post-bootstrap initialization ... sh: locale: not found
db_1 | No usable system locales were found.
db_1 | Use the option "--debug" to see details.
db_1 | ok
db_1 | syncing data to disk ... ok
db_1 |
db_1 | Success. You can now start the database server using:
db_1 |
db_1 | pg_ctl -D /var/lib/postgresql/data -l logfile start
db_1 |
db_1 |
db_1 | WARNING: enabling "trust" authentication for local connections
db_1 | You can change this by editing pg_hba.conf or using the option -A, or
db_1 | --auth-local and --auth-host, the next time you run initdb.
db_1 | ****************************************************
db_1 | WARNING: No password has been set for the database.
db_1 | This will allow anyone with access to the
db_1 | Postgres port to access your database. In
db_1 | Docker's default configuration, this is
db_1 | effectively any other container on the same
db_1 | system.
db_1 |
db_1 | Use "-e POSTGRES_PASSWORD=password" to set
db_1 | it in "docker run".
db_1 | ****************************************************
db_1 | waiting for server to start....LOG: could not bind IPv6 socket: Address not available
db_1 | HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
db_1 | LOG: database system was shut down at 2017-08-17 00:36:55 UTC
db_1 | LOG: MultiXact member wraparound protections are now enabled
db_1 | LOG: database system is ready to accept connections
db_1 | LOG: autovacuum launcher started
db_1 | done
db_1 | server started
db_1 | ALTER ROLE
db_1 |
db_1 |
db_1 | /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/initdb.sh
db_1 | CREATE DATABASE
db_1 | CREATE EXTENSION
db_1 | CREATE EXTENSION
db_1 |
db_1 | LOG: received fast shutdown request
db_1 | LOG: aborting any active transactions
db_1 | LOG: autovacuum launcher shutting down
db_1 | LOG: shutting down
db_1 | waiting for server to shut down....LOG: database system is shut down
api_1 | Starting 'run'...
db_1 | done
db_1 | server stopped
db_1 |
db_1 | PostgreSQL init process complete; ready for start up.
db_1 |
db_1 | LOG: database system was shut down at 2017-08-17 00:36:56 UTC
db_1 | LOG: MultiXact member wraparound protections are now enabled
db_1 | LOG: database system is ready to accept connections
db_1 | LOG: autovacuum launcher started
api_1 | Starting 'db-migrate'...
api_1 | Finished 'db-migrate' after 280ms
api_1 | Starting 'build'...
api_1 | src/DataLoaders.js -> build/DataLoaders.js
api_1 | src/app.js -> build/app.js
api_1 | src/db.js -> build/db.js
api_1 | src/email.js -> build/email.js
api_1 | src/passport.js -> build/passport.js
api_1 | src/redis.js -> build/redis.js
api_1 | src/server.js -> build/server.js
api_1 | src/routes/account.js -> build/routes/account.js
api_1 | src/schema/Comment.js -> build/schema/Comment.js
api_1 | src/schema/CommentType.js -> build/schema/CommentType.js
api_1 | src/schema/EmailType.js -> build/schema/EmailType.js
api_1 | src/schema/Node.js -> build/schema/Node.js
api_1 | src/schema/README.md -> build/schema/README.md
api_1 | src/schema/Story.js -> build/schema/Story.js
api_1 | src/schema/StoryType.js -> build/schema/StoryType.js
api_1 | src/schema/User.js -> build/schema/User.js
api_1 | src/schema/UserType.js -> build/schema/UserType.js
api_1 | src/schema/ValidationError.js -> build/schema/ValidationError.js
api_1 | src/schema/index.js -> build/schema/index.js
api_1 | src/emails/welcome/html.hbs -> build/emails/welcome/html.js
api_1 | src/emails/welcome/subject.hbs -> build/emails/welcome/subject.js
api_1 | Finished 'build' after 1417ms
api_1 | Node.js API server is listening on http://api:8080/

Thanks for the help.

@psyanite
Copy link
Contributor

psyanite commented Oct 10, 2017

Great to hear your issue is now resolved! @MikePugs 👍

I thought I would find the same issue in this thread but it seems not so, my issue is slightly different please let me know if I should open a new issue.

I followed the steps in this article:
https://medium.com/@daveyedwards/how-to-setup-kriasofts-nodejs-api-starter-on-windows-10-a092d6e34882

I also ran docker-compose build because it had permission issues as well installing what I think are the dependencies...

But when I ran docker-compose run this happens:

api_1 | yarn install v1.1.0
api_1 | [1/4] Resolving packages...
api_1 | [2/4] Fetching packages...
api_1 | info fsevents@1.1.2: The platform "linux" is incompatible with this module.
api_1 | info "fsevents@1.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
api_1 | [3/4] Linking dependencies...
api_1 | error Could not write file "/usr/src/app/yarn-error.log": "EACCES: permission denied, open '/usr/src/app/yarn-error.log'"
api_1 | error An unexpected error occurred: "EACCES: permission denied, mkdir '/usr/src/app/node_modules'".
api_1 | info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
api_1 | module.js:529
api_1 | throw err;
api_1 | ^
api_1 |
api_1 | Error: Cannot find module 'del'
api_1 | at Function.Module._resolveFilename (module.js:527:15) api_1 | at Function.Module._load (module.js:476:23)
api_1 | at Module.require (module.js:568:17)
api_1 | at require (internal/module.js:11:18)
api_1 | at Object. (/usr/src/app/tools/build.js:13:13)
api_1 | at Module._compile (module.js:624:30)
api_1 | at Object.Module._extensions..js (module.js:635:10) api_1 | at Module.load (module.js:545:32)
api_1 | at tryModuleLoad (module.js:508:12)
api_1 | at Function.Module._load (module.js:500:3)
nas_api_1 exited with code 1

I'd really appreciate any help :( This is a fantastic project!

@koistya
Copy link
Member

koistya commented Oct 10, 2017

@psyanite the error says that there are missing NPM modules (e.g. node_modules/del). You can try removing node_modules folder and install NPM dependencies from scratch:

$ docker-compose run --rm --no-deps api yarn    # Installs deps inside the "api" container

@psyanite
Copy link
Contributor

psyanite commented Oct 11, 2017

Thank's @koistya! I'll give it a try and open another issue or something if needed, but I think it's a windows bug that there are some permission issues. Cheers 🍰

@koistya
Copy link
Member

koistya commented Feb 3, 2020

I just removed Docker dependency, it should work fine on Windows, all you need is just Node.js 10+ runtime, Yarn and a local or remote instance of PostgreSQL server.

@koistya koistya closed this as completed Feb 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants