We are using CodeEffects Rules Engine with Angular Implementation and trying to dockerize the application. But the build is throwing an exception; need help from this group in resolving the error.
Below is my docker script and also attaching the error screenshot for reference
NOTE: Application works fine without docker in local.
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
RUN apt-get update && \
apt-get install -y wget && \
apt-get install -y gnupg2 && \
wget -qO- https://deb.nodesource.com/setup_12.x | bash - && \
apt-get install -y build-essential nodejs
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "CodeEffects.Rule.Angular.Demo.dll"]
Related
I am running 90 microservices in openshift and few of the services are in CrashLoopBackOff and logs showing the following error message.
Error:
OC logs -f :
"standard_init_linux.go:219: exec user process caused: no such file or directory"
OC Describe:
Is there an issue with the image because describe output shows:
"Container image "IMAGE_TAG" already present on machine"
Due to the fact that there is lack of information -
it is impossible to say exactly where the problem is.
I have found some similar errors.
Here is one of the best solutions that matches description of your problem:
Here the key to solve the problem was replacing the aronautica crate via rust-argon2 and modifying the Dockerfile:
FROM rust AS build
WORKDIR /usr/src
RUN apt-get update && apt-get upgrade -y && apt-get install -y build-essential git clang llvm-dev libclang-dev libssl-dev pkg-config libpq-dev brotli
RUN USER=root cargo new loxe-api WORKDIR /usr/src/loxe-api COPY
Cargo.toml Cargo.lock ./ COPY data ./data COPY migrations ./migrations
RUN cargo build --release
# Copy the source and build the application. COPY src ./src ENV PKG_CONFIG_ALLOW_CROSS=1 ENV
OPENSSL_INCLUDE_DIR="/usr/include/openssl" RUN cargo install --path .
FROM debian:buster-slim COPY --from=build
/usr/local/cargo/bin/loxe-api .
# standard env COPY .env ./.env COPY data ./data COPY migrations ./migrations RUN apt-get update && apt-get install -y libssl-dev
pkg-config libpq-dev brotli CMD ["/loxe-api"] ```
See also this similar issues:
second one
third one
Pretty much the question. Here's what I have currently:
FROM node:15 as server
WORKDIR /app
ENV NODE_ENV=production
COPY server/package.json ./
RUN npm install
COPY server/ ./
RUN apt-get update
RUN apt-get install -y mongo-tools
EXPOSE 5000
CMD ["node", "src/app.js"]
Which does work however mongo-tools is a really outdated version of the tools and is not fit for my pusposes.
Mongo Docs has instructions for how to install the newer mongodb-database-tools on linux/windows/macos but I can't figure out how to get it to work in a DockerFile.
For anyone wondering, I'm trying to get a node-cron to periodically call mongodump on a mongodb atlas database.
Any help is appreciated :)
you can download newer version of the tools and install it, just like you do on linux host
example Dockerfile like below:
FROM node:15 as server
WORKDIR /app
ENV NODE_ENV=production
RUN wget https://fastdl.mongodb.org/tools/db/mongodb-database-tools-debian92-x86_64-100.3.1.deb && \
apt install ./mongodb-database-tools-*.deb && \
rm -f mongodb-database-tools-*.deb
COPY server/package.json ./
RUN npm install
COPY server/ ./
EXPOSE 5000
CMD ["node", "src/app.js"]
Hi I am trying to run postgresql in alpine in docker with SQLAlchemy and flask but anytime I run my app I get this error ImportError: Error loading shared library libpq.so.5: No such file or directory (needed by /usr/local/lib/python3.8/site-packages/psycopg2/_psycopg.cpython-38-x86_64-linux-gnu.so)
I have combed stack overflow for a solution but everyone one them seems to tell me to install
psycopg2 which I have done already
FROM python:3.8.1-alpine3.10 AS build
# ENV PYTHONUNBUFFERED 1
WORKDIR /usr/src/app/restful
COPY requirements.txt /usr/src/app/restful
RUN python -m pip install --upgrade pip
RUN apk update && apk upgrade
RUN apk add libffi-dev
#installing dependencies
# dependencies for libpq postgresql-libs postgresql-dev *remove if not
RUN apk add --no-cache --virtual .build-deps gcc libc-dev py-cryptography libpq postgresql-libs postgresql-dev python3-dev musl-dev make openssl-dev gcc
RUN apk update && apk add --no-cache ca-certificates \
&& update-ca-certificates 2>/dev/null || true
RUN apk add build-base python-dev py-pip jpeg-dev zlib-dev
ENV LIBRARY_PATH=/lib:/usr/lib
WORKDIR /usr/src/app/restful
COPY requirements.txt /usr/src/app/restful
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
RUN python -m pip install --upgrade pip
RUN pip install -r requirements.txt
RUN pip install gevent
FROM python:3.8.1-alpine3.10
COPY --from=build /usr/local/lib/python3.8/site-packages/ /usr/local/lib/python3.8/site-packages/
RUN mkdir -p /usr/src/app/restful
RUN set -ex && apk --no-cache add sudo
RUN apk --no-cache --update add libffi libressl
RUN apk update && apk add --no-cache supervisor
RUN pip install psycopg2-binary
You seem to be using staged builds in your Dockerfile, and your apk add postgresql-libs is in the first stage. That second FROM stage is building off of a plain python:3.8.1-alpine3.10, not on all the stuff you had done above it, and you're only copying /usr/local/lib/python3.8/site-packages/ over to the second stage. You'll either need to find the full paths of all those dependencies (which could be prohibitively tedious), or just install the dependencies on the second stage as well. Therefore, you need to either build your second stage with FROM build (to include all the other apk deps), or you need to add RUN apk add postgresql-libs gcc libc-dev in the second stage.
So depending on what you're going for, you probably need this:
<...>
RUN pip install -r requirements.txt
RUN pip install gevent
FROM build
RUN mkdir -p /usr/src/app/restful
<...>
or this:
<...>
RUN set -ex && apk --no-cache add sudo
RUN apk --no-cache --update add libffi libressl postgresql-libs gcc libc-dev
RUN apk update && apk add --no-cache supervisor
<...>
This was fixed for me by changing my psycopg2 import to psycopg2-binary.
RUN apt-get update && apt-get install libpq5 -y after calling your build did the trick for me.
I just want to load onnx models in raspberry pi. How to load onnx models in edge devices?
You can use ONNX Runtime for ONNX model inference in Raspberry Pi. It support Arm32v7l architecture. Pre-build binary is not provided as of 2020/1/14. So you need to build it from source code. Instruction is described below.
https://github.com/microsoft/onnxruntime/blob/master/dockerfiles/README.md#arm-32v7
Install DockerCE on your development machine by following the instructions here
Create an empty local directory
mkdir onnx-build
cd onnx-build
Save the Dockerfile to your new directory
Dockerfile.arm32v7
FROM balenalib/raspberrypi3-python:latest-stretch-build
ARG ONNXRUNTIME_REPO=https://github.com/Microsoft/onnxruntime
ARG ONNXRUNTIME_SERVER_BRANCH=master
#Enforces cross-compilation through Quemu
RUN [ "cross-build-start" ]
RUN install_packages \
sudo \
build-essential \
curl \
libcurl4-openssl-dev \
libssl-dev \
wget \
python3 \
python3-pip \
python3-dev \
git \
tar \
libatlas-base-dev
RUN pip3 install --upgrade pip
RUN pip3 install --upgrade setuptools
RUN pip3 install --upgrade wheel
RUN pip3 install numpy
# Build the latest cmake
WORKDIR /code
RUN wget https://github.com/Kitware/CMake/releases/download/v3.14.3/cmake-3.14.3.tar.gz
RUN tar zxf cmake-3.14.3.tar.gz
WORKDIR /code/cmake-3.14.3
RUN ./configure --system-curl
RUN make
RUN sudo make install
# Set up build args
ARG BUILDTYPE=MinSizeRel
ARG BUILDARGS="--config ${BUILDTYPE} --arm"
# Prepare onnxruntime Repo
WORKDIR /code
RUN git clone --single-branch --branch ${ONNXRUNTIME_SERVER_BRANCH} --recursive ${ONNXRUNTIME_REPO} onnxruntime
# Start the basic build
WORKDIR /code/onnxruntime
RUN ./build.sh ${BUILDARGS} --update --build
# Build Shared Library
RUN ./build.sh ${BUILDARGS} --build_shared_lib
# Build Python Bindings and Wheel
RUN ./build.sh ${BUILDARGS} --enable_pybind --build_wheel
# Build Output
RUN ls -l /code/onnxruntime/build/Linux/${BUILDTYPE}/*.so
RUN ls -l /code/onnxruntime/build/Linux/${BUILDTYPE}/dist/*.whl
RUN [ "cross-build-end" ]
Run docker build
This will build all the dependencies first, then build ONNX Runtime and its Python bindings. This will take several hours.
docker build -t onnxruntime-arm32v7 -f Dockerfile.arm32v7 .
Note the full path of the .whl file
Reported at the end of the build, after the # Build Output line.
It should follow the format onnxruntime-0.3.0-cp35-cp35m-linux_armv7l.whl, but version number may have changed. You'll use this path to extract the wheel file later.
Check that the build succeeded
Upon completion, you should see an image tagged onnxruntime-arm32v7 in your list of docker images:
docker images
Extract the Python wheel file from the docker image
(Update the path/version of the .whl file with the one noted in step 5)
docker create -ti --name onnxruntime_temp onnxruntime-arm32v7 bash
docker cp onnxruntime_temp:/code/onnxruntime/build/Linux/MinSizeRel/dist/onnxruntime-0.3.0-cp35-cp35m-linux_armv7l.whl .
docker rm -fv onnxruntime_temp
This will save a copy of the wheel file, onnxruntime-0.3.0-cp35-cp35m-linux_armv7l.whl, to your working directory on your host machine.
Copy the wheel file (onnxruntime-0.3.0-cp35-cp35m-linux_armv7l.whl) to your Raspberry Pi or other ARM device
On device, install the ONNX Runtime wheel file
sudo apt-get update
sudo apt-get install -y python3 python3-pip
pip3 install numpy
# Install ONNX Runtime
# Important: Update path/version to match the name and location of your .whl file
pip3 install onnxruntime-0.3.0-cp35-cp35m-linux_armv7l.whl
Test installation by following the instructions here
I've cloned a copy of FreeCAD from github and I'm trying to create a docker file so that I can develop it locally on my machine.
The objectives being that:
I have a local copy of the code from git on my machine
I can make modifications to the code
I can build debug and release image (do I need to create two separate images?)
Have access to the code on my machine, so that I can use git for source control
This is the content of my Dockerfile:
# Get base image
FROM phusion/baseimage
# Use baseimage-docker's init system.
CMD ["/sbin/my_init"]
# Get the build pre-requisites
RUN apt-get update
RUN apt-get install -y build-essential cmake python python-matplotlib libtool
RUN apt-get install -y libcoin80-dev libsoqt4-dev
RUN apt-get install -y libxerces-c-dev libboost-dev libboost-filesystem-dev
RUN apt-get install -y libboost-regex-dev
RUN apt-get install -y libboost-program-options-dev libboost-signals-dev
RUN apt-get install -y libboost-thread-dev libboost-python-dev libqt4-dev
RUN apt-get install -y libqt4-opengl-dev qt4-dev-tools python-dev
RUN apt-get install -y python-pyside pyside-tools
RUN apt-get install -y liboce*-dev oce-draw
RUN apt-get install -y libeigen3-dev libqtwebkit-dev libshiboken-dev
RUN apt-get install -y libpyside-dev libode-dev swig libzipios++-dev
RUN apt-get install -y libfreetype6 libfreetype6-dev
# to make Coin to support additional image file formats
RUN apt-get install -y libsimage-dev
# to register your installed files into your system's package manager, so yo can easily uninstall later
RUN apt-get install -y checkinstall
# needed for the 2D Drafting module
RUN apt-get install -y python-qt4 python-pivy
# doxygen and libcoin80-doc (if you intend to generate source code documentation)
RUN apt-get install -y doxygen libcoin80-doc
# libspnav-dev (for 3Dconnexion devices support like the Space Navigator or Space Pilot)
RUN apt-get install -y libspnav-dev
# CMAke related issue for compiling on Ubuntu Xenial: http://forum.freecadweb.org/viewtopic.php?f=4&t=16292
RUN apt-get install -y libmedc-dev
RUN apt-get install -y libvtk6-dev
RUN apt-get install -y libproj-dev
# Get git
RUN apt-get install -y git
RUN git clone https://github.com/FreeCAD/FreeCAD.git freecad
RUN cd freecad
RUN mkdir freecad-debug
RUN cd freecad-debug
# command below is just a diagnostic to let me know wth I am (output is: /)
# RUN pwd
RUN cmake ../ -DFREECAD_USE_EXTERNAL_PIVY=1 -DCMAKE_BUILD_TYPE=Debug .
#cmake -DFREECAD_USE_EXTERNAL_PIVY=1 -DCMAKE_BUILD_TYPE=Release .
RUN make
I attempt to build the image using the following command:
docker build -tag freeCAD-my-fork .
Everything works until I get to the first cmake invocation. I then get the following error:
CMake Error: The source directory "/" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
The command '/bin/sh -c cmake ../ -DFREECAD_USE_EXTERNAL_PIVY=1 -DCMAKE_BUILD_TYPE=Debug .' returned a non-zero code: 1
I placed a RUN pwd in my Dockerfile, so I could find where the cmake command was being run from, and I was surprised to find that it was been run from the root directory.
I thought the issue was being caused by my use of relative and that it would be fixed by absolute paths - however specifying /path/to/my/copy/freecad when cloning etc, the issue remains.
How can I write my Dockerfile so that it achieves the objectives outlined above (stated at the beginning of my question)?
Default WORKDIR in docker is "/".All docker commands will be executed in that directory.There are two option either you change WORKDIR(https://docs.docker.com/engine/reference/builder/#workdir) or execute everything in one layer(In one RUN command).I have taken second approach.
Cloning and Building source code both executed in One layer of docker.
RUN git clone https://github.com/FreeCAD/FreeCAD.git freecad \
&& cd freecad \
&& mkdir freecad-debug \
&& cd freecad-debug \
&& cmake ../ -DFREECAD_USE_EXTERNAL_PIVY=1 -DCMAKE_BUILD_TYPE=Debug . \
&& make
You should install all your dependencies using run as you do but the actual building and copying of source code files should not happen when you build your image but when you run a container.
This way you can reuse your image for as many builds as you like.
Write a script with the build commands and copy it over to your image. Then in the CMD part of the dockerfile run that script.
To share the git project with the container you can mount your local files with docker run -v hostpath:containerpath imagename. That way any files in hostpath will be visible to the container at containerpath and vice versa. Alternatively you could also git clone from the script which is invoked by CMD but then you have to expose the build somehow to your host (some mounted volume again).