From 64709147ffbd6d5d2615f94fc8e3e87cd84d77a5 Mon Sep 17 00:00:00 2001 From: Eduardo Date: Sun, 12 Sep 2021 18:04:03 -0300 Subject: [PATCH] develop-v1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit :rocket: Adição do projeto inteiro no container - Conseguindo rodar o projeto localmente e via docker - Adição do product-ms no compose - Adição de DockerFile pra gerar a img do product-ms - Adição de scripts pra startar e parar a aplicação --- dockerStart.sh | 10 ++++++++++ dockerStop.sh | 6 ++++++ init.sh | 1 - src/main/docker/Dockerfile | 18 ++++++++++++++++++ src/main/docker/docker-compose.yaml | 20 +++++++++++++++++++- 5 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 dockerStart.sh create mode 100644 dockerStop.sh delete mode 100644 init.sh create mode 100644 src/main/docker/Dockerfile diff --git a/dockerStart.sh b/dockerStart.sh new file mode 100644 index 0000000..340d898 --- /dev/null +++ b/dockerStart.sh @@ -0,0 +1,10 @@ +cd "$(find ~ -type d -name product-ms-quarkus | head -1)" + +mvn clean package -Dmaven.test.skip=true + +docker image build -t product-ms-quarkus . -f ./src/main/docker/Dockerfile + +docker-compose -f src/main/docker/docker-compose.yaml up -d product-ms-database +docker-compose -f src/main/docker/docker-compose.yaml up -d product-ms-quarkus + +echo "containers gerados com sucesso!" diff --git a/dockerStop.sh b/dockerStop.sh new file mode 100644 index 0000000..402aed0 --- /dev/null +++ b/dockerStop.sh @@ -0,0 +1,6 @@ +docker container rm --force product-ms-quarkus && docker container rm --force product-ms-quarkus-database + +docker image rm $(docker images 'product-ms-quarkus') +docker image rm $(docker images 'mongo') + +echo "containers & suas imagens foram parados e removidos com sucesso!" diff --git a/init.sh b/init.sh deleted file mode 100644 index cfd2150..0000000 --- a/init.sh +++ /dev/null @@ -1 +0,0 @@ -docker-compose -f src/main/docker/docker-compose.yaml up -d diff --git a/src/main/docker/Dockerfile b/src/main/docker/Dockerfile new file mode 100644 index 0000000..28f065b --- /dev/null +++ b/src/main/docker/Dockerfile @@ -0,0 +1,18 @@ +FROM openjdk:11 + +ENV MONGODB_URL="mongodb://admin:admin123@product-ms-database:27015/product-ms" + +WORKDIR /deployments + +COPY target/quarkus-app/lib/ /deployments/lib/ +COPY target/quarkus-app/*.jar /deployments/ +COPY target/quarkus-app/app/ /deployments/app/ +COPY target/quarkus-app/quarkus/ /deployments/quarkus/ + +CMD ["java", "-jar", "quarkus-run.jar"] + +RUN ls -l /deployments + +RUN echo '\n\n * * * Imagem gerada com sucesso * * * \n' + + diff --git a/src/main/docker/docker-compose.yaml b/src/main/docker/docker-compose.yaml index 53cd82f..bc0f6ed 100644 --- a/src/main/docker/docker-compose.yaml +++ b/src/main/docker/docker-compose.yaml @@ -1,11 +1,23 @@ version: '3' services: + product-ms-quarkus: + image: product-ms-quarkus + container_name: product-ms-quarkus + ports: + - 9999:9999 + expose: + - 9999 + depends_on: + - product-ms-database + networks: + - bridge-network + product-ms-database: image: mongo command: mongod --port 27015 restart: always - container_name: product-ms-database + container_name: product-ms-quarkus-database environment: MONGO_INITDB_ROOT_USERNAME: admin MONGO_INITDB_ROOT_PASSWORD: admin123 @@ -14,3 +26,9 @@ services: - 127.0.0.1:27015:27015 expose: - 27015 + networks: + - bridge-network + +networks: + bridge-network: + driver: bridge