mvn clean install fails inside of Dockerfile - docker

I'm new to docker and I'm trying to clone a repo then running mvn clean install
the when I build my dockerfile , mvn clean install starts for awhile then eventually exits with exit code 1
executor failed running [/bin/sh -c mvn clean install]: exit code: 1
My docker file is the following
FROM maven:3.6.0-jdk-11-slim AS build
WORKDIR /src
# Update aptitude with new repo
RUN apt-get update
# Install git software
RUN apt-get install -y git
# cloning eclipse-hawkbit rep
RUN git clone https://github.com/eclipse/hawkbit.git /project/hawkbit
WORKDIR /project/hawkbit
RUN ls
# generating the binary
RUN mvn clean install
can someone help me out please :D

Related

Why can't I get ocaml/opam:ubuntu-16.04_ocaml-4.03.0 docker Image?

I was trying to run:
docker build -f hol-light/Dockerfile_check_proofs --ulimit stack=1000000000 --tag check_proofs hol-light/
but I get the error:
Sending build context to Docker daemon 48.9MB
Step 1/16 : FROM ocaml/opam:ubuntu-16.04_ocaml-4.03.0
pull access denied for ocaml/opam, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
Why?
The docker file is: https://github.com/brain-research/hol-light/blob/master/Dockerfile_check_proofs
FROM ocaml/opam:ubuntu-16.04_ocaml-4.03.0
WORKDIR /home/opam/
SHELL ["/bin/bash", "-c"]
ENV PATH="/home/opam/.opam/4.03.0/bin:${PATH}"
### Install num
RUN opam install num
### Install campl5
RUN git clone --depth 1 -b rel617 https://github.com/camlp5/camlp5
RUN cd camlp5 &&\
./configure &&\
make world.opt &&\
make install &&\
# meta/Makefile in camlp5 skips these files which we need, so copy them
# manually.
cp {main/pcaml,main/quotation,etc/pa_reloc,meta/q_MLast}.{cmi,cmx,o} `camlp5 -where`
### Install grpc
RUN sudo apt-get update &&\
sudo apt-get install -y build-essential autoconf libtool pkg-config clang libc++-dev
RUN git clone -b 'v1.17.1' --recurse-submodule --depth 1 https://github.com/grpc/grpc
RUN sudo make -C grpc install-headers_c install-static_c install-pkg-config_c\
install-headers_cxx install-static_cxx install-pkg-config_cxx\
install-plugins
RUN sudo make -C grpc/third_party/protobuf install
### Install farmhash
RUN git clone --depth 1 https://github.com/google/farmhash &&\
cd farmhash &&\
./configure CXXFLAGS="-DNAMESPACE_FOR_HASH_FUNCTIONS=farmhash"
RUN sudo make -C farmhash install
### Build binaries
COPY --chown=opam:0 . src/
RUN make -C src check_proofs
CMD ["./src/check_proofs"]
crossposted:
https://forums.docker.com/t/why-cant-i-get-ocaml-opam-ubuntu-16-04-ocaml-4-03-0-docker-image/84351
https://hub.docker.com/r/ocaml/opam/ hasn't been updated for 2 years and says:
At some point in the future, the tags in this repository will be deleted
This deletion is currently in progress (in fact, it has been deleting for more than a week now).
The ocaml/opam (opam 1) images generally aren't useful now because they don't work with the current opam-repository.
There are two alternatives you can use:
ocaml/opam2 contains opam 2 images. e.g. ocaml/opam2:ubuntu-16.04-ocaml-4.03
ocurrent/opam is also opam 2, but contains much smaller images (with only one version of the compiler per image). e.g. ocurrent/opam:ubuntu-16.04-ocaml-4.03
However, this repository is only temporary. It will replace ocaml/opam once Hub finishes deleting that...

How to invoke yarn command in docker's jenkins?

When I install yarn using this command in CentOS terminal:
sudo wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo
# Install yarn
yum install -y yarn
The yarn command run perfectly in terminal. But when the run the yarn install command in Docker's Jenkins(after docker's jenkins chekcout the project source code,compile react project),this is my build script:
yarn install
yarn build
it throw this error:
/bin/sh -xe /tmp/jenkins3735067167187767767.sh
+ yarn install
/tmp/jenkins3735067167187767767.sh: 2: /tmp/jenkins3735067167187767767.sh: yarn: not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE
When I don't using docker,I know it runs as user jenkins,but now I could not switch to user jenkins because it does not have a jenkins user.How to fix it?
Docker version 1.13.1, build 07f3374/1.13.1
Node version:v10.15.3
yarn version:v1.15.2
Your host is isolated from the docker container, so whatever you need to install you have to install inside the container itself not on the actual host. In case you are using an ubuntu image you need to do the following steps inside your container or inside your Dockerfile if you are building your own image. Make sure to use the root user for these steps:
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
apt update
apt install yarn
If you are just getting started with docker I suggest that you take a look at the following tutorial to get a better view about how it works: https://docs.docker.com/get-started/

Dockerfile is caching an old version of a generated file

I'm working on a Dockerfile with a multi-stage build. The general idea is to build the binary for the backend, build the javascript bundle for the frontend, and then put these two things in a final container for the app.
Here's the docker file:
# go binary
FROM golang:alpine as build-go
RUN apk --no-cache add git bzr mercurial
ENV D=/go/src/github.com/tamuhack-org/quack
RUN go get -d -v golang.org/x/net/html
RUN go get -d -v github.com/gorilla/handlers
RUN go get -d -v github.com/gorilla/mux
COPY ./main.go $D/main.go
COPY ./frontend/dist $D/frontend/dist
RUN rm -rf $D/frontend/dist/index.html
RUN rm -rf $D/frontend/dist/index.js
RUN cd $D && go build -o main && cp main /tmp/
# ui
FROM node:alpine AS build-node
RUN mkdir -p /src/ui
COPY ./frontend/package.json /src/ui/
RUN cd /src/ui && yarn install
COPY ./frontend /src/ui
# Replace the dev instance of index.html with the prod version.
RUN rm -rf /src/ui/dist/index.html
RUN mv /src/ui/dist/index-prod.html /src/ui/dist/index.html
RUN cd /src/ui && yarn build
# final
FROM alpine
RUN apk --no-cache add ca-certificates
WORKDIR /app/server/
COPY --from=build-go /tmp/main /app/server/
COPY --from=build-node /src/ui/dist /app/server/frontend/dist
EXPOSE 8080
CMD ["./main"]
What I've noticed is that when I update the frontend source code and build the docker container, the new version of the container doesn't update with the new bundle. Are there any obvious errors in the Dockerfile that may be the reason for why I'm not seeing any file changes? If I run yarn build locally, the bundle is accurate, but the docker container seems to be caching an older version. Thoughts?

yum install not working from Dockerfile

I was trying to create a Docker Image for ProxySQL . Following is my DockerFile
FROM rhel7:latest
USER root
MAINTAINER Ques Zama
# Update the image with the latest packages (recommended)
RUN yum update -y; yum clean all
# Update image
RUN yum-config-manager --enable proxysql_repo
# Install ProxySQL
RUN yum install proxysql -y
# Expose ProxySQL Port 6034
EXPOSE 6034
# Start the service
CMD /etc/init.d/service start proxysql
I was trying to build the image with below command
sudo docker build --no-cache -t zama_proxysql .
But I can it is not able to install the proxysql package using yum command as mentioned in Dockerfile . Following is the message below
Step 6 : RUN yum install proxysql -y
---> Running in 54cc1ae88ba3
Loaded plugins: ovl, product-id, search-disabled-repos, subscription-manager
No package proxysql available.
Error: Nothing to do
The command '/bin/sh -c yum install proxysql -y' returned a non-zero code: 1
If I execute the command yum install proxysql in commandline , it works fine . But from Dockerfile , it could not find the package. Please note that I have already enabled the repo for proxysql in /etc/yum.repos.d
Any suggestions to resolve the issue
Try adding the repo manually first instead of using yum-config-manager :
cat <<EOF | tee /etc/yum.repos.d/proxysql.repo
[proxysql_repo]
name= ProxySQL YUM repository
baseurl=http://repo.proxysql.com/ProxySQL/proxysql-1.4.x/centos/\$releasever
gpgcheck=1
gpgkey=http://repo.proxysql.com/ProxySQL/repo_pub_key
EOF
This works properly on a FROM centos:7 image.

Host key verification failed on dockerfile build

I have created a ssh key using ssh-keygen and added id-rsa.pub content to my github>settings>SSH & GPG keys.
I am able to clone the repo from my terminal with git clone git#github:myname/myrepo.git
But the same is giving the following error while building the docker file.
Cloning into 'Project-Jenkins'...
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
This is how I added the command in dockerfile
RUN git clone git#github.com:myname/myrepo.git
What went wrong here?
here is my dockerfile
FROM ubuntu
COPY script.sh /script.sh
CMD ["/script.sh"]
FROM python:2.7
RUN apt-get update
RUN apt-get install libmysqlclient-dev
RUN apt-get install -y cssmin
RUN apt-get install -y python-psycopg2
RUN pip install --upgrade setuptools
RUN pip install ez_setup
RUN apt install -y libpq-dev python-dev
RUN apt install -y postgresql-server-dev-all
COPY requirements.txt ./
CMD ["apt-get","install","pip"]
RUN apt-get install -y git
RUN git clone git#github.com:myname/myrepo.git
WORKDIR ./myrepo/LIMA
RUN pip install -r requirements.txt
CMD ["python","manage.py","migrate"]
CMD ["python","manage.py","collectstatic","--noinput"]
CMD ["python","manage.py","runserver"]
EXPOSE 8000
The syntax you have used finally ends up using SSH to clone, and inside the docker container, your github private key is not available which leads to error that you are getting. So instead try using,
RUN git clone https://{myusername}:{mypassword}#github.com/{myusername}/myrepo.git
Also remember if your password has '#' symbol use '%40' instead.
If you want to still go with private key approach, refer this question, How to access GIT repo with my private key from Dockerfile

Resources