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

Problem setting up dev environment with v2.7.1 #641

Open
migsar opened this issue Aug 4, 2021 · 2 comments
Open

Problem setting up dev environment with v2.7.1 #641

migsar opened this issue Aug 4, 2021 · 2 comments

Comments

@migsar
Copy link

migsar commented Aug 4, 2021

Describe the bug
I tried to set up my environment to be able to better debug. I think dev Dockerfile is outdated, specially after looking at both dockerfiles on the dev and prod folders.
I tried first just using docker/dev/docker-compose-example.yaml renamed to docker-compose.yaml.
I forked the repository and set my work branch at tag v2.7.1

To Reproduce
Steps to reproduce the behavior:

  1. Run yarn dev I got
$ yarn dev
yarn run v1.22.5
$ yarn dev:docker:up
$ cd docker/dev; docker-compose up
Building hasura-backend-plus
ERROR: Cannot locate specified Dockerfile: Dockerfile.dev
error Command failed with exit code 1.
  1. Replace in docker/dev/docker-compose-example.yaml:36 Dockerfile.dev by Dockerfile.
  2. Run yarn dev again.
$ yarn dev
yarn run v1.22.5
$ yarn dev:docker:up
$ cd docker/dev; docker-compose up
Building hasura-backend-plus
Step 1/12 : FROM node:14-alpine
 ---> d93b35a67404
Step 2/12 : RUN apk update && apk upgrade &&     apk add --no-cache bash git openssh
 ---> Running in 0d6586a50ace
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
v3.11.11-98-g4a4239f045 [http://dl-cdn.alpinelinux.org/alpine/v3.11/main]
v3.11.11-82-g6efedde556 [http://dl-cdn.alpinelinux.org/alpine/v3.11/community]
OK: 11275 distinct packages available
Upgrading critical system libraries and apk-tools:
(1/1) Upgrading apk-tools (2.10.6-r0 -> 2.10.8-r0)
Executing busybox-1.31.1-r10.trigger
Continuing the upgrade transaction with new apk-tools:
OK: 7 MiB in 16 packages
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
(1/17) Installing ncurses-terminfo-base (6.1_p20200118-r4)
(2/17) Installing ncurses-libs (6.1_p20200118-r4)
(3/17) Installing readline (8.0.1-r0)
(4/17) Installing bash (5.0.11-r1)
Executing bash-5.0.11-r1.post-install
(5/17) Installing ca-certificates (20191127-r2)
(6/17) Installing nghttp2-libs (1.40.0-r1)
(7/17) Installing libcurl (7.67.0-r5)
(8/17) Installing expat (2.2.9-r1)
(9/17) Installing pcre2 (10.34-r1)
(10/17) Installing git (2.24.4-r0)
(11/17) Installing openssh-keygen (8.1_p1-r0)
(12/17) Installing libedit (20191211.3.1-r0)
(13/17) Installing openssh-client (8.1_p1-r0)
(14/17) Installing openssh-sftp-server (8.1_p1-r0)
(15/17) Installing openssh-server-common (8.1_p1-r0)
(16/17) Installing openssh-server (8.1_p1-r0)
(17/17) Installing openssh (8.1_p1-r0)
Executing busybox-1.31.1-r10.trigger
Executing ca-certificates-20191127-r2.trigger
OK: 31 MiB in 33 packages
Removing intermediate container 0d6586a50ace
 ---> e3642d06ed7a
Step 3/12 : ARG NODE_ENV=development
 ---> Running in c4888a4c7049
Removing intermediate container c4888a4c7049
 ---> d892f51451be
Step 4/12 : ENV NODE_ENV $NODE_ENV
 ---> Running in 971eacdbcae2
Removing intermediate container 971eacdbcae2
 ---> b309bbf6f962
Step 5/12 : ENV PORT 3000
 ---> Running in 8d8ba74ae84b
Removing intermediate container 8d8ba74ae84b
 ---> f3a4ac4bc98c
Step 6/12 : ENV PGOPTIONS "-c search_path=auth"
 ---> Running in 1b6d85336da4
Removing intermediate container 1b6d85336da4
 ---> e9e4480c0238
Step 7/12 : WORKDIR /app
 ---> Running in 8efc6e23e781
Removing intermediate container 8efc6e23e781
 ---> d61abcfe2c0e
Step 8/12 : RUN git init /app
 ---> Running in 5bf19dc3bc52
Initialized empty Git repository in /app/.git/
Removing intermediate container 5bf19dc3bc52
 ---> eb34ea14046b
Step 9/12 : COPY package.json yarn.lock ./
ERROR: Service 'hasura-backend-plus' failed to build: COPY failed: file not found in build context or excluded by .dockerignore: stat package.json: file does not exist
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Expected behavior
I think it should create and image and start running the three services, but I am not sure about the dev flow with Docker, any information would be really appreciated.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Ubuntu 18.04
@mstephano
Copy link

mstephano commented Sep 3, 2021

Hi, here is how you could fix your issue:

  1. copy docker/dev/Dockerfile to root of repo (the hasura-backend-plus folder)

  2. edit this new copied Dockerfile and change line COPY ../../ . to COPY . .

  3. copy your docker/dev/docker-compose.yaml to root of repo

  4. edit this new copied docker-compose.yaml with the following under service hasura-backend-plus:

    1. change line dockerfile: Dockerfile.dev to dockerfile: Dockerfile
    2. add this line command: yarn dev:in-docker, this will allow you to run the code as debug inside your container, and will automatically recompile if you make a change in any of your local file
    3. in each line under volumes, replace ../../ by ./
  5. Your docker-compose.yml in the root should look like this under service hasura-backend-plus:

    ...
      hasura-backend-plus:
        image: 'nhost/hasura-backend-plus:latest'
        container_name: hbp-dev-hbp
        build:
          context: .
          dockerfile: Dockerfile
        command: yarn dev:in-docker
        depends_on:
          - graphql-engine
    ...
        volumes:
          - './custom:/app/custom'
          - './src:/app/src'
          - './migrations:/app/migrations'
    ...
    
  6. relunch docker-compose up

@ecchochan
Copy link

I followed your steps but get the following error, what am I missing?

Sending build context to Docker daemon  933.9kB
Step 1/12 : FROM node:14-alpine
 ---> 590973483ea0
Step 2/12 : RUN apk update && apk upgrade &&     apk add --no-cache bash git openssh
 ---> Using cache
 ---> 336dd7bf2289
Step 3/12 : ARG NODE_ENV=development
 ---> Using cache
 ---> f71c35878bbd
Step 4/12 : ENV NODE_ENV $NODE_ENV
 ---> Using cache
 ---> 03380ab61d4a
Step 5/12 : ENV PORT 3000
 ---> Using cache
 ---> 57b08fe79371
Step 6/12 : ENV PGOPTIONS "-c search_path=auth"
 ---> Using cache
 ---> 87685983da8a
Step 7/12 : WORKDIR /app
 ---> Using cache
 ---> 5d08dcac87d7
Step 8/12 : RUN git init /app
 ---> Using cache
 ---> 0f5ff3dd3c4c
Step 9/12 : COPY package.json yarn.lock ./
 ---> Using cache
 ---> 1d643f7718d9
Step 10/12 : RUN yarn install
 ---> Running in 8ae4b1f4c12e
yarn install v1.22.15
[1/4] Resolving packages...
[2/4] Fetching packages...
warning [email protected]: Invalid bin field for "url-loader".
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
error /app/node_modules/sharp: Command failed.
Exit code: 1
Command: (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
Arguments: 
Directory: /app/node_modules/sharp
Output:
ERR! sharp Use with musl 1.2.2 requires manual installation of libvips >= 8.10.5
info sharp Attempting to build from source via node-gyp but this may fail due to the above error
info sharp Please see https://sharp.pixelplumbing.com/install for required dependencies
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp ERR! find Python 
gyp ERR! find Python Python is not set from command line or npm configuration
gyp ERR! find Python Python is not set from environment variable PYTHON
gyp ERR! find Python checking if "python" can be used
gyp ERR! find Python - "python" is not in PATH or produced an error
gyp ERR! find Python checking if "python2" can be used
gyp ERR! find Python - "python2" is not in PATH or produced an error
gyp ERR! find Python checking if "python3" can be used
gyp ERR! find Python - "python3" is not in PATH or produced an error
gyp ERR! find Python 
gyp ERR! find Python **********************************************************
gyp ERR! find Python You need to install the latest version of Python.
gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
gyp ERR! find Python you can try one of the following options:
gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
gyp ERR! find Python   (accepted by both node-gyp and npm)
gyp ERR! find Python - Set the environment variable PYTHON
gyp ERR! find Python - Set the npm configuration variable python:
gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
gyp ERR! find Python For more information consult the documentation at:
gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
gyp ERR! find Python **********************************************************
gyp ERR! find Python 
gyp ERR! configure error 
gyp ERR! stack Error: Could not find any Python installation to use
gyp ERR! stack     at PythonFinder.fail (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:307:47)
gyp ERR! stack     at PythonFinder.runChecks (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:136:21)
gyp ERR! stack     at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:179:16)
gyp ERR! stack     at PythonFinder.execFileCallback (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:271:16)
gyp ERR! stack     at exithandler (child_process.js:390:5)
gyp ERR! stack     at ChildProcess.errorhandler (child_process.js:402:5)
gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:280:12)
gyp ERR! stack     at onErrorNT (internal/child_process.js:469:16)
gyp ERR! stack     at processTicksAndRejections (internal/process/task_queues.js:82:21)
gyp ERR! System Linux 5.11.0-41-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /app/node_modules/sharp
gyp ERR! node -v v14.18.2
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
The command '/bin/sh -c yarn install' returned a non-zero code: 1
ERROR: Service 'hasura-backend-plus' failed to build : Build failed

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