Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .env
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
# API key for cutt.ly
CUTTLY_API_KEY=
# Credentials to retrieve the SSL certificate
KEYSTORE_PASSWORD=
KEYMANAGER_PASSWORD=
KEYSTORE_PATH=
# Credentials to access rdfshape DB on mongo db atlas
MONGO_DATABASE=
MONGO_USER=
MONGO_PASSWORD=

# Github token needed to download weso dependencies
# GITHUB_TOKEN=
11 changes: 2 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,9 @@ RUN curl -s https://bintray.com/sbt/rpm/rpm | \

# ARGs - Override with: --build-arg [ARGUMENT]=[VALUE]
# Values in .env will not be taken into account!
# Permalink service creds.
ARG MONGO_DATABASE=""
ARG MONGO_USER=""
ARG MONGO_PASSWORD=""
# Needed at container runtime.
ENV MONGO_DATABASE=$MONGO_DATABASE
ENV MONGO_USER=$MONGO_USER
ENV MONGO_PASSWORD=$MONGO_PASSWORD
# Github token needed to download weso packages
# Github token needed to download weso packages at build time.
ARG GITHUB_TOKEN=""

# Port for the app to run
ENV PORT=80
# Add rdfshape output-directory to path
Expand Down
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,20 @@ RDFShape is already deployed [here](http://rdfshape.weso.es).

## Build a docker image

* Use the provided Dockerfile to build rdfshape image.
* Use the provided Dockerfile to build RdfShape image.
* When building the Docker image, you may provide the following arguments
via `--build-arg`:
* [GITHUB_TOKEN]: A valid GitHub token to download WESO project dependencies
from Github packages. This is required to build the image.
* [MONGO_DATABASE, MONGO_USER, MONGO_PASSWORD]: The credentials to a MongoDB
Atlas instance in order to use the permalink service. These are optional,
but permalinks won't work if left undefined. WESO members may
use [these credentials](https://github.com/weso/wesolocal/wiki/Servicios-de-Terceros#mongo-db-atlas).

> Deprecated:
> * Install [SBT](https://www.scala-sbt.org/)
> * Run `sbt docker:publishLocal` which will create a docker file at `target/docker`
* **GITHUB_TOKEN**:
- A valid GitHub token to download WESO project dependencies from Github
packages. This is required when manually building the image.
- Images available
in [Docker Hub](https://hub.docker.com/r/wesogroup/rdfshape-api) have
already been built using a read-only token for downloading the
dependencies.

* When running a container, you may provide the following environment variables
via `--env`:
- **PORT** (optional): Port where the API is exposed inside the container. Default is 80.

# Dependencies

Expand Down Expand Up @@ -83,5 +84,5 @@ pull request to add more features or submit issues:
* [Issues about SHACLex validation library](https://github.com/labra/shaclex/issues)

<a href="https://github.com/weso/rdfshape/graphs/contributors">
<img src="https://contributors-img.web.app/image?repo=weso/rdfshape" />
<img src="https://contributors-img.web.app/image?repo=weso/rdfshape" alt="RdfShape contributors"/>
</a>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package es.weso.server

import cats.effect._
import es.weso.server.APIDefinitions._
import es.weso.server.QueryParams.{HostNameParam, UrlCodeParam, UrlParam}
import es.weso.server.QueryParams.{UrlCodeParam, UrlParam}
import org.http4s._
import org.http4s.client.Client
import org.http4s.dsl.Http4sDsl
Expand Down Expand Up @@ -60,8 +60,13 @@ class PermalinkService(client: Client[IO]) extends Http4sDsl[IO] {
subscription.request(1)
override def onNext(result: InsertOneResult): Unit =
println(s"Created permalink: $url => $urlCode")
override def onError(e: Throwable): Unit =
override def onError(e: Throwable): Unit = {
println(s"Permalink creation failed: ${e.getMessage}")
InternalServerError(
s"Could not generate the permalink for url: $url"
)
}

override def onComplete(): Unit =
println("Permalink processing completed.")
})
Expand All @@ -73,7 +78,7 @@ class PermalinkService(client: Client[IO]) extends Http4sDsl[IO] {
BadRequest(s"Invalid URL provided for shortening: $url")
case _: Exception =>
InternalServerError(
s"Could not execute generate the permalink for url: $url"
s"Could not generate the permalink for url: $url"
)
}

Expand Down Expand Up @@ -132,11 +137,13 @@ class PermalinkService(client: Client[IO]) extends Http4sDsl[IO] {
)
}
}
// DB credentials
private val mongoUser = sys.env.getOrElse("MONGO_USER", "")
private val mongoPassword = sys.env.getOrElse("MONGO_PASSWORD", "")
private val mongoDatabase = sys.env.getOrElse("MONGO_DATABASE", "")
private val collectionName = "permalinks"
// DB credentials. Access is limited to application needs.
private val mongoUser = sys.env.getOrElse("MONGO_USER", "rdfshape-user")
private val mongoPassword =
sys.env.getOrElse("MONGO_PASSWORD", "rdfshape-user")
private val mongoDatabase = sys.env.getOrElse("MONGO_DATABASE", "rdfshape")
private val collectionName =
sys.env.getOrElse("MONGO_COLLECTION", "permalinks")
private val mongoConnectionString =
s"mongodb+srv://$mongoUser:$mongoPassword@cluster0.pnja6.mongodb.net/$mongoDatabase" +
"?retryWrites=true&w=majority"
Expand Down