Proxy error when using docker-compose.yml - docker

I keep getting the following error
Proxy error: Could not proxy request /getProducts from localhost:3002 to http://localhost:3001.
when trying to 'docker compose up' my docker-compose.yml file for a mern application.
Here is the file:
version: "3.8"
services:
mongodb:
image: "mongo"
volumes:
- data:/data/db
backend:
image: "{path to docker hub image}"
container_name: armoireBackend
ports:
- "3001:3001"
volumes:
- logs:/app/logs
- ./backend:/app
- /app/node_modules
depends_on:
- mongodb
frontend:
image: "{path to docker hub image}"
ports:
- "3002:3000"
volumes:
- ./frontend:/src:/app/src
stdin_open: true
tty: true
depends_on:
- backend
volumes:
data:
logs:
My react's package.json:
{
"name": "frontend",
"version": "0.1.0",
"proxy":"http://backend:3001",
"private": true,
"dependencies": {
"#emotion/react": "^11.10.4",
"#emotion/styled": "^11.10.4",
"#mui/material": "^5.10.9",
"#testing-library/jest-dom": "^5.16.5",
"#testing-library/react": "^13.4.0",
"#testing-library/user-event": "^13.5.0",
"#trendmicro/react-sidenav": "^0.5.0",
"axios": "^1.1.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"react-router-dom": "^6.4.2"
},
"jest": {
"transformIgnorePatterns": ["node_modules\/(?!axios)"]
}
}
I'm not sure what I'm doing wrong - my proxy in the package.json file is now referring to the name of the container at backend, but still processes requests to localhost/3001?
I have also tried changing the proxy to
"proxy": {
"/api": {
"target": "http://backend:3001"
}
},
and
"proxy": "http://host.docker.internal:3001",
as well as adding a slash at the end of the original http://localhost:3001 proxy.
Any help would be appreciated.

Related

Nuxt js high CPU usage on docker

I used nuxt and Docker to develop the app,
but running Docker uses a lot of RAM and CPU
Please see my configs below and tell me your opinion
Do you have a solution?
package.json File
"name": "ladder",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
"lint:js": "eslint --ext \".js,.ts,.vue\" --ignore-path .gitignore .",
"lint:prettier": "prettier --check .",
"lint": "yarn lint:js && yarn lint:prettier",
"lintfix": "prettier --write --list-different . && yarn lint:js --fix",
"test": "jest"
},
}
nuxt.config.js File
target: 'static',
ssr: false,
head: {
title: 'ladder',
htmlAttrs: {
lang: 'en',
},
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ name: 'apple-mobile-web-app-status-bar-style', content: '#007ad5' },
],
},
css: [
],
plugins: [
],
components: true,
buildModules: [
'#nuxt/typescript-build',
'#nuxtjs/device',
'#nuxtjs/tailwindcss',
['#nuxtjs/vuetify']
],
modules: [
'nuxt-route-meta'
],
vuetify: {
treeShake: true,
defaultAssets: false
},
build: {},
watchers: {
webpack: {
ignored: /node_modules/
}
},
server: {
host: '0.0.0.0',
}
}
Dockerfile
FROM node:16
WORKDIR /portal
COPY package*.json ./
RUN yarn install
COPY . .
RUN yarn build
EXPOSE 3000
CMD ["yarn","dev"]
docker stats command
Image
Do you have a solution?

Elasticsearch can't find hunspell

I'm running elasticsearch from a docker-compose.yml file:
version: '3'
services:
mongo:
image: mongo
container_name: mongo-cust-mycom
ports:
- 27017:27017
volumes:
- cust-mycom-mongo:/data/db
networks:
- cust-mycom
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.5.4
container_name: elasticsearch-cust-mycom
ports:
- 9200:9200
- 9300:9300
volumes:
- cust-mycom-elastic:/usr/share/elasticsearch/data
- ./cust/config/elasticsearch/config/hunspell:/usr/share/elasticsearch/config/hunspell
networks:
- cust-mycom
environment:
- cluster.name=i3-elasticsearch
- xpack.security.enabled=false
- xpack.monitoring.enabled=false
- xpack.ml.enabled=false
- xpack.graph.enabled=false
- xpack.watcher.enabled=false
restart: unless-stopped
kibana:
image: docker.elastic.co/kibana/kibana:6.5.4
container_name: kibana-cust-mycom
ports:
- 5601:5601
networks:
- cust-mycom
depends_on:
- elasticsearch
restart: unless-stopped
networks:
cust-mycom:
driver: bridge
volumes:
cust-mycom-mongo:
cust-mycom-elastic:
using docker-compose up -d.
When I try to create my desired index, using the following json:
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 2,
"analysis": {
"filter": {
"swedish_stemmer": {
"type": "hunspell",
"language": "sv_SE"
},
"ins_pattern": {
"type": "pattern_capture",
"patterns": [
"([a-zåäö]*)(prod)"
]
},
"cust_stopwords": {
"type": "stop",
"stopwords": [ "en", "ett", "det", "den" ]
}
},
"analyzer": {
"swedish_index": {
"tokenizer": "standard",
"filter": [
"lowercase",
"ins_pattern",
"swedish_stemmer"
]
},
"swedish_query": {
"tokenizer": "standard",
"filter": [
"lowercase",
"swedish_stemmer",
"cust_stopwords"
]
}
}
}
},
"mappings": {
"default": {
"properties": {
"keywords": {
"type": "text",
"store": true,
"norms": false,
"analyzer": "swedish_index",
"search_analyzer": "swedish_query"
},
"audience": {
"type": "keyword"
},
"contentExcerpt": {
"type": "text"
},
"date": {
"type": "date",
"store": true,
"format": "dateOptionalTime"
},
"validUntil": {
"type": "date",
"store": true,
"format": "dateOptionalTime"
},
"informationType": {
"type": "text",
"store": true,
"norms": false,
"analyzer": "swedish_index",
"search_analyzer": "swedish_query"
},
"mainContentOfPage": {
"type": "text",
"store": true,
"norms": false,
"analyzer": "swedish_index",
"search_analyzer": "swedish_query",
"term_vector": "with_positions_offsets"
},
"thumbnailUrl": {
"type": "keyword",
"store": true,
"norms": false
},
"title": {
"type": "text",
"store": true,
"norms": false,
"analyzer": "swedish_index",
"search_analyzer": "swedish_query"
},
"url": {
"type": "keyword",
"store": true,
"norms": false
},
"tags": {
"type": "text",
"store": true,
"norms": false,
"analyzer": "swedish_index",
"search_analyzer": "swedish_query"
}
}
}
}
}
and the following script:
#!/bin/bash
curl -XDELETE http://localhost:9200/main
curl -XPUT -H "Content-type: application/json" -d #json/custse.index.json http://localhost:9200/main
curl -XPUT http://localhost:9200/main/_settings -H "Content-Type: application/json" -d "{
\"index\" : {
\"number_of_replicas\" : 0
}
}"
I get the following error message:
{"error":{"root_cause":[{"type":"illegal_state_exception","reason":"failed to load hunspell dictionary for locale: sv_SE"}]
I've tried putting my hunspell dictionaries in /usr/share/elasticsearch/config/hunspell/, /usr/share/elasticsearch/hunspell, /etc/elasticsearch/hunspell and /etc/elasticsearch/config/hunspell. It can't find any of them.
Here are the contents of the hunspell file:
/etc/elasticsearch$ ls hunspell
sv_SE
/etc/elasticsearch$ ls hunspell/sv_SE/
cust.dic README_sv_SE.txt sv_SE.aff sv_SE.dic
How can I make elasticsearch find the hunspell dictionaries?
I confirm that this configuration works:
version: '3.4'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.8.13
container_name: elasticsearch6
ports:
- "127.0.0.1:9200:9200"
environment:
- "ES_JAVA_OPTS=-Xms256m -Xmx256m"
restart: always
volumes:
- "es_data:/usr/share/elasticsearch/data"
- ./elasticsearch/hunspell:/usr/share/elasticsearch/config/hunspell
volumes:
es_data:

error showing while creating a debian file from electronjs project

I am getting the below error while making deb file of electronjs
Error: could not find the Electron app binary at "dist/app-linux-x64/koriwallet". You may need to re-bundle the app using Electron Packager's "executableName" option.
My package.json file is
{
"name": "wallet",
"version": "1.0.0",
"description": "wallet",
"main": "src/main.js",
"scripts": {
"start": "electron .",
"build": "electron-packager . myapp",
"pack": "electron-builder --dir",
"dist": "electron-builder",
"deb64": "electron-installer-debian --src dist/app-linux-x64/ --dest dist/installers/ --arch amd64"
},
"author": "wallet",
"license": "ISC",
"devDependencies": {
"asar": "^2.0.1",
"electron": "^5.0.6",
"electron-builder": "^21.1.1",
"electron-installer-debian": "^2.0.0",
"electron-packager": "^14.0.2"
},
"electronPackagerConfig": {
"packageManager": "npm",
"executableName": "kori"
},
"build": {
"appId": "wallet",
"linux": {
"category": "wallet"
}
},
"dependencies": {
"cookies": "^0.7.3",
"crypto": "^1.0.1",
"dpkg": "^1.0.0",
"jquery": "^3.4.1",
"jstorage": "^0.4.8"
}
}
My 2 cents. I'm making an Fedora 30 rpm and got:
An unhandled error has occurred inside Forge:
An error occured while making for target: rpm
could not find the Electron app binary at "/home/ajm/Documents/Projects/sunstealer.ets/out/sunstealer.ets product-linux-x64/sunstealer.ets". You may need to re-bundle the app using Electron Packager's "executableName" option.
Error: could not find the Electron app binary at "/home/ajm/Documents/Projects/sunstealer.ets/out/sunstealer.ets product-linux-x64/sunstealer.ets". You may need to re-bundle the app using Electron Packager's "executableName" option.
at error.wrapError (/home/ajm/Documents/Projects/sunstealer.ets/node_modules/electron-installer-common/src/installer.js:145:15)
Fix was update package.json from
"name": "sunstealer.ets",
"productName": "sunstealer.ets product",
to:
"name": "sunstealer.ets",
"productName": "sunstealer.ets",
i.e. same value. Then npm run make with:
"forge": {
"packagerConfig": {},
"makers": [
{
"name": "#electron-forge/maker-squirrel",
"config": {
"certificateFile": "./certs/adam_mauger.pfx",
"certificatePassword": "REDACTED"
}
},
{
"name": "#electron-forge/maker-dmg",
"config": {
"format": "ULFO"
}
},
{
"name": "#electron-forge/maker-rpm",
"config": {
}
},
created sunstealer.ets-1.0.0-1.x86_64.rpm. Hope that helps.
my 5 cents)
so, launch npm from root folder. there exist node_modules.
app stored in root/src. there exist node_modules.
and in root and in root/src have package.json
check root/src/package.json file. maybe there parameter "name" have default value in lowercase

Why codecov is not showing report in comments?

I'm trying to setup codecov as code coverage tool in a repository. However, it is passing Travis CI test but not showing codecov report. Here is link of travis report - https://travis-ci.org/fossasia/susper.com/builds/213793203 (see under bash <(curl -s https://codecov.io/bash)). What should I do?
Here is the source code -
package.json
{
"name": "susper",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"#angular/common": "2.4.0",
"#angular/compiler": "2.4.0",
"#angular/core": "2.4.0",
"#angular/forms": "2.4.0",
"#angular/http": "2.4.0",
"#angular/platform-browser": "2.4.0",
"#angular/platform-browser-dynamic": "2.4.0",
"#angular/router": "3.4.0",
"#ngrx/core": "^1.2.0",
"#ngrx/effects": "^2.0.0",
"#ngrx/router-store": "^1.2.5",
"#ngrx/store": "^2.2.1",
"#ngrx/store-devtools": "^3.2.3",
"core-js": "^2.4.1",
"ngrx-store-freeze": "^0.1.6",
"reselect": "^2.5.4",
"rxjs": "5.0.0-beta.12",
"ts-helpers": "^1.1.1",
"zone.js": "^0.6.23"
},
"devDependencies": {
"#angular/compiler-cli": "2.4.0",
"#types/jasmine": "2.5.38",
"#types/node": "^6.0.42",
"angular-cli": "1.0.0-beta.24",
+ "codecov.io": "^0.1.6",
"codelyzer": "~2.0.0-beta.1",
"jasmine-core": "2.5.2",
"jasmine-spec-reporter": "2.5.0",
- "karma": "1.2.0",
+ "karma": "^1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
+ "karma-coverage": "^1.1.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "4.0.9",
"ts-node": "1.2.1",
"tslint": "^4.0.2",
"typescript": "~2.0.3",
"webdriver-manager": "10.2.5"
}
}
travis.yml
sudo: required
dist: trusty
language: node_js
node_js:
- 6
before_install:
- export CHROME_BIN=chromium-browser
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
+- pip install --user codecov
before_script:
- ng build
script:
- ng lint
- >
docker run -ti -v $(pwd):/app --workdir=/app coala/base coala --version
after_success:
- bash ./deploy.sh
+- bash <(curl -s https://codecov.io/bash)
cache:
bundler: true
directories:
- node_modules
- .coala-cache
services: docker
branches:
only:
- angular
karma.conf.js
// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', 'angular-cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-remap-istanbul'),
- require('angular-cli/plugins/karma')
+ require('angular-cli/plugins/karma'),
+ require('karma-coverage')
],
files: [
{ pattern: './src/test.ts', watched: false }
],
preprocessors: {
- './src/test.ts': ['angular-cli']
+ './src/test.ts': ['angular-cli'],
+ 'src/app/**/*.js': ['coverage']
},
mime: {
'text/x-typescript': ['ts','tsx']
},
remapIstanbulReporter: {
reports: {
html: 'coverage',
lcovonly: './coverage/coverage.lcov'
}
},
+ coverageReporter: {
+ type : 'lcov',
+ dir : 'coverage/'
+ },
angularCli: {
config: './angular-cli.json',
environment: 'dev'
},
reporters: config.angularCli && config.angularCli.codeCoverage
? ['progress', 'karma-remap-istanbul']
- : ['progress'],
+ : ['progress', 'coverage'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};
tsconfig.json
{
"compilerOptions": {
"baseUrl": "",
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"mapRoot": "./",
"module": "es6",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es5",
"typeRoots": [
"../node_modules/#types"
]
}
}
Happy to help out!
Issue: No reports are generated. See https://travis-ci.org/fossasia/susper.com/builds/213793203#L390
Suggestions
You do not need to use the bash uploader and the node uploader in the same project. So you may choose one or the other. Nonetheless, you have configured Codecov properly.
Using Docker: http://docs.codecov.io/docs/testing-with-docker
I did not dive deep into your project, but I suspect the reports are within the docker container and need to be passed through to Travis.

Docker-Compose Up Works but Eb Local Run does not

Attached is my docker-compose file. Its a very simple project with a database and phpmyadmin to access it.
web:
build: ./docker_web/
links:
- db
ports:
- "80:80"
volumes:
- "./docker_web/www/:/var/www/site"
db:
image: mysql:latest
restart: always
volumes:
- "./.data/db:/var/lib/mysql"
environment:
MYSQL_ROOT_PASSWORD: ^^^^
MYSQL_DATABASE: electionbattle
MYSQL_USER: admin
MYSQL_PASSWORD: ^^^^
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin
environment:
- PMA_ARBITRARY=1
restart: always
ports:
- 8081:80
volumes:
- /sessions
links:
- db
If I run this it works fine. I created the equivlent for Amazon Docker Run for Elastic Beanstalk and it starts up but for some reason it can't find the volume that is holding my persisted database data in the .data folder.
I've tried changing .data to just data no luck.
Also I get a weird error when trying to do eb deploy
2016-09-24 19:56:10 UTC-0700 ERROR ECS task stopped due to: Essential container in task exited. (db: CannotCreateContainerError: API error (500): create ./.data/db/: "./.data/db/" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed web: phpmyadmin: )
I have no idea how to fix this error or why its happening. Any ideas?
Oops forgot to add my amazon file :).
{
"AWSEBDockerrunVersion": 2,
"volumes": [
{
"name": "web",
"host": {
"sourcePath": "./docker_web/www/"
}
},
{
"name": "db",
"host": {
"sourcePath": "./data/db/"
}
}
],
"containerDefinitions": [
{
"name": "web",
"image": "197984628663.dkr.ecr.us-west-1.amazonaws.com/electionbattleonline",
"memory": 200,
"essential": true,
"mountPoints": [
{
"sourceVolume": "web",
"containerPath": "/var/www/site",
"readOnly": false
}
],
"links": [
"db"
],
"portMappings": [
{
"hostPort": 80,
"containerPort": 80
}
]
},
{
"name": "db",
"image": "mysql:latest",
"environment": [
{
"name": "MYSQL_ROOT_PASSWORD",
"value": "^^^^"
},
{
"name": "MYSQL_DATABASE",
"value": "electionbattleonline"
},
{
"name": "MYSQL_USER",
"value": "admin"
},
{
"name": "MYSQL_PASSWORD",
"value": "^^^^"
}
],
"portMappings": [
{
"hostPort": 3306,
"containerPort": 3306
}
],
"mountPoints": [
{
"sourceVolume": "db",
"containerPath": "/var/lib/mysql",
"readOnly": false
}
],
"essential": true,
"memory": 200
},
{
"name": "phpmyadmin",
"image": "phpmyadmin/phpmyadmin",
"environment": [
{
"name": "PMA_ARBITRARY",
"value": "1"
}
],
"essential": true,
"memory": 128,
"links": [
"db"
],
"portMappings": [
{
"hostPort": 8081,
"containerPort": 80
}
]
}
]
}
Don't use relative paths.
Use eb local run to test before deploying, it will help you solve deployment issues. Your Dockerrun.aws.json file will be converted into a docker-compose.yml file and started using a local copy of docker.
You can find the generated docker-compose.yml in your project directory at the path .elasticbeanstalk/docker-compose.yml. You will notice that your volumes are missing from the docker-compose config file.
To fix this change your volumes to:
"volumes": [
{
"name": "web",
"host": {
"sourcePath": "/var/app/current/docker_web/www/"
}
},
{
"name": "db",
"host": {
"sourcePath": "/var/app/current/data/db/"
}
}
],
and create the directories in your app, then "eb local run" will correctly convert them.
eb deploy should now work correctly.

Resources