This repository contains code to shorten URLs, it is a part of the final examination of the course "Webservices".
There are currently four branches which contain three different versions of the application.
- The main branch contains a Micronaut version(Native Image + Consul Service Discovery + Consul Config)
- The quarkus branch contains a Quarkus version(Native image), development of this version has stopped.
- The spring-boot branch contains a Spring Boot version, development of this version has stopped.
- The micronaut branch is no longer active. Development of this version has moved to the main branch, but this branch is kept for documentation
{
"url": "http://google.com"
}The link needs to have http:// or https:// in the beginning, www is optional
| Environment variable | Description | Default |
|---|---|---|
| CONSUL_HOST | The URL/IP address of the Consul server | localhost |
| CONSUL_PORT | The port of the Consul server | 8500 |
Should be placed in k/v store in config/url-shortener and in yaml format.
The reason why it's not url_shortener is because consul doesn't appear to support "_" in the name of services.
micronaut:
server:
port: 8080
datasources:
default:
url: jdbc:mysql://<database_url>
username: <username> # This is stored as clear text, will probably not be updated to be stored as a secret at this time.
password: <password> # This is stored as clear text, will probably not be updated to be stored as a secret at this time.
dialect: MYSQL
jpa.default.properties.hibernate.hbm2ddl.auto: update
netty:
default:
allocator:
max-order: 3To package to native image and create a Docker image run the following command if you HAVE Maven installed on your machine:
mvn -B package -Dpackaging=docker-native -Pgraalvm --file pom.xml
To package to native image and create a Docker image run the following command if you DO NOT HAVE Maven installed on your machine:
./mvnw -B package -Dpackaging=docker-native -Pgraalvm --file pom.xml
docker run --name url_shortener -d -p 8080:8080 -e CONSUL_HOST=localhost -e CONSUL_PORT=8500
ghcr.io/darkendhall/url_shortener:micronaut