Unable to run a react native apps by docker container - react-native

I am trying to dockerize react native app but can't do.When i am running docker-compose build command it shows following issues.
error: cannot communicate with server: Post http://localhost/v2/snaps/android-studio: dial unix /run/snapd.socket: connect: no such file or directory
Dockerfile:
FROM ubuntu:20.04
RUN apt update && apt-get install -y curl \
&& curl -fsSL https://deb.nodesource.com/setup_14.x | bash - \
&& apt-get install -y nodejs
# Install android sdk
RUN apt-get install -y snapd
RUN snap install android-studio
WORKDIR /node
RUN npm install -i -g --force react-native-cli
RUN npm install -g --force react-native
COPY ["package.json", "package-lock.json", "./"]
RUN npm install -f --silent
Compose file:
version: '3.7'
services:
pd_rn:
build:
context: .
command: ["react-native", "start"]
ports:
- 8081:8081
volumes:
- ./:/node

Related

How to solve this error while creating new Project in React-Native?

While creating a new Project in React-Native getting this error in terminal:-
This will walk you through creating a new React Native project in /home/React-Native/TodoList Installing react-native...
How to overcome this error????
In Ubuntu 20.04
Step 1: Check the node version in terminal.
node --version
Step 2: If node version is 16 then uninstall node & npm with below commands:-
uninstall Node - sudo apt-get remove nodejs
uninstall Node - sudo apt-get remove npm
Step 3: Check in terminal Curl is installed or not with below command:-
curl --version
Step 4: If curl is not installed then install curl with below command:-
sudo apt install curl
Step 5: Then paste the below command in terminal:-
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
Step 6: Then install nodejs with below command.
sudo apt-get install -y nodejs
Step 7: Now create your New Project.

How do I install NPM on a Chromebook?

I installed NodeJS (via Linux terminal) but it doesn't seem to come bundled with NPM:
:~$ sudo apt-get install -y nodejs
:~$ node -v
:~$ v10.23.1
:~$ npm -v
:~$ -bash: npm: command not found
I have an Acer Chromebook R 13 with an ARM processor.
Installing NodeJs
sudo apt-get install curl gnupg -y
curl -sl https://deb.nodesource.com/setup_13.x | sudo -E bash -
sudo apt-get install -y nodejs
In my case I didn't have the install script for npm, so got it externally
curl -L https://npmjs.org/install.sh | sudo sh
nvm is recommended on the npmjs.com install page, and nvm has installation instructions of using an install script.
Open the Terminal app on Chromebook.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
nvm install node
npm is now ready.
Due to trying to answer in comments i will attempt to give a complete answer here.
You need to first aquire the correct package for your architecture. As you have noted you are using the Acer Chromebook R13. This uses the MediaTek MT8173C processsor which utilizes ARMv8 instruction set.
following these commands should get you up and running.
#first, download the proper package for your architecture
mkdir myNodeJS
cd myNodeJS
wget https://nodejs.org/dist/v14.15.5/node-v14.15.5-linux-arm64.tar.xz
tar -xf node-v14.15.5-linux-arm64.tar.xz
cd node-v14.15.5-linux-arm64
cd bin
sudo cp node /usr/local/bin
cd ..
cd /lib/node_modules/npm/scripts
./install.sh
That should be it, if you have problems, you can resort to the first link that i sent for install instructions

Install yarn and npm in WSL

I have installed Windows Subsystem for Linux (WSL) and Ubuntu 16.04 on my Windows 10. Then I followed this to install yarn:
sudo apt update
sudo apt install curl
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update
sudo apt install yarn
It did not raise any error. However, yarn --version returned
$ yarn --version
/mnt/c/Users/chengtie/AppData/Roaming/npm/yarn: 12: /mnt/c/Users/chengtie/AppData/Roaming/npm/yarn: node: not found
npm --version returned
$ npm --version
: not foundram Files/nodejs/npm: 3: /mnt/c/Program Files/nodejs/npm:
: not foundram Files/nodejs/npm: 5: /mnt/c/Program Files/nodejs/npm:
/mnt/c/Program Files/nodejs/npm: 6: /mnt/c/Program Files/nodejs/npm: Syntax error: word unexpected (expecting "in")
Does anyone know how to fix this?
Look at this:
/mnt/c/Users/chengtie/AppData/Roaming/npm/yarn: 12
It is looking for the yarn installed on Windows. You must or uninstall yarn from windows or remove it from the WSL's PATH.
Use the following to remove windows yarn from the PATH:
WIN_YARN_PATH="\$(dirname "\$(which yarn)")"
export PATH=\$(echo "\${PATH}" | sed -e "s#\${WIN_YARN_PATH}##")
You can add this to your .bashrc
Also, look at your error messages it is getting also npm from windows, you need to remove them from the path using the same technique.
You need to type:
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
then:
sudo apt-get install -y nodejs
You must install nodejs before
sudo apt-get install nodejs
If you have latest nodejs version installed:
I encountered the same issue and it got fixed by trying sudo npm -v and to get npm without sudo, I restarted the WSL.
If you don't have the latest nodejs version:
If you are on WSL, you can install the Latest stable version by
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
In place of setup_8.x you can keep setup_16.x for version 16 (which includes npm).
sudo apt-get install nodejs
check nodejs version by nodejs -v.
check npm version by npm -v.
If still the same error codes. try sudo npm -v or restart PC/ WSL then try npm -v.

Docker container closes after starting Apache

OK, So I've set up my docker container as I need it.
This is my current Dockerfile:
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y \
build-essential sudo software-properties-common \
libboost-dev libboost-filesystem-dev libboost-program-options-dev \
libboost-regex-dev libboost-system-dev libboost-thread-dev \
libicu-dev libtiff5-dev libfreetype6-dev libpng12-dev \
libxml2-dev libproj-dev libsqlite3-dev libgdal-dev \
libcairo-dev libharfbuzz-dev
RUN apt-get install -y postgresql postgresql-contrib
RUN apt-get install -y nodejs
RUN apt-get install -y python3-dev python-dev git python-pip \
python-setuptools python-wheel python3-setuptools \
python3-pip python3-wheel python-cairo-dev libboost-python-dev
RUN apt-get install -y ruby ruby-dev
RUN apt-get install -y wget curl
RUN pip install --upgrade pip
RUN pip install mapnik
RUN sudo gem install awesome_print colorize twitter_cldr \
nokogiri unidecoder
RUN apt-get -y install apache2 php-pear lynx-cur
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_PID_FILE /var/run/apache2.pid
EXPOSE 80
ADD apache-config.conf /etc/apache2/sites-enabled/000-default.conf
If I build it and run it with docker run -p 80:80 -it mycontainer, it runs fine. I can go via the terminal, do a /usr/bin/apache2ctl start, the server starts as usual and I can access it via localhost from my host's browser. Great!
Now, the idea is to simply put that /usr/bin/apache2ctl start command inside my Dockerfile, so that I don't have to write it every time the container starts.
However: if I put CMD ["/usr/sbin/apache2ctl", "start"] at the very end of my Dockerfile, build it and run it (with docker run -p 80:80 -it mycontainer), the container seems to start, outputs an Apache message and then it stops, no terminal, nothing. (nor does it run in the background).
What goes on? I just want to be able to start Apache automatically and keep the terminal live, so that I can do things there too.
Containers are a tool to isolate a running application, and they run until the application that was launched exits. If this application is a shell or command that launches a daemon in the background like you've done, when the shell or command returns, the container will promptly exit.
The solution is to run your application in the foreground. The steps to do this with Apache have already been done with the official images which I'd recommend using over building your own. You can see their Dockerfile here. And you can use their image on Dockerfile.

Travis CI for a Qt5 project

I am trying to use Travis CI with a Qt5 project, but I can't get the build to pass.
My .travis.yml
install:
- sudo apt-get update
- sudo apt-get install qt5-default qttools5-dev-tools
script:
- qmake -project
- qmake Ultron.pro
- make
Last segment of the error log:
0.58s$ sudo apt-get install qt5-default qttools5-dev-tools
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package qt5-default
E: Unable to locate package qttools5-dev-tools
The command "sudo apt-get install qt5-default qttools5-dev-tools" failed and exited with 100 during .
Your build has been stopped.
Full log: http://pastebin.ubuntu.com/8296581/
Does this have something to do with it not being an official package?
You need to add the correct repository and update apt:
sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa
sudo apt-get update -qq
Your .travis.yml will then look like:
before_install:
- sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa
- sudo apt-get update -qq
- sudo apt-get install qtbase5-dev qtdeclarative5-dev libqt5webkit5-dev libsqlite3-dev
- sudo apt-get install qt5-default qttools5-dev-tools
script:
- qmake -project
- qmake Ultron.pro
- make
see: Travis CI config to build against Qt5.0 on Ubuntu 12.04. Requires installing a PPA and certain packages for qt5 support. (jreese / gist:6207161)