"ERROR: Failed to build gem native extension" building Docker image - ruby-on-rails

I'm trying to build a Docker image based on ruby:3.0. Inside Dockerfile, when running "RUN bundle install", start installing dependencies until error is shown:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension. #10
34.20 #10 34.20 current directory: /usr/local/bundle/gems/tiny_tds-2.1.5/ext/tiny_tds #10 34.20
/usr/local/bin/ruby -I /usr/local/lib/ruby/3.0.0 -r #10 34.20
./siteconf20220804-7-s3hvms.rb extconf.rb #10 34.20 looking for
freetds headers in the following directories: #10 34.20 -
/opt/local/include #10 34.20 - /opt/local/include/freetds #10 34.20 -
/usr/local/include #10 34.20 - /usr/local/include/freetds #10 34.20
looking for freetds library in the following directories: #10 34.20 -
/opt/local/lib #10 34.20 - /opt/local/lib/freetds #10 34.20 -
/usr/local/lib #10 34.20 - /usr/local/lib/freetds
Normally this issue is solved installing linux distribution headers files that is using, but in this case, I am not know how do it.
Dockerfile is this:
FROM ruby:3.0
## throw errors if Gemfile has been modified since Gemfile.lock
RUN bundle config --global frozen 1
WORKDIR /usr/src/app
COPY Gemfile Gemfile.lock ./
RUN gem i bundler
RUN bundle install
COPY . .
CMD ["rails c"]
I tried adding this to Dockerfile, but another error was shown:
RUN apt-get install ruby-dev
Thank you very much in advance to whoever can help me.

Try building on the 3.0-buster image because I think that comes with additional packages. More info here: https://hub.docker.com/_/ruby

I run RUN apt-get install ruby-dev in Dockerfile and this issue is the same to you.
I change to bellow. Beside you can add other lib such as nodejs postgresql-client ... I have consulted here https://docs.docker.com/samples/rails/
RUN apt-get update -qq && apt-get install -yq --no-install-recommends \
libpq-dev \
ruby-dev
or
RUN apt-get update -qq && apt-get install -y ruby-dev

Related

Unable to execute 'gcc': No such file or directory in Airflow (Docker)

I'm trying to install dbt-core and dbt-redshift in Airflow (Docker) but when I do so I get the error
#9 51.00 unable to execute 'gcc': No such file or directory
#9 51.00 error: command 'gcc' failed with exit status 1
I tried installing gcc with docker build but i still get the same error. My Dockerfile looks like this. Requirements contain dbt-core and dbt-redshift only
FROM python:3.7
RUN apt-get update
RUN apt-get install gcc libc-dev g++ libffi-dev libxml2 libffi-dev unixodbc-dev -y
FROM apache/airflow:2.1.2
COPY requirements.txt /requirements.txt
RUN pip install --no-cache-dir --user -r /requirements.txt
If i build the first command separately it finishes successfully and it looks like gcc gets installed. But then i build the second command and i get the same error again.

One of the configured repositories failed (Unknown),

Pretty new to docker; trying to get base layer setup on docker though it gives me these errors:
It's noting that the repository is failing / how do I set that repository?
I don't think it's AWS issue as I have been able to see the AWS push in cloud formation.
$./generate_base_layer.sh
Error: No such container: layer-container
[+] Building 27.7s (6/13)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 551B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/amazonlinux:2 0.9s
=> [auth] library/amazonlinux:pull token for registry-1.docker.io 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 37B 0.0s
=> [2/8] RUN yum install -y python37 && yum install -y python3-pip && yum install -y 26.7s
=> => # Loaded plugins: ovl, priorities
> [2/8] RUN yum install -y python37 && yum install -y python3-pip && yum install -y zip && yum clean all:
#6 0.369 Loaded plugins: ovl, priorities
#6 36.47
#6 36.47
#6 36.47 One of the configured repositories failed (Unknown),
#6 36.47 and yum doesn't have enough cached data to continue. At this point the only
#6 36.47 safe thing yum can do is fail. There are a few ways to work "fix" this:
#6 36.47
#6 36.47 1. Contact the upstream for the repository and get them to fix the problem.
#6 36.47
#6 36.47 2. Reconfigure the baseurl/etc. for the repository, to point to a working
#6 36.47 upstream. This is most often useful if you are using a newer
#6 36.47 distribution release than is supported by the repository (and the
#6 36.47 packages for the previous distribution release still work).
#6 36.47
#6 36.47 3. Run the command with the repository temporarily disabled
#6 36.47 yum --disablerepo=<repoid> ...
#6 36.47
#6 36.47 4. Disable the repository permanently, so yum won't use it by default. Yum
#6 36.47 will then just ignore the repository until you permanently enable it
#6 36.47 again or use --enablerepo for temporary usage:
#6 36.47
#6 36.47 yum-config-manager --disable <repoid>
#6 36.47 or
#6 36.47 subscription-manager repos --disable=<repoid>
#6 36.47
#6 36.47 5. Configure the failing repository to be skipped, if it is unavailable.
#6 36.47 Note that yum will try to contact the repo. when it runs most commands,
#6 36.47 so will have to try and fail each time (and thus. yum will be be much
#6 36.47 slower). If it is a very temporary problem though, this is often a nice
#6 36.47 compromise:
#6 36.47
#6 36.47 yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
#6 36.47
#6 36.47 Cannot find a valid baseurl for repo: amzn2-core/2/aarch64
#6 36.47 Could not retrieve mirrorlist http://amazonlinux.default.amazonaws.com/2/core/latest/aarch64/mirror.list error was
#6 36.47 12: Timeout on http://amazonlinux.default.amazonaws.com/2/core/latest/aarch64/mirror.list: (28, 'Failed to connect to amazonlinux.default.amazonaws.com port 80 after 4723 ms: Connection timed out')
------
executor failed running [/bin/sh -c yum install -y python37 && yum install -y python3-pip && yum install -y zip && yum clean all]: exit code: 1
Unable to find image 'base-layer:latest' locally
docker: Error response from daemon: pull access denied for base-layer, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.
Error: No such container:path: layer-container:layer.zip
I've already logged into docker and tried it with docker build -t... ; same issue
dockerfile:
FROM amazonlinux:2
# Install Python
RUN yum install -y python37 && \
yum install -y python3-pip && \
yum install -y zip && \
yum clean all
# Set up PIP and Venv
RUN python3.7 -m pip install --upgrade pip && \
python3.7 -m pip install virtualenv
RUN python3.7 -m venv base
RUN source base/bin/activate
# Install dependencies
COPY ./requirements.txt .
RUN pip install -r requirements.txt -t ./python
# Zip it up for deployment.
RUN zip -r layer.zip ./python/
ENTRYPOINT ["/bin/bash", "-l"]
generate_base.. file:
# Generates a base layer for the Lambda functions.
# Remove the container first (if it exists).
docker rm layer-container
# Build the base layer.
docker build -t base-layer .
# Rename it to layer-container.
docker run --name layer-container base-layer
# Copy the generated zip artifact so our CDK can use it.
docker cp layer-container:layer.zip . && echo "Created layer.zip with updated base layer."

Installing libsndfile1 on docker container [duplicate]

This question already has an answer here:
Can not install package within docker debian:jessie
(1 answer)
Closed 1 year ago.
I'm trying to install soundfile over pip install on my docker container. Sadly i need to install libsndfile1 manually over apt get by myself. This fails somehow and i don't really get why and does anyone know how to install it.
I'm running docker desktop on Win10 - but container will finally run on a Linux machine.
> [ 7/11] RUN apt-get install libsndfile1:
#11 0.618 Reading package lists...
#11 1.814 Building dependency tree...
#11 2.219 Reading state information...
#11 2.829 The following additional packages will be installed:
#11 2.830 libflac8 libogg0 libvorbis0a libvorbisenc2
#11 2.942 The following NEW packages will be installed:
#11 2.944 libflac8 libogg0 libsndfile1 libvorbis0a libvorbisenc2
#11 2.956 0 upgraded, 5 newly installed, 0 to remove and 3 not upgraded.
#11 2.956 Need to get 669 kB of archives.
#11 2.956 After this operation, 2136 kB of additional disk space will be used.
#11 2.956 Do you want to continue? [Y/n] Abort.
------
executor failed running [/bin/sh -c apt-get install libsndfile1]: exit code: 1
Anyone know something?
Use the command with an automatic yes to make it run non-interactively.
RUN apt-get --yes install libsndfile1
And FYI - this dangerous --force-yes option too is available.
Use with absolute discretion if necessary.
Read about apt-get options here.

Dockerfile error when running apt-get install

Im new to docker and tried a few different setups in my Dockerfile and it works great. Now when I try to use apt-get install inside my docker file (docker build .) it just breaks and I get the following error:
=> ERROR [ 6/14] RUN apt-get install -y php8.0-gd
------
> [ 6/14] RUN apt-get install -y php8.0-gd:
#11 0.213 Reading package lists...
#11 0.670 Building dependency tree...
#11 0.767 Reading state information...
#11 0.846 E: Unable to locate package php8.0-gd
#11 0.846 E: Couldn't find any package by glob 'php8.0-gd'
#11 0.846 E: Couldn't find any package by regex 'php8.0-gd'
I've tried to change to other apt-get install packages but same result no matter what package I try to install. I've also tried to install all packages in one RUN command, bud rewrote the code as shown below, to see if it was one specific package that crashed it.
Here is my code:
FROM php:8.0-apache-buster
RUN mkdir /workdir
WORKDIR /workdir
COPY . .
RUN apt-get update -y
RUN apt-get install -y php8.0-gd
RUN apt-get install -y php8.0-imagick
RUN apt-get install -y php8.0-pgsql
RUN apt-get install -y php-gettext
RUN apt-get install -y php8.0-curl
RUN apt-get install -y php8.0-soap
RUN apt-get install -y php-bcmath
RUN apt-get install -y language-pack-ko-base
RUN a2enmod rewrite
EXPOSE 80
CMD ["/usr/sbin/apache2ctl","-DFOREGROUND"]
I've searched and search but cannot find someone with the same problem. I am really new to Docker and I havn't figgured out if it is better to set this up in the docker-composer.yml file?
Please try this
FROM php:8.0-apache-buster
RUN mkdir /workdir
WORKDIR /workdir
COPY . .
RUN apt-get -y update && apt-get upgrade
RUN apt-get install -y lsb-release ca-certificates apt-transport-https software-properties-common
RUN apt-get install -y php8.0-gd php8.0-imagick php8.0-pgsql php-gettext php8.0-curl php8.0-soap php-bcmath language-pack-ko-base
RUN a2enmod rewrite
EXPOSE 80
CMD ["/usr/sbin/apache2ctl","-DFOREGROUND"]
Please refer this SO thread about using RUN multiple lines.

How do I install open-ssh client and server in an image of type debian:stretch inside a container?

I need to install ssh in order to run the following command:
git+ssh://git#github.com/some_org/some_repo#egg=some_egg
This failed with the following error:
Collecting athena from git+ssh://git#github.com/some_org/some_repo-py#egg=some_egg (from -r /requirements/athena.txt (line 2))
Cloning ssh://git#github.com/some_org/some_repo to /tmp/pip-build-jx3xzcel/athena
error: cannot run ssh: No such file or directory
fatal: unable to fork
Command "git clone -q ssh://git#github.com/some_org/some_repo /tmp/pip-build-jx3xzcel/athena" failed with error code 128 in None
You are using pip version 9.0.3, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
The command '/bin/sh -c pip3 install -r /requirements/athena.txt' returned a non-zero code: 1
Makefile:109: recipe for target 'build' failed
It seems that I do not have the ssh installed in the container, hence, trying to install it.
I have already tried with the commands available on various pages to install ssh on Debian, none of them have worked. Those commands include installing openssh-server and openssh-client via apt-get
RUN apt-get install -yqq openssh-server
I expect to have ssh installed and this step in the dockerfile to be a successful one but instead, I am getting the following error:
Step 20/38 : RUN apt-get install openssh-server
---> Running in e63d8d044b88
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package openssh-server
The command '/bin/sh -c apt-get install openssh-server' returned a non-zero code: 100
make: *** [dev] Error 100

Resources