Skip to content

Commit

Permalink
develop-v1
Browse files Browse the repository at this point in the history
	🚀 Adição de container

		- Remoção de alguns arquivos do getting-started de DockerFile
		- Trocando application.properties pra application.yaml
		- Adição de dependência do quarkus pra trabalhar com yaml
		- Refatoração da URI do MONGODB_URL
		- Adição de scripts para subir/parar container no mongo
  • Loading branch information
Eduardo committed Sep 11, 2021
1 parent 12180b8 commit 1b181e5
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 211 deletions.
5 changes: 0 additions & 5 deletions .dockerignore

This file was deleted.

1 change: 1 addition & 0 deletions init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker-compose -f src/main/docker/docker-compose.yaml up -d
4 changes: 4 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-config-yaml</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
Expand Down
55 changes: 0 additions & 55 deletions src/main/docker/Dockerfile.jvm

This file was deleted.

51 changes: 0 additions & 51 deletions src/main/docker/Dockerfile.legacy-jar

This file was deleted.

27 changes: 0 additions & 27 deletions src/main/docker/Dockerfile.native

This file was deleted.

23 changes: 0 additions & 23 deletions src/main/docker/Dockerfile.native-distroless

This file was deleted.

16 changes: 16 additions & 0 deletions src/main/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: '3'

services:
product-ms-database:
image: mongo
command: mongod --port 27015
restart: always
container_name: product-ms-database
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: admin123
MONGO_INITDB_DATABASE: product-ms
ports:
- 127.0.0.1:27015:27015
expose:
- 27015
12 changes: 12 additions & 0 deletions src/main/java/org/edudev/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.edudev;

import io.quarkus.runtime.annotations.QuarkusMain;
import io.quarkus.runtime.Quarkus;

@QuarkusMain
public class Main {

public static void main(String ... args) {
Quarkus.run(args);
}
}
13 changes: 1 addition & 12 deletions src/main/java/org/edudev/arch/db/MongoConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,8 @@ public final class MongoConfig {

private final ConnectionString url;

private final String username;

private final String password;

public MongoConfig(final ConnectionString url, final String username, final String password) {
this.url = url;
this.username = username;
this.password = password;
}
public MongoConfig(final ConnectionString url) { this.url = url; }

public ConnectionString getUrl() { return url; }

public String getUsername() { return username; }

public String getPassword() { return password; }
}
21 changes: 2 additions & 19 deletions src/main/java/org/edudev/arch/db/MongoConfigurationProducer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,18 @@
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import java.util.Optional;

@ApplicationScoped
public final class MongoConfigurationProducer {

private final String url;

private final Optional<String> username;

private final Optional<String> password;

@Inject
MongoConfigurationProducer(
@ConfigProperty(name = "MONGODB_URL") final String url,
@ConfigProperty(name = "MONGODB_USERNAME") final Optional<String> username,
@ConfigProperty(name = "MONGODB_PASSWORD") final Optional<String> password
) {
this.url = url;
this.username = username;
this.password = password;
}
MongoConfigurationProducer(@ConfigProperty(name = "MONGODB_URL") final String url) { this.url = url; }

@Produces
public MongoConfig produce() {
return new MongoConfig(
new ConnectionString(this.url),
this.username.orElse(null),
this.password.orElse(null)
);
return new MongoConfig(new ConnectionString(this.url));
}
}

19 changes: 0 additions & 19 deletions src/main/resources/application.properties

This file was deleted.

23 changes: 23 additions & 0 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
MONGODB_URL: mongodb://admin:admin123@localhost:27015/product-ms
quarkus:
swagger-ui:
path: doc
theme: Newspaper
http:
port: 9999
test-port: 8888
mp:
openapi:
extensions:
smallrye:
info:
title: Product MS
version: 1.0.0
description: API desenvolvida para vaga de emprego na Compasso UOL, onde foram implementadas arquiteturas para tratativa e manipulação geral dos registros, visando diminuir o código boiderplate, e consequentemente, melhorar a manuntenção e escalabilidade do software.
contact:
email: [email protected]
name: Eduardo J.
url: https://duduxs.github.io/portfolio/
license:
name: MIT License
url: https://github.com/Duduxs/product-ms-quarkus/blob/master/LICENSE
4 changes: 4 additions & 0 deletions stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
docker container stop product-ms-database
echo "Database stopped"
docker container rm product-ms-database
echo "Database removed"

0 comments on commit 1b181e5

Please sign in to comment.