I have a web application running in a Docker container. From my understanding, using the ‘cypress/base’ image should provide the necessary dependencies. However, trying to start the Cypress tests from an attached shell (run with headless), results in the following output:
Unhandled rejection Error: Your system is missing the dependency: Xvfb
Install Xvfb and run Cypress again.
Read our documentation on dependencies for more information:
https://on.cypress.io/required-dependencies
If you are using Docker, we provide containers with all required dependencies installed.
----------
Error: spawn Xvfb ENOENT
----------
Platform: linux (Debian - 10.11)
Cypress Version: 8.5.0
at /app/node_modules/cypress/lib/errors.js:328:17
at tryCatcher (/app/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/app/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/app/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/app/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/app/node_modules/bluebird/js/release/promise.js:729:18)
at Promise._fulfill (/app/node_modules/bluebird/js/release/promise.js:673:18)
at Promise._resolveCallback (/app/node_modules/bluebird/js/release/promise.js:466:57)
at Promise._settlePromiseFromHandler (/app/node_modules/bluebird/js/release/promise.js:559:17)
at Promise._settlePromise (/app/node_modules/bluebird/js/release/promise.js:604:18)
Installing Xvfb manually does not resolve the issue; it only results in another error saying Cypress’s dependencies could not be resolved.
Dockerfile:
FROM node:16
RUN mkdir /app
WORKDIR /app
COPY package.json .
COPY yarn.lock .
RUN yarn
RUN npx browserslist#latest --update-db
COPY . .
CMD ["yarn", "start"]
docker-compose.yml:
version: "3"
services:
ponder:
image: cypress/base:16
container_name: myApplication
build: ./
volumes:
- ./src:/app/src
- ./public:/app/public
- ./package.json:/app/package.json
- /app/node_modules
ports:
- 3001:3000
stdin_open: true
Thoughts?
Edit:
Xvfb was installed manually by running apt-get update, then apt-get install xvfb. Attempting to run Cypress after this, gives:
Unhandled rejection Error: Cypress failed to start.
This may be due to a missing library or dependency. https://on.cypress.io/required-dependencies
Please refer to the error below for more details.
----------
/root/.cache/Cypress/8.5.0/Cypress/Cypress: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory
----------
Platform: linux (Debian - 10.11)
Cypress Version: 8.5.0
at /app/node_modules/cypress/lib/errors.js:328:17
at tryCatcher (/app/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/app/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/app/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/app/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/app/node_modules/bluebird/js/release/promise.js:729:18)
at Promise._fulfill (/app/node_modules/bluebird/js/release/promise.js:673:18)
at Promise._resolveCallback (/app/node_modules/bluebird/js/release/promise.js:466:57)
at Promise._settlePromiseFromHandler (/app/node_modules/bluebird/js/release/promise.js:559:17)
at Promise._settlePromise (/app/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/app/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/app/node_modules/bluebird/js/release/promise.js:729:18)
at Promise._fulfill (/app/node_modules/bluebird/js/release/promise.js:673:18)
at Promise._resolveCallback (/app/node_modules/bluebird/js/release/promise.js:466:57)
at Promise._settlePromiseFromHandler (/app/node_modules/bluebird/js/release/promise.js:559:17)
at Promise._settlePromise (/app/node_modules/bluebird/js/release/promise.js:604:18)
Instead of FROM node:16, try using FROM cypress/included . that image comes with node 16 already and browsers pre-installed. NOTE: the image might be a lot larger.
Nice attempt but you are overdoing it a little.
You need to install dependencies. https://docs.cypress.io/guides/continuous-integration/introduction#Dependencies
apt-get install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb
Related
I'm trying to install vue.js in docker. However it comes with an error and I am completely stuck at this point. Please help me solving this issue.
I've already prepared DockerFile and docker-compose.yml.
docker-compose.yml:
version: '3.8'
services:
app:
build: .
container_name: vue-curriculum
ports:
- '8880:8880'
volumes:
- ./app:/app
tty: true
Dockerfile:
FROM node:15.11.0-alpine
WORKDIR /app
RUN yarn global add #vue/cli
Process:
docker-compose up -d # could make a container
docker container exec -it [container name] sh
vue create .
Here comes an error...
Vue CLI v5.0.8
? Generate project in current directory? Yes
Vue CLI v5.0.8
? Please pick a preset: Default ([Vue 2] babel, eslint)
? Pick the package manager to use when installing dependencies: Yarn
Vue CLI v5.0.8
✨ Creating project in /app.
⚙️ Installing CLI plugins. This might take a while...
yarn install v1.22.5
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
error jest-worker#28.1.3: The engine "node" is incompatible with this module. Expected version "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0". Got "15.11.0"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
ERROR Error: command failed: yarn
Error: command failed: yarn
at ChildProcess.<anonymous> (/usr/local/share/.config/yarn/global/node_modules/#vue/cli/lib/util/executeCommand.js:138:16)
at ChildProcess.emit (node:events:378:20)
at maybeClose (node:internal/child_process:1067:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
/app #
I have a VUE app I have been developing locally which I am trying to deploy to a remote server for testing.
My dev machine is running Arch with Docker 20.10.17
My VUE app has the following Dev.Dockerfile which is used to build it:
FROM node:lts-alpine
WORKDIR /code
COPY package*.json /code/
RUN npm install --location=global #vue/cli
RUN yarn install
COPY . .
# serve application in development
CMD [ "yarn", "serve" ]
The relevant service in my docker-compose.yml is:
frontend:
build:
context: ./frontend
dockerfile: dockerfiles/Dev.Dockerfile
command: yarn serve
stdin_open: true
restart: always
volumes:
- ./frontend/:/code/
ports:
- "8080:8080"
The VUE service is part of a larger set of services I am setting up with docker-compose.
This seems to be running fine on my local machine (Arch with the latest Docker).
When I try to deploy this to an Ubuntu 20.04 server, however, I run into issues.
The server is running Docker-compose 1.29.2 and Docker 20.17.1
The build goes fine, but when I try to run docker-compose up I get:
yarn run v1.22.19
$ vue-cli-service serve
/bin/sh: vue-cli-service: not found
Reading elsewhere on stackoverflow about this issue, I tried installing:
RUN npm install -g #vue/cli-service
This changes the error to:
yarn run v1.22.19
$ vue-cli-service serve
...
Error: Cannot find module '#vue/cli-plugin-babel'
I have also tried to explicitly install:
RUN npm install #babel/core #babel/preset-env
RUN npm install #vue/cli-plugin-babel
The error remains the same.
This is not an issue on my local machine running Arch, only the remote machine running Ubuntu 20. How do I fix this?
MORE INFORMATION.
After experimenting with #amir's answer I have some more information.
On Arch, Docker compose is now a command in Docker and I have been using it without thinking about it. On the Ubuntu server that doesn't work and instead I am using the 'docker-compose' command. I "assumed" these were functionally the same but I think docker-compose is causing the failure.
If I build my frontend service manually with Docker and my Dev.Dockerfile and then run it with Docker it works perfectly. No warnings.
Building with Docker-compose works... but throws a number a warnings:
yarn add v1.22.19
info No lockfile found.
[1/4] Resolving packages...
warning #vue/cli-service > cssnano > cssnano-preset-default > postcss-svgo > svgo > stable#0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
warning #vue/cli > #vue/cli-ui > apollo-server-express > subscriptions-transport-ws#0.9.19: The `subscriptions-transport-ws` package is no longer maintained. We recommend you use `graphql-ws` instead. For help migrating Apollo software to `graphql-ws`, see https://www.apollographql.com/docs/apollo-server/data/subscriptions/#switching-from-subscriptions-transport-ws For general help using `graphql-ws`, see https://github.com/enisdenjo/graphql-ws/blob/master/README.md
warning #vue/cli > #vue/cli-ui > apollo-server-express > apollo-server-core > subscriptions-transport-ws#0.9.19: The `subscriptions-transport-ws` package is no longer maintained. We recommend you use `graphql-ws` instead. For help migrating Apollo software to `graphql-ws`, see https://www.apollographql.com/docs/apollo-server/data/subscriptions/#switching-from-subscriptions-transport-ws For general help using `graphql-ws`, see https://github.com/enisdenjo/graphql-ws/blob/master/README.md
warning #vue/cli > #vue/cli-ui > apollo-server-express > graphql-tools#4.0.8: This package has been deprecated and now it only exports makeExecutableSchema.\nAnd it will no longer receive updates.\nWe recommend you to migrate to scoped packages such as #graphql-tools/schema, #graphql-tools/utils and etc.\nCheck out https://www.graphql-tools.com to learn what package you should use instead
warning #vue/cli > #vue/cli-ui > apollo-server-express > apollo-server-core > graphql-tools#4.0.8: This package has been deprecated and now it only exports makeExecutableSchema.\nAnd it will no longer receive updates.\nWe recommend you to migrate to scoped packages such as #graphql-tools/schema, #graphql-tools/utils and etc.\nCheck out https://www.graphql-tools.com to learn what package you should use instead
warning #vue/cli > #vue/cli-ui > apollo-server-express > graphql-tools > uuid#3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
warning #vue/cli > vue-codemod > jscodeshift > micromatch > snapdragon > source-map-resolve#0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
warning #vue/cli > #vue/cli-ui > apollo-server-express > apollo-server-core > apollo-cache-control#0.14.0: The functionality provided by the `apollo-cache-control` package is built in to `apollo-server-core` starting with Apollo Server 3. See https://www.apollographql.com/docs/apollo-server/migration/#cachecontrol for details.
warning #vue/cli > #vue/cli-ui > apollo-server-express > apollo-server-core > graphql-extensions#0.15.0: The `graphql-extensions` API has been removed from Apollo Server 3. Use the plugin API instead: https://www.apollographql.com/docs/apollo-server/integrations/plugins/
warning #vue/cli > vue-codemod > jscodeshift > micromatch > snapdragon > source-map-resolve > resolve-url#0.2.1: https://github.com/lydell/resolve-url#deprecated
warning #vue/cli > vue-codemod > jscodeshift > micromatch > snapdragon > source-map-resolve > source-map-url#0.4.1: See https://github.com/lydell/source-map-url#deprecated
warning #vue/cli > vue-codemod > jscodeshift > micromatch > snapdragon > source-map-resolve > urix#0.1.0: Please see https://github.com/lydell/urix#deprecated
warning #vue/cli > #vue/cli-ui > apollo-server-express > apollo-server-core > apollo-tracing#0.15.0: The `apollo-tracing` package is no longer part of Apollo Server 3. See https://www.apollographql.com/docs/apollo-server/migration/#tracing for details
So it isn't finding the yarn.lock file - which is there - and throwing a number of module errors.
Again, this does not occur on my Arch machine running 'Docker compose' but does on an Ubuntu 20.04 server running docker-compose
I did try adding a volume directly to the node_module directory as per #amir's answer but that did not work. I also tried changing the copy location for the Dockerfile as per that answer. No joy.
Ideas? I am really stuck here.
Hi I fixed my own version with below dockerfile:
FROM node:16.6-alpine3.14
WORKDIR /code
RUN apk update && apk upgrade && apk add curl py-pip make g++
COPY package*.json ./
COPY . .
EXPOSE 8080
RUN yarn install
CMD yarn dev # or serve
I think there might be a problem in your copying package.json file line
frontend:
container_name: frontend
ports:
- 8080:8080
env_file:
- ./.env
build:
context: <Context>
target: <TARGET>
networks:
- network
volumes:
- <Location>:/code
- <Location>/node_modules
Ok. After a lot of trial and error and lots of help from #Amir Jani I was able to fix it.
In case it helps anyone else. What was occuring is the node_module directory was being overwritten in the final image build. This is simmilar to this issue
The fix was to add a volume to store the node_module directory. The syntax for the volume had to be absolute from the volume storing the code - since that's where my node_module was located.
Final Dockerfile and docker-compose.yml
FROM node:lts-alpine
WORKDIR /code
COPY package*.json /code/
RUN yarn add global #vue/cli
RUN yarn install
COPY . .
CMD [ "yarn", "serve" ]
docker-compose.yml
version: "3.9"
services:
...
frontend:
container_name: frontend
build:
context: ./frontend
dockerfile: dockerfiles/Dev.Dockerfile
restart: always
volumes:
- ./frontend/:/code/
- /code/node_modules
ports:
- "8080:8080"
I'm not sure this is the best solution, but it seems to work. Is mounting the node_modules bad for any reason?
I am still confused why this wasn't a problem on an Arch machine but was on Ubuntu 20. The versions of docker used were the same. If anyone could explain that it would be a big help
Just add the following code in the Dockerfile:
NODE_ENV=development npm run instal and this might resolve vue-cli issue
I am developing with Next.js on my Mac OS host using Docker running Ubuntu 18 and bind mounting my development directory to the container. I want to know if there is any way when using SWC Minify in Next.js 12+ to not have to copy over the whole host build context to Docker and then use a yarn install build step and a persistent volume to run a development environment in Docker because of the missing #next/swc-linux-x64-gnu binary.
Relevant part of docker-compose.yaml
# Next.js Client and Server
my-nextjs:
container_name: my-nextjs
build:
context: ./www
dockerfile: Dockerfile
volumes:
# bind mounting my development directory to /app in Docker
- ./www:/app/
ports:
- "3911:3000"
I know that because it will be running on Linux and not Mac, Next.js SWC Minify will need a different binary so I explicitly add that to my dependencies on my Host machine with Yarn 3 (set to nodeLinker: node-modules in .yarnrc)
But that does not install the package to my host node_modules folder even though it is zipped in the .yarn/cache folder and appears in my package.json dependencies. I'm not sure why, and I think it's the reason for this problem.
Dockerfile:
FROM ubuntu:18.04
# Install Node.js
RUN apt-get update
RUN apt-get -y install curl
RUN apt-get -y install sudo
RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
RUN curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
RUN apt-get install -y nodejs
RUN apt-get install -y build-essential
# Install Yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
RUN sudo apt-get update
RUN sudo apt-get install yarn
WORKDIR /app
EXPOSE 3000
ENV PORT 3000
ENV NEXT_TELEMETRY_DISABLED 1
CMD ["yarn", "dev"]
When I try run this container I get:
❯ docker compose up my-nextjs
[+] Running 1/1
⠿ Container my-nextjs Recreated 0.1s
Attaching to my-nextjs
my-nextjs | ready - started server on 0.0.0.0:3000, url: http://localhost:3000
my-nextjs | info - Loaded env from /app/.env
my-nextjs | warn - SWC minify release candidate enabled. https://nextjs.org/docs/messages/swc-minify-enabled
my-nextjs | info - Attempted to load #next/swc-linux-x64-gnu, but it was not installed
my-nextjs | info - Attempted to load #next/swc-linux-x64-gnux32, but it was not installed
my-nextjs | info - Attempted to load #next/swc-linux-x64-musl, but it was not installed
my-nextjs | error - Failed to load SWC binary for linux/x64, see more info here: https://nextjs.org/docs/messages/failed-loading-swc
my-nextjs exited with code 1
I have figured out a workaround for this... adding - /app/node_modules to the docker-compose volumes to allow the container to persist that folder and in the Dockerfile:
COPY . /app/
RUN yarn install
Which gets the correct binary and persists it in its own node_modules over the bind mounted node_modules folder. But I'm just trying to see if there's a way to do it without copying over the whole thing from the build context. I'm sure that if Yarn 3 would actually install #next/swc-linux-x64-gnu to node_modules on my host then this could be possible.
Any thoughts?
In <repoDir>/.yarnrc, add:
--ignore-platform true
(Valid for yarn 1. You might want to double-check for later versions.)
Then run:
yarn add --dev #next/swc-linux-x64-gnu
This will install the Linux version of SWC in your node_modules, regardless of the platform, and you'll be able to use that in docker containers.
Trade-offs:
you lose the platform check for packages you install in the future
it won't be updated automatically when you update Next, you'll have to do it manually
I've installed Docker on Windows Server 2019 according to this manual but when I try to build my image it fails with errors:
Step 5/13 : RUN python3 -m venv /opt/venv
---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (windows/amd64) and no specific platform was requested
---> Running in 6b034a5cbe59
The command '/bin/sh -c python3 -m venv /opt/venv' returned a non-zero code: 4294967295: failed to shutdown container: container 6b034a5cbe59b5aae61936320a216306c1722c2cccf63a93069ed5897940c290 encountered an error during hcsshim::System::waitBackground: failure in a Windows system call: The virtual machine or container with the specified identifier is not running. (0xc0370110): subsequent terminate failed container 6b034a5cbe59b5aae61936320a216306c1722c2cccf63a93069ed5897940c290 encountered an error during hcsshim::System::waitBackground: failure in a Windows system call: The virtual machine or container with the specified identifier is not running. (0xc0370110)
ERROR: Service 'server' failed to build : Build failed
Here is my Dockerfile:
FROM python:3.8-slim-buster
ENV PYTHONUNBUFFERED 1
WORKDIR /app
COPY requirements/ requirements/
RUN python3 -m venv /opt/venv
RUN . ./opt/venv
RUN pip install --no-cache-dir --upgrade pip
RUN pip install --no-cache-dir --upgrade setuptools
RUN pip install --no-cache-dir -r requirements/common.txt
RUN pip install --no-cache-dir psycopg2-binary
COPY . .
RUN ["chmod", "+x", "/app/entrypoint.sh"]
ENTRYPOINT ["/app/entrypoint.sh"]
docker-compose.yml:
version: '3.9'
services:
server:
build:
context: .
dockerfile: Dockerfile
environment:
- "SQLALCHEMY_DATABASE_URI=<DB_CONNECTION_STR>"
- "RAW_DATA_DIR=/app/mydrive"
restart: "always"
volumes:
- ${CONFIG_PATH}\companyLogo.png:/app/files/branding/companyLogo.png
- mydrive:/app/mydrive
networks:
- internal
ports:
- '80:80'
command: "server"
volumes:
mydrive:
driver: local
driver_opts:
type: cifs
o: 'username=<USERNAME>,password=<PASSWORD>,domain=<DOMAIN>,uid=5000,gid=6000'
device: '<LINK_TO_MY_SERVER>'
networks:
internal:
As it shown above there is a simple Docker image for Flask, and if I will run a pure python:3.8-slim-buster image and run all these commands manually then all works. However, docker build . and docker-compose build fail. I tried to google the error and error code but there is a nothing useful.
Why does it happen? How to fix it?
I believe that you will need to use a Python image for Windows Server, as suggested here.
The official Docker images with Python over Windows are listed in the Docker Hub, marked with windowsservercore.
I have to configure custom build process of GC AppEngine application with GC Cloud Build.
First of all - I have an internal python repository on the GC ComputeEngine instance. It's accessible only through internal network and I use Remote-builder to run pip installcommand on the internal GC instance.
After downloading of dependencies from the internal repository I have to deploy results into the GC AppEngine.
Cloudbuild.yaml:
steps:
/#Download dependencies from the internal repository
- name: gcr.io/${ProjectName}/remote-builder
env:
- COMMAND=sudo bash workspace/download-dependencies.bash
- ZONE=us-east1-b
- INSTANCE_NAME=remote-cloud-build
- INSTANCE_ARGS=--image-project centos-cloud --image-family centos-7
- name: gcr.io/cloud-builders/docker
args: ['build', '-t', 'gcr.io/${ProjectName}/app', '.']
- name: gcr.io/cloud-builders/docker
args: ['push', 'gcr.io/${ProjectName}/app']
- name: gcr.io/cloud-builders/gcloud
args: ['app', 'deploy', 'app.yaml', '--image-url=gcr.io/${ProjectName}/${ProjectName}']
images: ['gcr.io/${ProjectName}/${ProjectName}']
app.yaml:
runtime: python
env: flex
entrypoint: python main.py
service: service-name
runtime_config:
python_version: 3
Dockerfile:
FROM gcr.io/google-appengine/python
WORKDIR /app
COPY . /app
download-dependencies.bash:
#!/usr/bin/env bash
easy_install pip
pip install --upgrade pip
pip install --upgrade setuptools
pip install -r workspace/requirements.txt'
After running of gcloud builds submit --config cloudbuild.yaml
new version of the application is deployed on the AppEngine but it doesn't work
Maybe the issue is the wrong image? As far as I understand, I need to configure Dockefile to collect all custom python dependencies into the image.
Could you please help me with it
Thanks in advance!
Update
I changed my Dockerfile according to the google guidline:
FROM gcr.io/google-appengine/python
RUN virtualenv /env
ENV VIRTUAL_ENV /env
ENV PATH /env/bin:$PATH
ADD . /app
CMD main.py
And new error is: /bin/sh: 1: main.py: not found
If I change last line to: CMD app/main.py - it creates version and doesn't work
Finally, I finished. There were some issues and I will share right configs below. Hope it will help someone.
steps:
# Move our code to instance inside the project to have access to the private repo
- name: gcr.io/${PROJECT_NAME}/remote-builder
env:
- COMMAND=sudo bash workspace/download-dependencies.bash:
- ZONE=us-east1-b
- INSTANCE_NAME=remote-cloud-build
- INSTANCE_ARGS=--image-project centos-cloud --image-family centos-7
#Build image with downloaded deps
- name: gcr.io/cloud-builders/docker
args: ['build', '-t', 'gcr.io/${PROJECT_NAME}/${APP_NAME}', '.']
#Push image to project repo
- name: gcr.io/cloud-builders/docker
args: ['push', 'gcr.io/${PROJECT_NAME}/${APP_NAME}']
#Deploy image to AppEngine
- name: gcr.io/cloud-builders/gcloud
args: ['app', 'deploy', 'app.yaml', '--image-url=gcr.io/${PROJECT_NAME}/${APP_NAME}']
images: ['gcr.io/${PROJECT_NAME}/${APP_NAME}']
timeout: '1800s'
download-dependencies.bash:
#!/usr/bin/env bash
easy_install pip
pip install --upgrade pip
pip install --upgrade setuptools
pip install wheel
#Download private deps and save it to volume (share folder between steps)
pip wheel --no-deps -r workspace/private-dependencies.txt -w workspace/lib --no-binary :all:
Dockerfile:
FROM gcr.io/google-appengine/python
COPY . /${APP_NAME}
RUN virtualenv /env
ENV VIRTUAL_ENV /env
ENV PATH /env/bin:$PATH
RUN pip install -r /${APP_NAME}/workspace/public-dependencies.txt
#Install private deps from volume
RUN pip install -f /${APP_NAME}/workspace/lib --no-index ${LIBRARY_NAME}
CMD gunicorn -b :$PORT main:app