Alright, so I'm trying to create a kind of pipeline to put my application online at Amazon AWS. I am using the following dockerfile:
FROM maven:3.8.5-openjdk-17 AS MAVEN_BUILD
RUN apt-get update && \
apt-get upgrade -y && |
apt-get install git -y
WORKDIR /repositorio/
RUN git clone https://gitlab.com/booking_hub/grupo_04_bookinghub.git
COPY /repositorio/grupo_04_bookinghub/backend/APIrest/APIrest/pom.xml /build/
COPY /repositorio/grupo_04_bookinghub/backend/APIrest/APIrest/src /build/src/
WORKDIR /build/
RUN mvn clean install "-Dmaven.test.skip=true" && mvn package
FROM openjdk:17-slim
WORKDIR /app
COPY --from=MAVEN_BUILD /build/target/APIrest-*.jar /app/APIrest.jar
ENTRYPOINT ["java","-Dspring.profiles.active=dev", "-jar", "APIrest.jar"]
I'm having the following error:
My docker-compose file:
version: "3.7"
services:
#outro container --- backend
springweb:
container_name: bookinghub
build: . #preciso do Dockerfile para gerar a imagem
ports:
- "8080:8080"
networks:
- servers
environment:
SPRING_PROFILES_ACTIVE: dev
networks:
servers:
driver: bridge
This docker-compose is being called by a ansible-playbook file (from a management machine):
- hosts: backend
become: yes
tasks:
# 1
### task desnecessária para uso com docker, o mvn já está sendo puxado da imagem que irá rodar o docker
# - name: "System : instalando o mvn"
# shell:
# cmd: "sudo mvn install"
# chdir: /home/ubuntu/backend
#1
- name: "System: Atualizando o sistema"
become: true
shell:
cmd: "apt-get update"
#2
- name: "System: Instalando dependências do Docker"
become: true
apt:
name: "{{item}}"
state: present
update_cache: yes
loop:
- ca-certificates
- curl
- gnupg
- gnupg-agent
- lsb-release
#3
- name: "Docker : adicionar chave GPG"
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
#4
- name: "Docker : adicionar repositório do instalador"
apt_repository:
repo: deb https://download.docker.com/linux/ubuntu bionic stable
state: present
#5
- name: "Docker : instalacao"
apt:
name: "{{item}}"
state: latest
update_cache: yes
loop:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-compose
#6
- name: "Docker : instalar python e pip, Ansible precisa para poder iniciar e executar o Docker"
apt:
name: "{{item}}"
state: latest
update_cache: yes
loop:
- python3
- pip
#7
- name: " Docker : Instalar recurso que o ansible precisa para o docker"
pip:
name: docker
#Fim da instalação do Docker
handlers:
- name: "System : reiniciar o Docker"
service:
name: docker
state: restarted
- name: Criar rede servers
docker_network:
name: servers
driver: bridge
state: present
force: yes
- hosts: backend
tasks:
- name: "System: Executando o docker compose da aplicação Backend"
become: true
shell:
cmd: "docker-compose -f docker-compose-java.yml up"
chdir: /home/ubuntu/Backend
I am stuck in this error and don't know what to do. The official maven image says it runs a Ubuntu based image so APT-GET should've worked.
I tried to change the maven version to 3.8.1 where I found out that this version still used a Ubuntu based where APT-GET work but the same error occurred.
I expect the dockerfile to download a maven image, run a git clone of my project and build it inside the docker image (which will be called by a docker-compose file)
CodePudding user response:
Looks like https://hub.docker.com/_/maven is on oraclelinux which is redhat based.
I think you should try https://oracle-base.com/articles/linux/installing-software-packages#rpm and https://oracle-base.com/articles/linux/installing-software-packages#yum as your package managers.
Good luck!