How to build react native iOS app with docker? - ios

I want to build my react native iOS app using docker, My problem is that when I run react-native run-ios I'm getting an error that it cant find the simulator. I know the issue occur because I don't have Xcode on my docker.
I was looking for image for Mac or Xcode but all found is a few images for old versions of Xcode and they are not working anymore, I couldn't find images for Mac or any other way to install Xcode on my docker or install iOS simulator on image that isn't Mac OS.
Im attaching my docker:
FROM openjdk:8 as builder
ENV SDK_URL "https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip"
ENV ANDROID_HOME /usr/src/app
ENV ANDROID_BUILD_TOOLS_VERSION 28.0.3
ENV ANDROID_VERSION 28
ENV PATH $PATH:$ANDROID_HOME/bin
ARG NODE_VERSION=12.x
WORKDIR /usr/src/app
COPY package*.json ./
# installing android and java
RUN apt update -qq && apt install -qq -y --no-install-recommends \
apt-transport-https \
curl \
build-essential \
file \
git \
openjdk-8-jre \
gnupg2 \
python \
ruby-full \
openssh-client \
zip \
unzip \
&& rm -rf /var/lib/apt/lists/*/;
RUN npm i -g react-native-cli
#installing libraries
RUN npm install
COPY . .
RUN react-native run-ios;
Thank you for the help

This can't be done right now. The reason being that only macOS systems can develop native iOS apps; therefore, react native doesn't support iOS development on anything but a Mac. Docker containers are all built on Linux, not macOS, so this is currently unfeasible, unfortunately. See this post.

Related

Dockerfile for multistage image won't work

I am attempting to run a Dockerfile for a multistage image I cloned from github. The Dockerfile reads:
FROM openjdk:9-jdk-slim AS build
COPY certificates /usr/local/share/ca-certificates/certificates
RUN apt-get update && apt-get install --no-install-recommends -y -qq ca-certificates-java && \
apt-update ca-certificates --verbose
FROM openjdk:9-jre-slim
COPY --from=build /etc/ssl/certs/java/cacerts /etc/ssl/certs/java/cacerts
RUN groupadd --gid 1000 java && \
useradd --uid 1000 --gid java --shell /bin/bash --create-home java && \
chmod -R a+w /home/java
WORKDIR /home/java
USER java
When I attempt to run it with the command:
docker image build . -t layers:5
I get the following response:
executor failed running [/bin/sh -c apt-get update && apt-get install --no-install-recommends -y -qq ca-certificates-java && update-ca-certificates --verbose]: exit code: 100
I have tried solving this by removing '-y' and attaching 'apt-' to 'update-ca-certificates' and removing the dash between 'ca' and 'certificates', but none of them have worked. I'm unsure how to tackle this; your help would be most appreciated.
The base image, openjdk:9-jdk-slim, is an older image based on Debian Buster.
The apt-get update is the cause of the issue because of no public key existing.
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 648ACFD622F3D138 NO_PUBKEY 0E98404D386FA1D9
Normally, you'd import the key and be on your way. However, use of the image is not recommended because the Debian version is Debian GNU/Linux buster/sid. The Debian release docs say: "The unstable distribution is always called sid." You'd be better off upgrading to a stable version of Debian like an image built more recently for a newer version of Java.
Another option, that could cause more problems is to copy /etc/apt/trusted.gpg.d from a newer Buster release like buster-20221205-slim and then run your commands.

Install Java runtime in Debian based docker image

I am trying to install the java runtime in a Debian based docker image (mcr.microsoft.com/dotnet/core/sdk:3.1-buster). According to various howtos this should be possible by running
RUN apt update
RUN apt-get install openjdk-11-jre
The latter command comes back with
E: Unable to locate package openjdk-11-jre
However according to https://packages.debian.org/buster/openjdk-11-jre the package does exist. What am I doing wrong?
Unsure from which image your are pulling. I used slim, Dockerfile.
from debian:buster-slim
ENV DEBIAN_FRONTEND=noninteractive
RUN mkdir -p /usr/share/man/man1 /usr/share/man/man2
RUN apt-get update && \
apt-get install -y --no-install-recommends \
openjdk-11-jre
# Prints installed java version, just for checking
RUN java --version
NOTE: If you don't run the mkdir -p /usr/share/man/man1 /usr/share/man/man2 you'll run into dependency problems with ca-certificates, openjdk-11-jre-headless etc. I've been using this fix provided by community, haven't really checked the permanent fix.

How can we install google-chrome-stable on alpine image in dockerfile using dpkg?

I am trying to install google-chrome-stable on alpine image using dpkg. However, the dpkg is installed but it does not install google-chrome-stable and return this error instead? Is there a way to install google-chrome-stable in alpine image either using dpkg or other way?
dpkg: regarding google-chrome-stable_current_amd64.deb containing
google-chrome-stable:amd64, pre-dependency problem:
google-chrome-stable:amd64 pre-depends on dpkg (>= 1.14.0)
dpkg: error processing archive google-chrome-stable_current_amd64.deb (--install):
pre-dependency problem - not installing google-chrome-stable:amd64
Errors were encountered while processing:
Dockerfile:
# Base image
FROM ruby:2.6.3-alpine3.10
# Use node version 10.16.3, yarn version 1.16.0
RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.10/main/ nodejs=10.16.3-r0
RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.10/community/ yarn=1.16.0-r0
# Install dependencies
RUN apk upgrade
RUN apk --update \
add build-base \
git \
tzdata \
nodejs \
nodejs-npm \
bash \
curl \
yarn \
gzip \
postgresql-client \
postgresql-dev \
imagemagick \
imagemagick-dev \
imagemagick-libs \
chromium \
chromium-chromedriver \
ncurses \
less \
dpkg=1.19.7-r0 \
chromium \
chromium-chromedriver
RUN dpkg --add-architecture amd64
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
RUN dpkg -i google-chrome-stable_current_amd64.deb
# This is the base directory used in any
# further COPY, RUN and ENTRYPOINT commands
WORKDIR /webapp
# Copy Gemfile and Gemfile.lock and run bundle install
COPY Gemfile* /webapp/
RUN gem install bundler -v '1.17.3' && \
bundle _1.17.3_ install
# Copy everything to /webapp for docker image
COPY . ./
EXPOSE 3000
# Run the application
CMD ["rails", "server", "-b", "0.0.0.0"]
Installing the Chrome .deb file this way won't work on Alpine.
While the dpkg package is available in the Alpine repository, and is useful for installing lightweight Debian packages, you won't be able to use it for installing complex Debian packages, since it'll be impossible to satisfy many Debian dependencies. Alpine is generally not Debian compatible (relying on musl libc), so installing native Alpine packages using apk is the right way to go.
AFAIK, there's currently no Google Chrome Alpine Linux compatible, musl-libc build.
You could, however, install the Chromium browser, which is available using an apk package:
apk add chromium
Another option is enabling glibc on a vanilla Alpine image, making it compatible with Debian binaries. This is a fairly simple procedure, see: Dockerfile. However, it may not be suitable for images with existing applications such as ruby:2.6.3-alpine3.10. Moreover, even with a glibc setup on Alpine, Chrome is not likely to run without issues. I have made a quick attempt (Dockerfile) but couldn't get past the first segfault.
Edit 9/5/21: Running the debian compatible Chrome stable on Alpine is going to be a very difficult task to say the least. This is in part due to the very large number of dependencies and libraries. Trying to run it results with segfaults during dynamic linking and finally assertions from the dynamic linker. Even if we manage to get passed these issues and start Chrome it will probably be very unstable.
Since chromium-chromedriver is presented in your package list, I suppose that you want to do browser automation.As to browser automation, I used java and selenium, and download chromium binary and chromium driver binary manually.
What the most I want to tell you is that the chromium binary and chromium driver binary bundle might not work as expected, and you need to downgrade the version of either chrome driver or chrome and make several trial to find a matched versions that really work, no matter whether you use node.js or java selenium.
With Selenium, you have another option that you can deploy the chrome and chromedriver bundle as a http service in a different server, and make selenium invoke the remote chrome service.
ChromeDriver for version 93.0.4577.15

Building Go Application using confluent-kafka-go on Linux

I am trying to create a docker image with my go application. The application (which was developed on MacOS) depends on confluent-kafka-go which in turn depends on librdkafka-dev which I install in the Docker image like so:
FROM golang:1.1
RUN apt-get update
RUN apt-get -y install librdkafka-dev
VOLUME /workspace
WORKDIR /workspace/src/my/app/folder
ENTRYPOINT ["/bin/sh", "-c"]
I am getting the following error:
my/app/folder/vendor/github.com/confluentinc/confluent-kafka-go/kafka
../folder/vendor/github.com/confluentinc/confluent-kafka-go/kafka/00version.go:44:2: error: #error "confluent-kafka-go requires librdkafka v0.11.5 or later. Install the latest version of librdkafka from the Confluent repositories, see http://docs.confluent.io/current/installation.html"
As far as I understand the latest version is installed.
How can I fix it?
I had a similar issue a few weeks ago. IIRC confluent-kafka-go requires a recent version of librdkafka-dev, which simply was not yet released to alpine or others.
I was able to find it for ubuntu though, so my solution (which was more involved than I hoped for, but it worked), was to start from clean ubuntu, install librdkafka-dev, install Go version that I want and compile inside docker.
Here's how it looks:
FROM ubuntu
# Install the C lib for kafka
RUN apt-get update
RUN apt-get install -y --no-install-recommends apt-utils wget gnupg software-properties-common
RUN apt-get install -y apt-transport-https ca-certificates
RUN wget -qO - https://packages.confluent.io/deb/5.1/archive.key | apt-key add -
RUN add-apt-repository "deb [arch=amd64] https://packages.confluent.io/deb/5.1 stable main"
RUN apt-get update
RUN apt-get install -y librdkafka-dev
# Install Go
RUN add-apt-repository ppa:longsleep/golang-backports
RUN apt-get update
RUN apt-get install -y golang-1.11-go
# build the library
WORKDIR /go/src/gitlab.appsflyer.com/rantav/kafka-mirror-tester
COPY *.go ./
COPY // the rest of your go files. You may copy recursive if you want
COPY vendor vendor
RUN GOPATH=/go GOOS=linux /usr/lib/go-1.11/bin/go build -a -o main .
EXPOSE 8000
ENTRYPOINT ["./main"]
You can specify a version of package to be installed in apt-get command.
e.g
apt-get install librdkafka-dev=0.11.6~1confluent5.0.1-1
If that doesn't work then I think the apt sources doesn't have version 0.11.5 of librdkafka.
You can add a repository with the right version of librdkafka in /etc/apt/sources.list as described here:
https://docs.confluent.io/current/installation/installing_cp/deb-ubuntu.html#systemd-ubuntu-debian-install

How to build a kivy application using buildozer and the latest kivy?

Using buildozer I have successfully built and run an Android application.
Buildozer uses kivy-stable (1.7)
How do I build a kivy application using the latest kivy 1.8 ?
I noticed at
https://github.com/kivy/python-for-android/blob/master/recipes/kivy/recipe.sh the lines
VERSION_kivy=${VERSION_kivy:-stable}
URL_kivy=https://github.com/kivy/kivy/zipball/$VERSION_kivy/kivy-$VERSION_kivy.zip
Does this mean that only the kivy-stable version can be used with buildozer ?
Thanks
I can't remember if buildozer has a switch to use kivy master (1.8 is unreleased), but you can certainly make it work. Here's a few instructions assuming your shell is something bash-like.
First, create your own local kivy repository:
git clone https://github.com/kivy/kivy.git
Second, export the environment variable P4A_kivy_DIR to point at this directory. If this variable exists, python-for-android (including the one downloaded and used by buildozer) will use that directory to build kivy.
export P4A_kivy_DIR="$PWD/kivy$
echo $P4A_kivy_DIR
The second line should print out the directory of your newly cloned kivy.
You can then run buildozer. You might need to first delete the .buildozer file in your app dir, or more specifically some of the python-for-android components - easiest is just to do
rm -rf /path/to/your/app/.buildozer/android/platform/python-for-android
After that, just run buildozer and the python-for-android component should use your copy of kivy master.
If you want this behaviour to automatically work every time, you could put the export line in your .bashrc or some other suitable shell setup file. If you don't do this, you'll need to run the export line every time you create or replace a .buildozer directory.
Now (as on January, 2020) there is an easier option: just specify version in buildozer.spec, e.g.:
requirements = python3,kivy==2.0.0rc1
Google Colab!!!
go to this website: https://colab.research.google.com/
Step 1 : Create a new Note Book
Step 2 : add a new code
Step 3:add your main python file and kv file
Note: Make sure that your notebook is connected to runtime
Step 4:Copy and paste these codes in spreate code cells
!pip install buildozer
.
!pip install cython==0.29.19
.
!sudo apt-get install -y \
python3-pip \
build-essential \
git \
python3 \
python3-dev \
ffmpeg \
libsdl2-dev \
libsdl2-image-dev \
libsdl2-mixer-dev \
libsdl2-ttf-dev \
libportmidi-dev \
libswscale-dev \
libavformat-dev \
libavcodec-dev \
zlib1g-dev
.
!sudo apt-get install -y \
libgstreamer1.0 \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good
.
!sudo apt-get install build-essential libsqlite3-dev sqlite3 bzip2 libbz2-dev zlib1g-dev libssl-dev openssl libgdbm-dev libgdbm-compat-dev liblzma-dev libreadline-dev libncursesw5-dev libffi-dev uuid-dev libffi6
.
!sudo apt-get install libffi-dev
.
!buildozer init
.
Make sure to rename your python file as main.py
and also upload all the images used in the programe(if used)
navigate to builder.spec file
uncomment and comment these following lines
add __version__ = 0.1 at the top of your main.py
Then
add these Code
!sudo apt install build-essential autoconf libtool
.
pip install --user -U colorama
.
pip install libtool
.
pip install testcase-automaker
.
pip install autoconf
Finally
add this code ...
This will build the apk
!buildozer -v android debug
This Worked for me
Hope this will work for all
Basically - you specify build related things in your buildozer.spec file.
Detailed how to - available on project page:
https://buildozer.readthedocs.io/en/latest/quickstart.html#init-and-build-for-android
In buildozer.spec you can define:
Requirements needed to build/ compile your project like:
# (list) Application requirements
# comma separated e.g. requirements = sqlite3,kivy
requirements =python3,kivy,kivymd==0.104.2,pillow==9.1.0,sqlite3
You shouldn't forget about Android permissions if needed for example:
# (list) Permissions
android.permissions =
READ_EXTERNAL_STORAGE,WRITE_EXTERNAL_STORAGE
Last thing in the specs is to define architecture for compiled file. For example:
# (int) Target Android API, should be as high as possible.
android.api = 30
And:
# (list) The Android archs to build for, choices: armeabi-v7a, arm64-v8a, x86, x86_64
android.archs = armeabi-v7a, x86
Then terminal command to buildozer to compile:
$ buildozer -v android debug
You will end up with *.apk file that can be used on physical device (copy to the device, grant permissions to the file on the physical device) or in Android emulator (i.e. GenyMotion -> https://www.geeksforgeeks.org/how-to-set-up-an-emulator-for-vscode/).
If any troubles in build or live debugging you can connect to the emulator with adb, like:
$ adb logcat YOUR_DEVICE_IP > log.txt

Resources